diff options
author | Andrew Chow <achow101-github@achow101.com> | 2018-07-20 18:24:16 -0700 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2019-02-16 00:04:27 -0500 |
commit | 08f749c9147a5f3fdbbd880e0974b97084429002 (patch) | |
tree | b54ee7d58a907acbe39af79fd2e8d226a2b520fe /test/functional | |
parent | 7344a7b9984b99882e136efc8ad48fb31740df93 (diff) | |
download | bitcoin-08f749c9147a5f3fdbbd880e0974b97084429002.tar.xz |
Implement joinpsbts RPC and tests
Adds a joinpsbts RPC which combines multiple distinct PSBTs into
one PSBT.
Diffstat (limited to 'test/functional')
-rwxr-xr-x | test/functional/rpc_psbt.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py index 28507267ce..f1538b34a8 100755 --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -321,6 +321,23 @@ class PSBTTest(BitcoinTestFramework): assert "witness_utxo" not in decoded['inputs'][1] and "non_witness_utxo" not in decoded['inputs'][1] assert "witness_utxo" not in decoded['inputs'][2] and "non_witness_utxo" not in decoded['inputs'][2] + # Two PSBTs with a common input should not be joinable + psbt1 = self.nodes[1].createpsbt([{"txid":txid1, "vout":vout1}], {self.nodes[0].getnewaddress():Decimal('10.999')}) + assert_raises_rpc_error(-8, "exists in multiple PSBTs", self.nodes[1].joinpsbts, [psbt1, updated]) + + # Join two distinct PSBTs + addr4 = self.nodes[1].getnewaddress("", "p2sh-segwit") + txid4 = self.nodes[0].sendtoaddress(addr4, 5) + vout4 = find_output(self.nodes[0], txid4, 5) + self.nodes[0].generate(6) + self.sync_all() + psbt2 = self.nodes[1].createpsbt([{"txid":txid4, "vout":vout4}], {self.nodes[0].getnewaddress():Decimal('4.999')}) + psbt2 = self.nodes[1].walletprocesspsbt(psbt2)['psbt'] + psbt2_decoded = self.nodes[0].decodepsbt(psbt2) + assert "final_scriptwitness" in psbt2_decoded['inputs'][0] and "final_scriptSig" in psbt2_decoded['inputs'][0] + joined = self.nodes[0].joinpsbts([psbt, psbt2]) + 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] if __name__ == '__main__': |