aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@protonmail.com>2019-09-18 16:18:17 +0200
committerWladimir J. van der Laan <laanwj@protonmail.com>2019-09-18 16:19:47 +0200
commit72d30d668afd54537a707c0995241b5a38844cb9 (patch)
tree4931a21a5043edb806628bbfd7358cea60cbb61c /test
parent408c9203810239b3c9d272327bc35ad5a755a2b7 (diff)
parentc0b5d9710322a614a50ab5da081558cf6a38ad2a (diff)
downloadbitcoin-72d30d668afd54537a707c0995241b5a38844cb9.tar.xz
Merge #16512: rpc: Shuffle inputs and outputs after joining psbts
c0b5d9710322a614a50ab5da081558cf6a38ad2a Test that joinpsbts randomly shuffles the inputs (Andrew Chow) 6f405a1d3b38395e35571b68aae55cae50e0762a Shuffle inputs and outputs after joining psbts (Andrew Chow) Pull request description: `joinpsbts` currently just adds the inputs and outputs in the order of that the PSBTs were provided. This makes it extremely easy to identify which outputs belong to which inputs. This PR changes that so that all of the inputs and outputs are shuffled in the joined transaction. ACKs for top commit: instagibbs: utACK https://github.com/bitcoin/bitcoin/pull/16512/commits/c0b5d9710322a614a50ab5da081558cf6a38ad2a jonatack: ACK c0b5d9710322a614a50ab5da081558cf6a38ad2a modulo suggestions for later. Tree-SHA512: 14a0b7aae07d92e6d2c76a3a3b228b481e1964cb7d34f97515bdda18e2ea05a9f97c5a22affc143b86ae8b95c3cb239849fb54219d65512bc2112264dca915c8
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/rpc_psbt.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py
index 5a04e0c8d8..cb8320a6c2 100755
--- a/test/functional/rpc_psbt.py
+++ b/test/functional/rpc_psbt.py
@@ -382,6 +382,16 @@ class PSBTTest(BitcoinTestFramework):
joined_decoded = self.nodes[0].decodepsbt(joined)
assert len(joined_decoded['inputs']) == 4 and len(joined_decoded['outputs']) == 2 and "final_scriptwitness" not in joined_decoded['inputs'][3] and "final_scriptSig" not in joined_decoded['inputs'][3]
+ # Check that joining shuffles the inputs and outputs
+ # 10 attempts should be enough to get a shuffled join
+ shuffled = False
+ for i in range(0, 10):
+ shuffled_joined = self.nodes[0].joinpsbts([psbt, psbt2])
+ shuffled |= joined != shuffled_joined
+ if shuffled:
+ break
+ assert shuffled
+
# Newly created PSBT needs UTXOs and updating
addr = self.nodes[1].getnewaddress("", "p2sh-segwit")
txid = self.nodes[0].sendtoaddress(addr, 7)