mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Update rpc_psbt.py for PSET
This commit is contained in:
parent
46ccf611c4
commit
afd795010b
1 changed files with 24 additions and 12 deletions
|
|
@ -405,7 +405,7 @@ class PSBTTest(BitcoinTestFramework):
|
|||
psbt1 = self.nodes[1].walletprocesspsbt(psbt_orig, False, "ALL")['psbt']
|
||||
psbt1_decoded = self.nodes[0].decodepsbt(psbt1)
|
||||
assert len(psbt1_decoded["inputs"][0].keys()) > 3
|
||||
assert len(psbt2_decoded["inputs"][1].keys()) == 3
|
||||
assert len(psbt1_decoded["inputs"][1].keys()) == 3
|
||||
# Check that BIP32 path was added
|
||||
assert "bip32_derivs" in psbt1_decoded['inputs'][0]
|
||||
psbt2 = self.nodes[2].walletprocesspsbt(psbt_orig, False, "ALL", False)['psbt']
|
||||
|
|
@ -415,11 +415,16 @@ class PSBTTest(BitcoinTestFramework):
|
|||
# Check that BIP32 paths were not added
|
||||
assert "bip32_derivs" not in psbt2_decoded['inputs'][1]
|
||||
|
||||
# Sign PSBTs (workaround issue #18039)
|
||||
psbt1 = self.nodes[1].walletprocesspsbt(psbt_orig)['psbt']
|
||||
psbt2 = self.nodes[2].walletprocesspsbt(psbt_orig)['psbt']
|
||||
# Fill PSBTs (workaround issue #18039)
|
||||
psbt1 = self.nodes[1].walletprocesspsbt(psbt_orig, False)['psbt']
|
||||
psbt2 = self.nodes[2].walletprocesspsbt(psbt_orig, False)['psbt']
|
||||
|
||||
# Combine, finalize, and send the psbts
|
||||
# Combine and sign
|
||||
combined = self.nodes[0].combinepsbt([psbt1, psbt2])
|
||||
psbt1 = self.nodes[1].walletprocesspsbt(combined, True)['psbt']
|
||||
psbt2 = self.nodes[2].walletprocesspsbt(combined, True)['psbt']
|
||||
|
||||
# Combine again, finalize, sign, and send the psbts
|
||||
combined = self.nodes[0].combinepsbt([psbt1, psbt2])
|
||||
finalized = self.nodes[0].finalizepsbt(combined)['hex']
|
||||
self.nodes[0].sendrawtransaction(finalized)
|
||||
|
|
@ -649,8 +654,6 @@ class PSBTTest(BitcoinTestFramework):
|
|||
self.nodes[0].generate(200)
|
||||
self.sync_all()
|
||||
|
||||
assert_raises_rpc_error(-25, 'Inputs missing or spent', self.nodes[0].walletprocesspsbt, 'cHNldP8BAOECAAAAAAK2GUhaoOw0nV0BJhZg0a8G7vb9PQvlTds8GA/N+l+peAMAAAAA/////7YZSFqg7DSdXQEmFmDRrwbu9v09C+VN2zwYD836X6l4AQAAAAD/////AgEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAlQK2wAAWABSNJKzjaUb3uOxixsvh1GGE3fW7zQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAlQL5AAAWABQo3DTHwdFy0CCa+h6+bi7VJs3tcgAAAAAAAQDhAgAAAAACczMa321tVHuN4GKWKRncycI22aX3uXgwSFUKM2orjRsBAAAAAP////9zMxrfbW1Ue43gYpYpGdzJwjbZpfe5eDBIVQozaiuNGwAAAAAA/////wIBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAJUC+QAAFgAU/c11FQPC7OYlaspyx3uf70ntV8kBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAJUCzUAAFgAUZlkFHI0o4IUPP7h+AZ/85GpMC7QAAAAAAAEBQgEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAlQLNQAAWABRmWQUcjSjghQ8/uH4Bn/zkakwLtAAAAA==')
|
||||
|
||||
# Run all the pre-Elements, tests first with non-confidential addresses, then again with confidential addresses
|
||||
self.run_basic_tests(False)
|
||||
self.run_basic_tests(True)
|
||||
|
|
@ -714,23 +717,28 @@ class PSBTTest(BitcoinTestFramework):
|
|||
test_psbt_input_keys(decoded['inputs'][1], psbt_v2_required_keys)
|
||||
test_psbt_input_keys(decoded['inputs'][2], psbt_v2_required_keys + ['witness_utxo', 'bip32_derivs', 'redeem_script'])
|
||||
|
||||
# Cannot create PSBTv0
|
||||
assert_raises_rpc_error(-8, "The PSBT version can only be 2", self.nodes[0].createpsbt, [{"txid":txid1, "vout":vout1}], [{self.nodes[0].getnewaddress():Decimal('10.999')}], 0, True, 0)
|
||||
|
||||
"""
|
||||
# TODO: joinpsbts is disabled for PSBTv2s
|
||||
# Cannot join PSBTv2s
|
||||
psbt1 = self.nodes[1].createpsbt(inputs=[{"txid":txid1, "vout":vout1}], outputs={self.nodes[0].getnewaddress():Decimal('10.999')}, psbt_version=0)
|
||||
psbt2 = self.nodes[1].createpsbt(inputs=[{"txid":txid1, "vout":vout1}], outputs={self.nodes[0].getnewaddress():Decimal('10.999')}, psbt_version=2)
|
||||
psbt1 = self.nodes[1].createpsbt(inputs=[{"txid":txid1, "vout":vout1}], outputs=[{self.nodes[0].getnewaddress():Decimal('10.999')}], psbt_version=0)
|
||||
psbt2 = self.nodes[1].createpsbt(inputs=[{"txid":txid1, "vout":vout1}], outputs=[{self.nodes[0].getnewaddress():Decimal('10.999')}], psbt_version=2)
|
||||
assert_raises_rpc_error(-8, "joinpsbts only operates on version 0 PSBTs", self.nodes[1].joinpsbts, [psbt1, psbt2])
|
||||
|
||||
# Two PSBTs with a common input should not be joinable
|
||||
psbt2 = self.nodes[1].createpsbt(inputs=[{"txid":txid1, "vout":vout1}], outputs={self.nodes[0].getnewaddress():Decimal('10.999')}, psbt_version=0)
|
||||
psbt2 = self.nodes[1].createpsbt(inputs=[{"txid":txid1, "vout":vout1}], outputs=[{self.nodes[0].getnewaddress():Decimal('10.999')}], psbt_version=0)
|
||||
assert_raises_rpc_error(-8, "exists in multiple PSBTs", self.nodes[1].joinpsbts, [psbt1, psbt2])
|
||||
|
||||
# Join two distinct PSBTs
|
||||
psbt1 = self.nodes[1].createpsbt(inputs=[{"txid":txid1, "vout":vout1},{"txid":txid2, "vout":vout2},{"txid":txid3, "vout":vout3}], outputs={self.nodes[0].getnewaddress():32.999}, psbt_version=0)
|
||||
psbt1 = self.nodes[1].createpsbt(inputs=[{"txid":txid1, "vout":vout1},{"txid":txid2, "vout":vout2},{"txid":txid3, "vout":vout3}], outputs=[{self.nodes[0].getnewaddress():32.999}], psbt_version=0)
|
||||
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(inputs=[{"txid":txid4, "vout":vout4}], outputs={self.nodes[0].getnewaddress():Decimal('4.999')}, psbt_version=0)
|
||||
psbt2 = self.nodes[1].createpsbt(inputs=[{"txid":txid4, "vout":vout4}], outputs=[{self.nodes[0].getnewaddress():Decimal('4.999')}], psbt_version=0)
|
||||
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]
|
||||
|
|
@ -750,7 +758,10 @@ class PSBTTest(BitcoinTestFramework):
|
|||
if shuffled:
|
||||
break
|
||||
assert shuffled
|
||||
"""
|
||||
|
||||
# TODO: Re-enable analyzepsbt
|
||||
"""
|
||||
# Newly created PSBT needs UTXOs and updating
|
||||
addr = self.nodes[1].getnewaddress("", "p2sh-segwit")
|
||||
txid = self.nodes[0].sendtoaddress(addr, 7)
|
||||
|
|
@ -800,6 +811,7 @@ class PSBTTest(BitcoinTestFramework):
|
|||
assert_equal(analysis['error'], 'PSBT is not valid. Input 0 specifies invalid prevout')
|
||||
|
||||
assert_raises_rpc_error(-25, 'Inputs missing or spent', self.nodes[0].walletprocesspsbt, 'cHNldP8BAOECAAAAAAK2GUhaoOw0nV0BJhZg0a8G7vb9PQvlTds8GA/N+l+peAMAAAAA/////7YZSFqg7DSdXQEmFmDRrwbu9v09C+VN2zwYD836X6l4AQAAAAD/////AgEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAlQK2wAAWABSNJKzjaUb3uOxixsvh1GGE3fW7zQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAlQL5AAAWABQo3DTHwdFy0CCa+h6+bi7VJs3tcgAAAAAAAQDhAgAAAAACczMa321tVHuN4GKWKRncycI22aX3uXgwSFUKM2orjRsBAAAAAP////9zMxrfbW1Ue43gYpYpGdzJwjbZpfe5eDBIVQozaiuNGwAAAAAA/////wIBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAJUC+QAAFgAU/c11FQPC7OYlaspyx3uf70ntV8kBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAJUCzUAAFgAUZlkFHI0o4IUPP7h+AZ/85GpMC7QAAAAAAAEBQgEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAlQLNQAAWABRmWQUcjSjghQ8/uH4Bn/zkakwLtAAAAA==')
|
||||
"""
|
||||
|
||||
if __name__ == '__main__':
|
||||
PSBTTest().main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue