This PR adds new test cases to test bitcoin-tx JSON output, as suggested by @sipa in #8817 .
Add bitcoin-tx JSON tests #8829
pull jnewbery wants to merge 1 commits into bitcoin:master from jnewbery:test-bitcoin-tx-json changing 12 files +997 −1-
jnewbery commented at 5:39 PM on September 28, 2016: member
-
Add bitcoin-tx JSON tests 54e5d7c1b8
- MarcoFalke added the label Tests on Sep 28, 2016
-
laanwj commented at 6:16 AM on September 29, 2016: member
-
MarcoFalke commented at 8:43 AM on September 29, 2016: member
utACK 54e5d7c1b81e1b76f5789abfa2cb1f5963cd9d72
- MarcoFalke merged this on Sep 29, 2016
- MarcoFalke closed this on Sep 29, 2016
- MarcoFalke referenced this in commit 8ca69a2a88 on Sep 29, 2016
- MarcoFalke added the label Needs backport on Sep 29, 2016
- MarcoFalke added this to the milestone 0.13.1 on Sep 29, 2016
-
paveljanik commented at 9:00 AM on September 29, 2016: contributor
ups, merged in the middle of my testing :-)
postmerge ACK https://github.com/bitcoin/bitcoin/commit/54e5d7c1b81e1b76f5789abfa2cb1f5963cd9d72
-
droark commented at 11:32 AM on September 29, 2016: contributor
Question: Was txcreate2.json supposed to be empty? I'm assuming some test data was supposed to be in it. :)
-
jnewbery commented at 12:35 PM on September 29, 2016: member
Interesting. The txcreate2 test is attempting to create a transaction with a single pay-to-script output for zero satoshi. When outputting as json, bitcoin-tx returns the empty string. When outputting as hex, it returns 01000000000100000000000000000000000000, ie:
version |number in|number out|out1 amount |out1 script length|nlocktime 01000000 00 01 0000000000000000 00 00000000I think that's garbage and bitcoin-tx should reject any attempt to add an output with zero satoshi. I'll open a PR to fix that.
Interestingly, bitcoin-tx does output a json object if I try to create a zero-value transaction output to a non-empty script:
$ bitcoin-tx -json -create outscript=0:"OP_DROP" { "txid": "f0851b68202f736b792649cfc960259c2374badcb644ab20cac726b5f72f61c9", "version": 1, "locktime": 0, "vin": [ ], "vout": [ { "value": 0.00, "n": 0, "scriptPubKey": { "asm": "OP_DROP", "hex": "75", "type": "nonstandard" } } ], "hex": "0100000000010000000000000000017500000000" }txcreate2 is also the only test case that tests creating a pay-to-script, so we should add a new test case that tests adding a valid pay-to-script output.
- jnewbery deleted the branch on Sep 29, 2016
-
sipa commented at 12:39 PM on September 29, 2016: member
Zero-value outputs are perfectly valid according to consensus rules.
-
jnewbery commented at 12:45 PM on September 29, 2016: member
ah, ok. Thanks. Then the fix is in bitcoin-tx to properly output zero-value, empty-script outputs.
-
laanwj commented at 12:48 PM on September 29, 2016: member
Good to see that we're finding bugs in bitcoin-tx by adding tests :)
-
jnewbery commented at 1:02 PM on September 29, 2016: member
I've mischaracterised the problem here. bitcoin-tx is outputting the transaction correctly in hex and json. However, when I try to pipe that same hex transaction back into bitcoin-tx, it fails with
error: invalid transaction encoding. -
sipa commented at 1:09 PM on September 29, 2016: member
Ah, that seems to be due to the segwit ambiguity for 0-input transactions. IIRC, DecodeTransaction in core_io.h has a boolean parameter for attempting to decode partial transactions. It should be set to true in calls from bitcoin-tx.
-
jnewbery commented at 2:29 PM on September 29, 2016: member
- MarcoFalke referenced this in commit 2a8bca465d on Oct 3, 2016
- MarcoFalke removed the label Needs backport on Oct 13, 2016
- codablock referenced this in commit 1eba1e1962 on Sep 19, 2017
- codablock referenced this in commit 963f6a6f3a on Jan 12, 2018
- lateminer referenced this in commit c7f6a2e815 on Nov 10, 2018
- andvgal referenced this in commit c13d3c3fa1 on Jan 6, 2019
- zkbot referenced this in commit 44f5ef7c9d on Nov 9, 2020
- zkbot referenced this in commit bd5ff7c889 on Nov 9, 2020
- DrahtBot locked this on Sep 8, 2021
Milestone
0.13.1