(self)
| 64 | connect_nodes_bi(self.nodes, 0, 2) |
| 65 | |
| 66 | def run_test(self): |
| 67 | # Create and fund a raw tx for sending 10 BTC |
| 68 | psbtx1 = self.nodes[0].walletcreatefundedpsbt([], {self.nodes[2].getnewaddress():10})['psbt'] |
| 69 | |
| 70 | # Node 1 should not be able to add anything to it but still return the psbtx same as before |
| 71 | psbtx = self.nodes[1].walletprocesspsbt(psbtx1)['psbt'] |
| 72 | assert_equal(psbtx1, psbtx) |
| 73 | |
| 74 | # Sign the transaction and send |
| 75 | signed_tx = self.nodes[0].walletprocesspsbt(psbtx)['psbt'] |
| 76 | final_tx = self.nodes[0].finalizepsbt(signed_tx)['hex'] |
| 77 | self.nodes[0].sendrawtransaction(final_tx) |
| 78 | |
| 79 | # Create p2sh, p2wpkh, and p2wsh addresses |
| 80 | pubkey0 = self.nodes[0].getaddressinfo(self.nodes[0].getnewaddress())['pubkey'] |
| 81 | pubkey1 = self.nodes[1].getaddressinfo(self.nodes[1].getnewaddress())['pubkey'] |
| 82 | pubkey2 = self.nodes[2].getaddressinfo(self.nodes[2].getnewaddress())['pubkey'] |
| 83 | p2sh = self.nodes[1].addmultisigaddress(2, [pubkey0, pubkey1, pubkey2], "", "legacy")['address'] |
| 84 | p2wsh = self.nodes[1].addmultisigaddress(2, [pubkey0, pubkey1, pubkey2], "", "bech32")['address'] |
| 85 | p2sh_p2wsh = self.nodes[1].addmultisigaddress(2, [pubkey0, pubkey1, pubkey2], "", "p2sh-segwit")['address'] |
| 86 | p2wpkh = self.nodes[1].getnewaddress("", "bech32") |
| 87 | p2pkh = self.nodes[1].getnewaddress("", "legacy") |
| 88 | p2sh_p2wpkh = self.nodes[1].getnewaddress("", "p2sh-segwit") |
| 89 | |
| 90 | # fund those addresses |
| 91 | rawtx = self.nodes[0].createrawtransaction([], {p2sh:10, p2wsh:10, p2wpkh:10, p2sh_p2wsh:10, p2sh_p2wpkh:10, p2pkh:10}) |
| 92 | rawtx = self.nodes[0].fundrawtransaction(rawtx, {"changePosition":3}) |
| 93 | signed_tx = self.nodes[0].signrawtransactionwithwallet(rawtx['hex'])['hex'] |
| 94 | txid = self.nodes[0].sendrawtransaction(signed_tx) |
| 95 | self.nodes[0].generate(6) |
| 96 | self.sync_all() |
| 97 | |
| 98 | # Find the output pos |
| 99 | p2sh_pos = -1 |
| 100 | p2wsh_pos = -1 |
| 101 | p2wpkh_pos = -1 |
| 102 | p2pkh_pos = -1 |
| 103 | p2sh_p2wsh_pos = -1 |
| 104 | p2sh_p2wpkh_pos = -1 |
| 105 | decoded = self.nodes[0].decoderawtransaction(signed_tx) |
| 106 | for out in decoded['vout']: |
| 107 | if out['scriptPubKey']['addresses'][0] == p2sh: |
| 108 | p2sh_pos = out['n'] |
| 109 | elif out['scriptPubKey']['addresses'][0] == p2wsh: |
| 110 | p2wsh_pos = out['n'] |
| 111 | elif out['scriptPubKey']['addresses'][0] == p2wpkh: |
| 112 | p2wpkh_pos = out['n'] |
| 113 | elif out['scriptPubKey']['addresses'][0] == p2sh_p2wsh: |
| 114 | p2sh_p2wsh_pos = out['n'] |
| 115 | elif out['scriptPubKey']['addresses'][0] == p2sh_p2wpkh: |
| 116 | p2sh_p2wpkh_pos = out['n'] |
| 117 | elif out['scriptPubKey']['addresses'][0] == p2pkh: |
| 118 | p2pkh_pos = out['n'] |
| 119 | |
| 120 | # spend single key from node 1 |
| 121 | rawtx = self.nodes[1].walletcreatefundedpsbt([{"txid":txid,"vout":p2wpkh_pos},{"txid":txid,"vout":p2sh_p2wpkh_pos},{"txid":txid,"vout":p2pkh_pos}], {self.nodes[1].getnewaddress():29.99})['psbt'] |
| 122 | walletprocesspsbt_out = self.nodes[1].walletprocesspsbt(rawtx) |
| 123 | assert_equal(walletprocesspsbt_out['complete'], True) |
nothing calls this directly
no test coverage detected