1

In tx 3a4a7087d4ece4503948b33aa77c807cda770575d229cbcb7dd8336ffa77445a the unique input is 1387e35f2c65f6664e15a98a43b7a70831e636635876a7154c99f38d89a9f795 with index vout = 1. When I request this tx to Bitcoin core (version 0.17.1 for MAC) Why do I get this result :

{
"txid":
"eb20d4cbb350c092205e874358b1cf22195430f5516042ecc4a61ad9cbce7dce",
"hash": 
"eb20d4cbb350c092205e874358b1cf22195430f5516042ecc4a61ad9cbce7dce",
"version": 1,
"size": 258,
"vsize": 258,
"weight": 1032,
"locktime": 0,
"vin": [],
"vout": [
{
  "value": -81633158802.50592511,
  "n": 0,
  "scriptPubKey": {
    "asm": "OP_NOP4 OP_RESERVED1 fcac561ac13cb1fd797dd49f9b3bd9dee003b5cecb0100000000f0ffffff0340420f000000000017a9 46281ac9378a76b004945954e275a243171d759f OP_EQUAL OP_GREATERTHAN 1 0000000000160014a8160b1e0db3418d3592b60c1df5784f7b96f0350000000000000000196a1768747470733a2f2f746274632e6269746170732e636f6d02 3045022100e771433023daa30b7a16127ffb80b98962672fac45dfc8b34e7d0b956c31c8cd02207ce59a29138b02f58b8fb44c20e5863d915f0767441d4f8df136aaa817f12b2101 0263d53e7cabca20523a412092ccc505a259a12e2d81d06b89dc5ae20fe14a1e67",
    "hex": "b38929fcac561ac13cb1fd797dd49f9b3bd9dee003b5cecb0100000000f0ffffff0340420f000000000017a91446281ac9378a76b004945954e275a243171d759f87a0513f0000000000160014a8160b1e0db3418d3592b60c1df5784f7b96f0350000000000000000196a1768747470733a2f2f746274632e6269746170732e636f6d02483045022100e771433023daa30b7a16127ffb80b98962672fac45dfc8b34e7d0b956c31c8cd02207ce59a29138b02f58b8fb44c20e5863d915f0767441d4f8df136aaa817f12b2101210263d53e7cabca20523a412092ccc505a259a12e2d81d06b89dc5ae20fe14a1e67",
    "type": "nonstandard"
  }
}
]
}

which is totally different form the result given by the explorer.

1

This is a known issue due to how segwit data is stored. To parse a transaction correctly, you must use either of the following:

getrawtransaction <tx_id> true
decoderawtransaction <txhex> true

For the first one, the API will return a decoded, complete transaction object including witness data as a JSON object. If you are decoding raw transaction data sourced from elsewhere, you can pass the encoded hex data to decoderawtransaction and set the second (optional) iswitness parameter to true to ask the API to treat it as a segwit transaction.

  • And how do I decide when to put the parameter iswitness to true ? – jfjobidon Aug 19 at 15:34
  • 2
    @jfjobidon Set it to true whenever you're decoding a real transaction (one that is complete, on the chain, or could be broadcast to the nerwork). Set it to false when you have an unsigned transaction. It's a historical mistake that these two distinct use cases use the same hex raw format. – Pieter Wuille Aug 19 at 15:37
1

The problem is with getrawtransaction command in bitcoin core. It doesn't recognize the SegWit input which is why it decode/deserialize the transaction incorrectly (wrong input txid and negative amount in output).
https://bitcointalk.org/index.php?topic=5014781.0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.