Problem with decoding transaction #12989

issue mishabunte openend this issue on April 15, 2018
  1. mishabunte commented at 3:52 pm on April 15, 2018: none

    I have a problem with decoding transaction on testnet. I call method getrawtransaction for txhash f0a1d41cb2d1cea36b334c77f90f1a88b0f01332fffefaac3be9bb77f5b5f5b6

    But then I call the decoderawtransaction it returns another txid in decoded transaction data: 22519827b1dc985ed4d0115e58c3f327a60e44015c8499ff3c5bc7fe5a8ce3f0

    I expect that txid in both cases should be the same

    It occurs everytime, on two different machines

    Bitcoin Core RPC client version v0.16.0.0-g4b4d7eb255

    Ubuntu linux 16.04, i7-2600 CPU

     0genosse@local:~$ bitcoin-cli -testnet getrawtransaction f0a1d41cb2d1cea36b334c77f90f1a88b0f01332fffefaac3be9bb77f5b5f5b6
     102000000000101c79161617adc1cad419254fd0194193dd6786a7faf1f65df9b3a369e8e600a3c0000000000ffffffff017b134c000000000016001443aac20a116e09ea4f7914be1c55e4c17aa600b70248304502210087116858148c7f4e33c05881103444ae5d67b1b5fd922ca18c00127c9683c4a502206ede2a47953942365a01fb772d2644dcfa59968fcece1caa305d8235557b0456012103335134d7414e1d1a154600b124a96f5ef2c6ca21434d2622469a96bd5262fd5600000000
     2genosse@local:~$ bitcoin-cli -testnet decoderawtransaction 02000000000101c79161617adc1cad419254fd0194193dd6786a7faf1f65df9b3a369e8e600a3c0000000000ffffffff017b134c000000000016001443aac20a116e09ea4f7914be1c55e4c17aa600b70248304502210087116858148c7f4e33c05881103444ae5d67b1b5fd922ca18c00127c9683c4a502206ede2a47953942365a01fb772d2644dcfa59968fcece1caa305d8235557b0456012103335134d7414e1d1a154600b124a96f5ef2c6ca21434d2622469a96bd5262fd5600000000
     3{
     4  "txid": "22519827b1dc985ed4d0115e58c3f327a60e44015c8499ff3c5bc7fe5a8ce3f0",
     5  "hash": "22519827b1dc985ed4d0115e58c3f327a60e44015c8499ff3c5bc7fe5a8ce3f0",
     6  "version": 2,
     7  "size": 192,
     8  "vsize": 192,
     9  "locktime": 0,
    10  "vin": [
    11  ],
    12  "vout": [
    13    {
    14      "value": 20796716866.05686529,
    15      "n": 0,
    16      "scriptPubKey": {
    17        "asm": "9254fd0194193dd6786a7faf1f65df9b3a369e8e600a3c0000000000ffffffff017b134c000000000016001443aac20a116e09ea4f7914be1c55e4c17aa600b702 304502210087116858148c7f4e33c05881103444ae5d67b1b5fd922ca18c00127c9683c4a502206ede2a47953942365a01fb772d2644dcfa59968fcece1caa305d8235557b045601 03335134d7414e1d1a154600b124a96f5ef2c6ca21434d2622469a96bd5262fd56",
    18        "hex": "419254fd0194193dd6786a7faf1f65df9b3a369e8e600a3c0000000000ffffffff017b134c000000000016001443aac20a116e09ea4f7914be1c55e4c17aa600b70248304502210087116858148c7f4e33c05881103444ae5d67b1b5fd922ca18c00127c9683c4a502206ede2a47953942365a01fb772d2644dcfa59968fcece1caa305d8235557b0456012103335134d7414e1d1a154600b124a96f5ef2c6ca21434d2622469a96bd5262fd56",
    19        "type": "nonstandard"
    20      }
    21    }
    22  ]
    23}
    
     0genosse@local:~$ bitcoin-cli -testnet getrawtransaction d259c4573cffb992df4c864c8fb172fb934e83ce3fa58e5fabb16bccfc59e273
     102000000000101d3171d300fefb4ada940a7e6b4411391909908838db0532db8cd90b36367407a0000000000ffffffff0106ea4b000000000016001435600b44f82d414e451a4d5ed2e23e7f38a0de3502483045022100da76f404dfe7d29e8283f715509a2bbec14a4fbb13603d374f760c1da6b67705022017c15cad3e1420369e6734bbdc158f58cf07f4e4afe4f854ce9a11dfaefe6d00012102192a09100e62eefcf1b6b6ed4d6c81e3b95d29f6c2f8cb39841a8158e41d0d6600000000
     2genosse@local:~$ raw=02000000000101d3171d300fefb4ada940a7e6b4411391909908838db0532db8cd90b36367407a0000000000ffffffff0106ea4b000000000016001435600b44f82d414e451a4d5ed2e23e7f38a0de3502483045022100da76f404dfe7d29e8283f715509a2bbec14a4fbb13603d374f760c1da6b67705022017c15cad3e1420369e6734bbdc158f58cf07f4e4afe4f854ce9a11dfaefe6d00012102192a09100e62eefcf1b6b6ed4d6c81e3b95d29f6c2f8cb39841a8158e41d0d6600000000
     3genosse@local:~$ bitcoin-cli -testnet decoderawtransaction $raw
     4{
     5  "txid": "a4d7ce0d0df329bc697a85c9f1108a4466d765a123b8a35e4ba835fd57346649",
     6  "hash": "a4d7ce0d0df329bc697a85c9f1108a4466d765a123b8a35e4ba835fd57346649",
     7  "version": 2,
     8  "size": 192,
     9  "vsize": 192,
    10  "locktime": 0,
    11  "vin": [
    12  ],
    13  "vout": [
    14    {
    15      "value": -54090879281.27728895,
    16      "n": 0,
    17      "scriptPubKey": {
    18        "asm": "OP_HASH160 a7e6b4411391909908838db0532db8cd90b36367407a0000000000ffffffff0106ea4b000000000016001435600b44f82d414e451a4d5ed2e23e7f38a0de3502 3045022100da76f404dfe7d29e8283f715509a2bbec14a4fbb13603d374f760c1da6b67705022017c15cad3e1420369e6734bbdc158f58cf07f4e4afe4f854ce9a11dfaefe6d0001 02192a09100e62eefcf1b6b6ed4d6c81e3b95d29f6c2f8cb39841a8158e41d0d66",
    19        "hex": "a940a7e6b4411391909908838db0532db8cd90b36367407a0000000000ffffffff0106ea4b000000000016001435600b44f82d414e451a4d5ed2e23e7f38a0de3502483045022100da76f404dfe7d29e8283f715509a2bbec14a4fbb13603d374f760c1da6b67705022017c15cad3e1420369e6734bbdc158f58cf07f4e4afe4f854ce9a11dfaefe6d00012102192a09100e62eefcf1b6b6ed4d6c81e3b95d29f6c2f8cb39841a8158e41d0d66",
    20        "type": "nonstandard"
    21      }
    22    }
    23  ]
    24}
    
  2. mishabunte commented at 5:57 pm on April 15, 2018: none

    Last version of bitcoin core does not work neither, there are steps to reproduce with current release (Bitcoin Core RPC client version v0.16.99.0-e76acf3):

    0git clone ...
    1rebuild ...
    2rm -rf ~/.bitcoin/testnet3 # remove database 
    3bitcoind -txindex -testnet # reload blockchain 
    
     0genosse@local:~$ /usr/local/bin/bitcoin-cli getrawtransaction f0a1d41cb2d1cea36b334c77f90f1a88b0f01332fffefaac3be9bb77f5b5f5b6
     102000000000101c79161617adc1cad419254fd0194193dd6786a7faf1f65df9b3a369e8e600a3c0000000000ffffffff017b134c000000000016001443aac20a116e09ea4f7914be1c55e4c17aa600b70248304502210087116858148c7f4e33c05881103444ae5d67b1b5fd922ca18c00127c9683c4a502206ede2a47953942365a01fb772d2644dcfa59968fcece1caa305d8235557b0456012103335134d7414e1d1a154600b124a96f5ef2c6ca21434d2622469a96bd5262fd5600000000
     2genosse@local:~$ /usr/local/bin/bitcoin-cli decoderawtransaction 02000000000101c79161617adc1cad419254fd0194193dd6786a7faf1f65df9b3a369e8e600a3c0000000000ffffffff017b134c000000000016001443aac20a116e09ea4f7914be1c55e4c17aa600b70248304502210087116858148c7f4e33c05881103444ae5d67b1b5fd922ca18c00127c9683c4a502206ede2a47953942365a01fb772d2644dcfa59968fcece1caa305d8235557b0456012103335134d7414e1d1a154600b124a96f5ef2c6ca21434d2622469a96bd5262fd5600000000
     3{
     4  "txid": "22519827b1dc985ed4d0115e58c3f327a60e44015c8499ff3c5bc7fe5a8ce3f0",
     5  "hash": "22519827b1dc985ed4d0115e58c3f327a60e44015c8499ff3c5bc7fe5a8ce3f0",
     6  "version": 2,
     7  "size": 192,
     8  "vsize": 192,
     9  "locktime": 0,
    10  "vin": [
    11  ],
    12  "vout": [
    13    {
    14      "value": 20796716866.05686529,
    15      "n": 0,
    16      "scriptPubKey": {
    17        "asm": "9254fd0194193dd6786a7faf1f65df9b3a369e8e600a3c0000000000ffffffff017b134c000000000016001443aac20a116e09ea4f7914be1c55e4c17aa600b702 304502210087116858148c7f4e33c05881103444ae5d67b1b5fd922ca18c00127c9683c4a502206ede2a47953942365a01fb772d2644dcfa59968fcece1caa305d8235557b045601 03335134d7414e1d1a154600b124a96f5ef2c6ca21434d2622469a96bd5262fd56",
    18        "hex": "419254fd0194193dd6786a7faf1f65df9b3a369e8e600a3c0000000000ffffffff017b134c000000000016001443aac20a116e09ea4f7914be1c55e4c17aa600b70248304502210087116858148c7f4e33c05881103444ae5d67b1b5fd922ca18c00127c9683c4a502206ede2a47953942365a01fb772d2644dcfa59968fcece1caa305d8235557b0456012103335134d7414e1d1a154600b124a96f5ef2c6ca21434d2622469a96bd5262fd56",
    19        "type": "nonstandard"
    20      }
    21    }
    22  ]
    23}
    
  3. MarcoFalke added the label RPC/REST/ZMQ on Apr 15, 2018
  4. MarcoFalke commented at 6:19 pm on April 15, 2018: member

    This is a transaction that includes witness data. Does it help if you explicitly specify iswitness=true?

    0decoderawtransaction 02000000000101c79161617adc1cad419254fd0194193dd6786a7faf1f65df9b3a369e8e600a3c0000000000ffffffff017b134c000000000016001443aac20a116e09ea4f7914be1c55e4c17aa600b70248304502210087116858148c7f4e33c05881103444ae5d67b1b5fd922ca18c00127c9683c4a502206ede2a47953942365a01fb772d2644dcfa59968fcece1caa305d8235557b0456012103335134d7414e1d1a154600b124a96f5ef2c6ca21434d2622469a96bd5262fd5600000000 true
    
  5. sipa commented at 6:23 pm on April 15, 2018: member

    There are a few strange things about this:

    • The txid and hash both list the transaction’s (correct) wtxid. For hash this is correct behaviour; for txid it isn’t.
    • The decoded output does not include the inputs (which sounds like it fails to detect it as a witness tx).
  6. fivepiece commented at 9:02 pm on April 15, 2018: contributor

    The transaction has correct encoding in both witness and non-witness forms because the prev-txid makes it all align

    0              size of
    1              first "item"
    2              pushed
    3                VV
    4C79161617ADC1CAD419254FD0194193DD6786A7FAF1F65DF9B3A369E8E600A3C
    5              ^^
    6            size of
    7            perceived
    8            scriptpubkey
    

    The remainder is exactly the nlocktime field

  7. mishabunte commented at 7:15 am on April 16, 2018: none

    Does it help if you explicitly specify iswitness=true?

    Yes, It helps. So should I specify iswitness=true every time I call decoderawtransaction?

  8. cuiweixie commented at 9:52 am on April 28, 2018: none
    https://github.com/btcsuite/btcd using the golang version of bitcoin, it’s ok! BTW, how can we know whether if the tx has witness data?
  9. vizeet commented at 9:23 am on May 11, 2018: none
    I think decoderawtransaction should be aware if tx contains witness data. I think it is better to remove iswitness option altogether. It will make the RPC more consistent as segwit is already active and large percentage of tx contain witness data.
  10. mishabunte commented at 3:03 pm on May 14, 2018: none
    ‘iswitness’ option looks useless to me, I have to specify iswitness=true every time I call decoderawtranscation, agreed with @vizeet
  11. achow101 commented at 3:10 pm on May 14, 2018: member

    I think decoderawtransaction should be aware if tx contains witness data.

    decoderawtransaction attempts to do that. However it is difficult to be aware of whether a transaction includes witness data because decoderawtransaction also needs to handle the case of an un-funded transaction so 0-input 1-output transactions are acceptable. Unfortunately witness transactions are signaled by having 0 inputs and 1 output to a traditional parser, and when we see these from other peers, we know that it must be witness, but the same assumption cannot be made for decoderawtransaction.

    decoderawtransaction does in fact do some detection. There are some heuristics that it checks for, and it can properly identify many witness transactions when in the past were decoded as non-witness transactions. However some transactions still do slip through the heuristics which is the problem that you are experiencing.

  12. kushal256 commented at 8:56 pm on July 25, 2018: none

    Is it ok to unconditionally set iswitness=true? This appears to work for both segwit and non-segwit txns, so it appears to function better than the default (without specifying iswitness flag).

    Can someone please confirm or deny?

  13. sipa commented at 9:00 pm on July 25, 2018: member

    @kushal256 No. If you specify iswitness=true, and there are two possible interpretations, it will prefer the one which has a witness. If you specify iswitness=false, only a witness-free version will be tried. If you don’t specify anything, heuristics will be used to determine which is the most reasonable interpretation.

    You can specify iswitness=true if you know the transaction has at least one input.

  14. kushal256 commented at 3:43 am on July 26, 2018: none

    Thanks @sipa for your feedback, much appreciated!

    So what is the recommended logic for 0 input coinbase txns, if it’s not safe to unconditionally set isWitness=true?

  15. sipa commented at 4:58 am on July 26, 2018: member

    For any real, fully valid, or on-chain transaction you can you use iswitness=true, even coinbase transaction.

    iswitness=false or not set is purely for the case of decoding partial not-fully-signed transactions.

  16. kushal256 commented at 6:19 am on July 26, 2018: none
    Whew, big relief! Thanks, that makes it clear.
  17. meshcollider closed this on Jun 18, 2019

  18. meshcollider referenced this in commit 22b6c4ed75 on Jun 18, 2019
  19. sidhujag referenced this in commit 6832c16b75 on Jun 19, 2019
  20. vijaydasmp referenced this in commit 090d778a0c on Dec 10, 2021
  21. vijaydasmp referenced this in commit 0b8a40a785 on Dec 10, 2021
  22. vijaydasmp referenced this in commit 5177a86893 on Dec 11, 2021
  23. vijaydasmp referenced this in commit 6e1eadf146 on Dec 11, 2021
  24. vijaydasmp referenced this in commit d0de12e763 on Dec 11, 2021
  25. vijaydasmp referenced this in commit 4304d6ae25 on Dec 11, 2021
  26. vijaydasmp referenced this in commit 17e2687ee6 on Dec 13, 2021
  27. vijaydasmp referenced this in commit 20d674f397 on Dec 14, 2021
  28. vijaydasmp referenced this in commit 8a20aa7f42 on Dec 14, 2021
  29. MarcoFalke locked this on Dec 16, 2021
  30. knst referenced this in commit a1dd3bf75b on Feb 2, 2023
  31. knst referenced this in commit 676137b99a on Feb 2, 2023
  32. knst referenced this in commit f831a31e63 on Feb 2, 2023
  33. knst referenced this in commit 7611c789da on Feb 2, 2023
  34. knst referenced this in commit 3022c426ea on Feb 2, 2023
  35. knst referenced this in commit 49fe2a46f3 on Feb 2, 2023
  36. knst referenced this in commit 3953b95c54 on Feb 10, 2023
  37. knst referenced this in commit e504094558 on Feb 10, 2023
  38. knst referenced this in commit 7b24a5fe49 on Feb 10, 2023
  39. UdjinM6 referenced this in commit faa6f770d9 on Feb 10, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 09:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me