getrawtransaction(verbose) and decoderawtransaction of a same transaction returns different txid #15872

issue ChefJ openend this issue on April 23, 2019
  1. ChefJ commented at 4:09 am on April 23, 2019: none

    For transaction f4dedd64c9841d53bbda8beeda52235ec986f1400606812d9c033ac34105532c, the call of [getrawtransaction(verbose)] and [getrawtransaction(hex) + decoderawtransaction] has totally different result,including txid.

    Step of reproducing the issue:

    • Use getrawtransaction(hex) + decoderawtransaction
    0curl --user yourAuth --data-binary '{"jsonrpc": "1.0","id":"curltest","method":"getrawtransaction", "params": ["f4dedd64c9841d53bbda8beeda52235ec986f1400606812d9c033ac34105532c"] }' -H 'content-type: text/plain;' http://yourEndPoint
    

    Returns:

    0{
    1	"result": "0100000000010115a16270d3ee7ccc58a0757c1d8e1763790f223d4e4c3823948fb3dfdf9865180100000000ffffffff023f3256000000000017a9142915a7db6c6df171fd0436c7cec0042195dad01c8738ee4647000000001600140aad95e932ba045c2daf31a04c36683d39efe91002473044022002537539ac9586fdd8b5947fa0a47dc002ebe57502608433e103efe2740f93d4022023b1ade7bdf0f002a8fdc4ec6d534588d2132ab88850ac426ea413b4adb465260121031ef964af6923a2111e4916afcc87c73a8980322cc761dd3648714dfda99e72c400000000",
    2	"error": null,
    3	"id": null
    4}
    

    Decode with decoderawtransaction:

    0curl --user yourAuth  --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "decoderawtransaction", "params": ["0100000000010115a16270d3ee7ccc58a0757c1d8e1763790f223d4e4c3823948fb3dfdf9865180100000000ffffffff023f3256000000000017a9142915a7db6c6df171fd0436c7cec0042195dad01c8738ee4647000000001600140aad95e932ba045c2daf31a04c36683d39efe91002473044022002537539ac9586fdd8b5947fa0a47dc002ebe57502608433e103efe2740f93d4022023b1ade7bdf0f002a8fdc4ec6d534588d2132ab88850ac426ea413b4adb465260121031ef964af6923a2111e4916afcc87c73a8980322cc761dd3648714dfda99e72c400000000"] }' -H 'content-type: text/plain;' http://yourEndPoint
    

    Returns:

     0{
     1	"result": {
     2		"txid": "0b637b18840d8fc978a657a3422df3c246c86e4c4046d90e63bf0f86b179b403",
     3		"hash": "0b637b18840d8fc978a657a3422df3c246c86e4c4046d90e63bf0f86b179b403",
     4		"version": 1,
     5		"size": 223,
     6		"vsize": 223,
     7		"locktime": 0,
     8		"vin": [
     9
    10		],
    11		"vout": [
    12			{
    13				"value": 90023651848.04721921,
    14				"n": 0,
    15				"scriptPubKey": {
    16					"asm": "8 OP_GREATERTHAN OP_DROP OP_SWAP 8e1763790f223d4e4c3823948fb3dfdf9865180100000000ffffffff02 3256000000000017a9142915a7db6c6df171fd0436c7cec0042195dad01c8738ee4647000000001600140aad95e932ba045c2daf31a04c36683d39efe91002 3044022002537539ac9586fdd8b5947fa0a47dc002ebe57502608433e103efe2740f93d4022023b1ade7bdf0f002a8fdc4ec6d534588d2132ab88850ac426ea413b4adb4652601 031ef964af6923a2111e4916afcc87c73a8980322cc761dd3648714dfda99e72c4",
    17					"hex": "58a0757c1d8e1763790f223d4e4c3823948fb3dfdf9865180100000000ffffffff023f3256000000000017a9142915a7db6c6df171fd0436c7cec0042195dad01c8738ee4647000000001600140aad95e932ba045c2daf31a04c36683d39efe91002473044022002537539ac9586fdd8b5947fa0a47dc002ebe57502608433e103efe2740f93d4022023b1ade7bdf0f002a8fdc4ec6d534588d2132ab88850ac426ea413b4adb465260121031ef964af6923a2111e4916afcc87c73a8980322cc761dd3648714dfda99e72c4",
    18					"type": "nonstandard"
    19				}
    20			}
    21		]
    22	},
    23	"error": null,
    24	"id": null
    25}
    

    None of the “txid” or “hash” equals the hash I gave it at first(f4dedd64c9841d53bbda8beeda52235ec986f1400606812d9c033ac34105532c) .

    • Use getrawtransaction(verbose):
    0curl --user yourAuth --data-binary '{"jsonrpc": "1.0","id":"curltest","method":"getrawtransaction", "params": ["f4dedd64c9841d53bbda8beeda52235ec986f1400606812d9c033ac34105532c",true] }' -H 'content-type: text/plain;' http://yourEndPoint
    

    This returns :

     0{
     1	"result": {
     2		"txid": "f4dedd64c9841d53bbda8beeda52235ec986f1400606812d9c033ac34105532c",
     3		"hash": "0b637b18840d8fc978a657a3422df3c246c86e4c4046d90e63bf0f86b179b403",
     4		"version": 1,
     5		"size": 223,
     6		"vsize": 142,
     7		"locktime": 0,
     8		"vin": [
     9			{
    10				"txid": "186598dfdfb38f9423384c4e3d220f7963178e1d7c75a058cc7ceed37062a115",
    11				"vout": 1,
    12				"scriptSig": {
    13					"asm": "",
    14					"hex": ""
    15				},
    16				"txinwitness": [
    17					"3044022002537539ac9586fdd8b5947fa0a47dc002ebe57502608433e103efe2740f93d4022023b1ade7bdf0f002a8fdc4ec6d534588d2132ab88850ac426ea413b4adb4652601",
    18					"031ef964af6923a2111e4916afcc87c73a8980322cc761dd3648714dfda99e72c4"
    19				],
    20				"sequence": 4294967295
    21			}
    22		],
    23		"vout": [
    24			{
    25				"value": 0.05648959,
    26				"n": 0,
    27				"scriptPubKey": {
    28					"asm": "OP_HASH160 2915a7db6c6df171fd0436c7cec0042195dad01c OP_EQUAL",
    29					"hex": "a9142915a7db6c6df171fd0436c7cec0042195dad01c87",
    30					"reqSigs": 1,
    31					"type": "scripthash",
    32					"addresses": [
    33						"35SFa5Aev3bjP7gfvfY959GSdWUrSdzoJn"
    34					]
    35				}
    36			},
    37			{
    38				"value": 11.95830840,
    39				"n": 1,
    40				"scriptPubKey": {
    41					"asm": "0 0aad95e932ba045c2daf31a04c36683d39efe910",
    42					"hex": "00140aad95e932ba045c2daf31a04c36683d39efe910",
    43					"reqSigs": 1,
    44					"type": "witness_v0_keyhash",
    45					"addresses": [
    46						"bc1qp2ket6fjhgz9ctd0xxsycdng85u7l6gs2x4dgh"
    47					]
    48				}
    49			}
    50		],
    51		"hex": "0100000000010115a16270d3ee7ccc58a0757c1d8e1763790f223d4e4c3823948fb3dfdf9865180100000000ffffffff023f3256000000000017a9142915a7db6c6df171fd0436c7cec0042195dad01c8738ee4647000000001600140aad95e932ba045c2daf31a04c36683d39efe91002473044022002537539ac9586fdd8b5947fa0a47dc002ebe57502608433e103efe2740f93d4022023b1ade7bdf0f002a8fdc4ec6d534588d2132ab88850ac426ea413b4adb465260121031ef964af6923a2111e4916afcc87c73a8980322cc761dd3648714dfda99e72c400000000",
    52		"blockhash": "00000000000000000011ca3164ee629216de2e5dae09ffb099815319f6e35a71",
    53		"confirmations": 1459,
    54		"time": 1555100160,
    55		"blocktime": 1555100160
    56	},
    57	"error": null,
    58	"id": null
    59}
    

    which has the right transaction Id(txid).

    They were supposed to return the same transaction,at least returns the same txid. Which result is more correct?

    My node info:

     0{
     1  "result": {
     2    "version": 170100,
     3    "subversion": "/Satoshi:0.17.1/",
     4    "protocolversion": 70015,
     5    "localservices": "000000000000040d",
     6    "localrelay": true,
     7    "timeoffset": 10,
     8    "networkactive": true,
     9    "connections": 8,
    10    "networks": [
    11      {
    12        "name": "ipv4",
    13        "limited": false,
    14        "reachable": true,
    15        "proxy": "",
    16        "proxy_randomize_credentials": false
    17      },
    18      {
    19        "name": "ipv6",
    20        "limited": false,
    21        "reachable": true,
    22        "proxy": "",
    23        "proxy_randomize_credentials": false
    24      },
    25      {
    26        "name": "onion",
    27        "limited": true,
    28        "reachable": false,
    29        "proxy": "",
    30        "proxy_randomize_credentials": false
    31      }
    32    ],
    33    "relayfee": 0.00001000,
    34    "incrementalfee": 0.00001000,
    35    "localaddresses": [
    36      
    37    ],
    38    "warnings": ""
    39  },
    40  "error": null,
    41  "id": "curltest"
    42}
    
  2. achow101 commented at 4:49 am on April 23, 2019: member

    This is (unfortunately) expected behavior. getrawtransaction is correct, decoderawtransaction is incorrect.

    This issue occurs because the transaction is a segwit transaction which can be mistaken for a 0 input transaction by decoderawtransaction which needs to decode 0 input transactions. The heuristic used to distinguish between 0 input and segwit transactions that decoderawtransaction uses is not foolproof and there are still some false positives, such as your transaction. getrawtransaction is not confused because it is fetching the details of a transaction that exists on the network and thus cannot be a 0 input transaction. decoderawtransaction gives the wrong txid because it is including the segwit data in the txid when it shouldn’t.

    decoderawtransaction has an optional parameter iswitness which is used to indicate whether it should consider the transaction to be a segwit transaction and decode it as such. You should get the correct result (the same as getrawtransaction) if you set that to true (i.e. bitcoin-cli decoderawtransaction <raw tx> true).

  3. ChefJ commented at 5:14 am on April 23, 2019: none
    @achow101 Thanks for your explanation,my problem’s solved.
  4. fanquake closed this on Apr 23, 2019

  5. jnewbery commented at 3:04 pm on April 23, 2019: member
    This would make a useful stack exchange Question/Answer!
  6. meshcollider referenced this in commit 22b6c4ed75 on Jun 18, 2019
  7. sidhujag referenced this in commit 6832c16b75 on Jun 19, 2019
  8. vijaydasmp referenced this in commit 090d778a0c on Dec 10, 2021
  9. vijaydasmp referenced this in commit 0b8a40a785 on Dec 10, 2021
  10. vijaydasmp referenced this in commit 5177a86893 on Dec 11, 2021
  11. vijaydasmp referenced this in commit 6e1eadf146 on Dec 11, 2021
  12. vijaydasmp referenced this in commit d0de12e763 on Dec 11, 2021
  13. vijaydasmp referenced this in commit 4304d6ae25 on Dec 11, 2021
  14. vijaydasmp referenced this in commit 17e2687ee6 on Dec 13, 2021
  15. vijaydasmp referenced this in commit 20d674f397 on Dec 14, 2021
  16. vijaydasmp referenced this in commit 8a20aa7f42 on Dec 14, 2021
  17. DrahtBot locked this on Dec 16, 2021
  18. knst referenced this in commit a1dd3bf75b on Feb 2, 2023
  19. knst referenced this in commit 676137b99a on Feb 2, 2023
  20. knst referenced this in commit f831a31e63 on Feb 2, 2023
  21. knst referenced this in commit 7611c789da on Feb 2, 2023
  22. knst referenced this in commit 3022c426ea on Feb 2, 2023
  23. knst referenced this in commit 49fe2a46f3 on Feb 2, 2023
  24. knst referenced this in commit 3953b95c54 on Feb 10, 2023
  25. knst referenced this in commit e504094558 on Feb 10, 2023
  26. knst referenced this in commit 7b24a5fe49 on Feb 10, 2023
  27. 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