Skip to content
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

Remove manual byte editing in wallet_tx_clone func test #15397

Merged
merged 1 commit into from Feb 18, 2019

Conversation

@instagibbs
Copy link
Member

@instagibbs instagibbs commented Feb 13, 2019

Adapted from @stevenroose

@stevenroose
Copy link
Contributor

@stevenroose stevenroose commented Feb 13, 2019

@MarcoFalke MarcoFalke added this to the 0.19.0 milestone Feb 13, 2019

# 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")
Copy link
Member

@MarcoFalke MarcoFalke Feb 13, 2019

Assigned 0.19.0, because this is python3.5 only

Copy link
Member Author

@instagibbs instagibbs Feb 13, 2019

SGTM, I like the syntax way more. So should I ping once 0.18 is branched?

Copy link
Member

@MarcoFalke MarcoFalke Feb 13, 2019

Remind me #14954

Copy link
Member

@MarcoFalke MarcoFalke Feb 18, 2019

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.py

Copy link
Member Author

@instagibbs instagibbs Feb 18, 2019

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])
Copy link
Member

@MarcoFalke MarcoFalke Feb 13, 2019

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])
Copy link
Contributor

@practicalswift practicalswift Feb 13, 2019

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):
Copy link
Contributor

@practicalswift practicalswift Feb 13, 2019

Nit: Parantheses redundant :-)

@jonasschnelli
Copy link
Member

@jonasschnelli jonasschnelli commented Feb 14, 2019

Oh yes. Thanks for doing this.
utACK 6aaa0ab once 0.18 is branched off.

@MarcoFalke MarcoFalke merged commit 6aaa0ab into bitcoin:master Feb 18, 2019
2 checks passed
MarcoFalke added a commit that referenced this issue Feb 18, 2019
6aaa0ab Remove manual byte editing in wallet_tx_clone func test (Gregory Sanders)

Pull request description:

  Adapted from @stevenroose

Tree-SHA512: 87f251579e347f870bd30fc57b0c130f00914a3dc78799826384eb049b91d49f2525d55899bf525997e23cc976ca7d10e6b56b23f7358acec307368d48a6f6f1
MarcoFalke added a commit to MarcoFalke/bitcoin-core that referenced this issue Feb 20, 2019
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
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue Nov 11, 2020
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
vijaydasmp added a commit to vijaydasmp/dash that referenced this issue Sep 5, 2021
…nc test

6aaa0ab Remove manual byte editing in wallet_tx_clone func test (Gregory Sanders)

Pull request description:

  Adapted from @stevenroose

Tree-SHA512: 87f251579e347f870bd30fc57b0c130f00914a3dc78799826384eb049b91d49f2525d55899bf525997e23cc976ca7d10e6b56b23f7358acec307368d48a6f6f1
Munkybooty added a commit to Munkybooty/dash that referenced this issue Sep 5, 2021
…nc test

6aaa0ab Remove manual byte editing in wallet_tx_clone func test (Gregory Sanders)

Pull request description:

  Adapted from @stevenroose

Tree-SHA512: 87f251579e347f870bd30fc57b0c130f00914a3dc78799826384eb049b91d49f2525d55899bf525997e23cc976ca7d10e6b56b23f7358acec307368d48a6f6f1
vijaydasmp added a commit to vijaydasmp/dash that referenced this issue Sep 6, 2021
…nc test

6aaa0ab Remove manual byte editing in wallet_tx_clone func test (Gregory Sanders)

Pull request description:

  Adapted from @stevenroose

Tree-SHA512: 87f251579e347f870bd30fc57b0c130f00914a3dc78799826384eb049b91d49f2525d55899bf525997e23cc976ca7d10e6b56b23f7358acec307368d48a6f6f1
Munkybooty added a commit to Munkybooty/dash that referenced this issue Sep 7, 2021
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
Munkybooty added a commit to Munkybooty/dash that referenced this issue Sep 7, 2021
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
Munkybooty added a commit to Munkybooty/dash that referenced this issue Sep 7, 2021
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
Munkybooty added a commit to Munkybooty/dash that referenced this issue Sep 7, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants