From 5814cb7c9ec01c4c0ae817cb3beaace186ba32ea Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Fri, 5 Apr 2024 14:12:39 -0500 Subject: [PATCH] Correct the parsing of the tx hash in `TxIn` --- src/ZcashHaskell/Types.hs | 2 +- test/Spec.hs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/ZcashHaskell/Types.hs b/src/ZcashHaskell/Types.hs index f2c5359..0320479 100644 --- a/src/ZcashHaskell/Types.hs +++ b/src/ZcashHaskell/Types.hs @@ -160,7 +160,7 @@ fromRawTxIn t = H.TxIn op (rti_script t) (rti_seq t) then H.nullOutPoint else H.OutPoint ((fromJust . - H.hexToTxHash . toText . hexString . rop_hash . rti_outpoint) + H.hexToTxHash . toText . fromRawBytes . rop_hash . rti_outpoint) t) (rop_n $ rti_outpoint t) diff --git a/test/Spec.hs b/test/Spec.hs index d631b23..6db774b 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -832,6 +832,18 @@ main = do Just t' -> do let ob = zt_oBundle t' fromRawOBundle ob `shouldNotBe` Nothing + describe "Raw transaction with Transparent inputs" $ do + let h = + hexString + "0400008085202f89014b6ded3d2ee43e54135c04f9a305b473d7d741bbe6f383aa636e03e948705e0d01000000fdfd0000483045022100b34ca0fb34959230b95a48e9de95521dc4c013bdc0e6bd2a77a67b373fadea42022030a1b13f16993ab212d9f674b7b8dd3c6723137c183dbd41a9bbfcf66d7811c40147304402200f0bd12663a52ccb5e6211ec633932bbc7f0151ab51194038534abf88f689025022051fe62591dfa11a96095b4aeee2114c77a0d773242939f7ac2fa8e5262ff0865014c6952210231ee0c161e846bc133ad41d295f560d7e24829415afc78ead24d4b10198bb7342103b0b11f2dd10611d06cd6232233678dce736ce2b2141c62bdf0b4fe6f79d736da21029cbeda22b05352f66a338561604cbe11e8332f836385f16abf5088045c39d4dd53aefdffffff02b63500000000000017a91499a8b5b1f3d3a1a12e92dd4f3d94bee8fc34c527873362fa020000000017a914d75fe4791fcd50f2874f1b7457fca5833293b3a38700000000000000000000000000000000000000" + let t = readZebraTransaction h + it "TxIn parsing" $ do + case t of + Nothing -> assertFailure "Couldn't decode" + Just t' -> do + let tb = zt_tBundle t' + print tb + show tb `shouldNotBe` "" -- | Properties prop_PhraseLength :: Property