-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Remove manual byte editing in wallet_tx_clone func test #15397
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
| # Use a different signature hash type to sign. This creates an equivalent but malleated clone. | ||
| # Don't send the clone anywhere yet | ||
| tx1_clone = self.nodes[0].signrawtransactionwithwallet(clone_raw, None, "ALL|ANYONECANPAY") | ||
| tx1_clone = self.nodes[0].signrawtransactionwithwallet(clone_tx.serialize().hex(), None, "ALL|ANYONECANPAY") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assigned 0.19.0, because this is python3.5 only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM, I like the syntax way more. So should I ping once 0.18 is branched?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remind me #14954
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already broken in master, so just going to merge this as well 🤷♀️
$ git grep -l '\.hex()' test/
test/functional/mining_basic.py
test/functional/test_framework/wallet_util.py
test/functional/wallet_txn_clone.pyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah at least partially my bad 🥇
| clone_tx = CTransaction() | ||
| clone_tx.deserialize(io.BytesIO(bytes.fromhex(clone_raw))) | ||
| if (rawtx1["vout"][0]["value"] == 40 and clone_tx.vout[0].nValue != 40*COIN or rawtx1["vout"][0]["value"] != 40 and clone_tx.vout[0].nValue == 40*COIN): | ||
| (clone_tx.vout[0], clone_tx.vout[1]) = (clone_tx.vout[1], clone_tx.vout[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice swap
| clone_tx = CTransaction() | ||
| clone_tx.deserialize(io.BytesIO(bytes.fromhex(clone_raw))) | ||
| if (rawtx1["vout"][0]["value"] == 40 and clone_tx.vout[0].nValue != 40*COIN or rawtx1["vout"][0]["value"] != 40 and clone_tx.vout[0].nValue == 40*COIN): | ||
| (clone_tx.vout[0], clone_tx.vout[1]) = (clone_tx.vout[1], clone_tx.vout[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Parantheses redundant :-)
| clone_raw = clone_raw[:pos0] + output1 + output0 + clone_raw[pos0 + 2 * output_len:] | ||
| clone_tx = CTransaction() | ||
| clone_tx.deserialize(io.BytesIO(bytes.fromhex(clone_raw))) | ||
| if (rawtx1["vout"][0]["value"] == 40 and clone_tx.vout[0].nValue != 40*COIN or rawtx1["vout"][0]["value"] != 40 and clone_tx.vout[0].nValue == 40*COIN): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Parantheses redundant :-)
|
Oh yes. Thanks for doing this. |
6aaa0ab Remove manual byte editing in wallet_tx_clone func test (Gregory Sanders) Pull request description: Adapted from @stevenroose Tree-SHA512: 87f251579e347f870bd30fc57b0c130f00914a3dc78799826384eb049b91d49f2525d55899bf525997e23cc976ca7d10e6b56b23f7358acec307368d48a6f6f1
1a062b8 tests: remove byte.hex() to keep compatibility (Akio Nakamura) Pull request description: Use ```test_framework.util.bytes_to_hex_str()``` instead of ```bytes.hex()``` that new in Python 3.5 to support minimum version of Python(test). ```test/functional/test_framework/wallet_util.py``` is also reported to have '\.hex()' in bitcoin#15397, but it does not matter because it calls CScript.hex() defined in wallet_util.py. Tree-SHA512: 1019212e965f0848d235fab4da11959dffa42e8adfcd41216c10795cfc63c804b5deb5a3317f25d29940b9dcf088ab76fe3fa80d2679dc19f5f482dc5bde3283
Summary: Replace byte editing in a raw hexadecimal transaction by a more readable element swap in a `CTransaction.vout` list This is a backport of Core [[bitcoin/bitcoin#15397 | PR15397]] Test Plan: `ninja && test/functional/test_runner.py wallet_txn*` Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D8362
…nc test 6aaa0ab Remove manual byte editing in wallet_tx_clone func test (Gregory Sanders) Pull request description: Adapted from @stevenroose Tree-SHA512: 87f251579e347f870bd30fc57b0c130f00914a3dc78799826384eb049b91d49f2525d55899bf525997e23cc976ca7d10e6b56b23f7358acec307368d48a6f6f1
Adapted from @stevenroose