-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Add bitcoin-tx JSON tests #8829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Awesome, thanks! |
utACK 54e5d7c |
54e5d7c Add bitcoin-tx JSON tests (jnewbery)
ups, merged in the middle of my testing :-) postmerge ACK 54e5d7c |
Question: Was txcreate2.json supposed to be empty? I'm assuming some test data was supposed to be in it. :) |
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:
I 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:
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. |
Zero-value outputs are perfectly valid according to consensus rules.
|
ah, ok. Thanks. Then the fix is in bitcoin-tx to properly output zero-value, empty-script outputs. |
Good to see that we're finding bugs in bitcoin-tx by adding tests :) |
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 |
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.
|
Github-Pull: bitcoin#8829 Rebased-From: 54e5d7c
This was backported in #8832, removing tag |
54e5d7c Add bitcoin-tx JSON tests (jnewbery)
Github-Pull: bitcoin#8829 Rebased-From: 54e5d7c
54e5d7c Add bitcoin-tx JSON tests (jnewbery)
bitcoin-util-test.py backports Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#8829 - bitcoin/bitcoin#8830 - bitcoin/bitcoin#8836 - bitcoin/bitcoin#8881 - bitcoin/bitcoin#9032 - bitcoin/bitcoin#9023 - bitcoin/bitcoin#9069 - bitcoin/bitcoin#9945
This PR adds new test cases to test bitcoin-tx JSON output, as suggested by @sipa in #8817 .