(self, confidential)
| 137 | assert_equal(decoded_psbt["outputs"][changepos]["script"]["type"], expected_type) |
| 138 | |
| 139 | def run_basic_tests(self, confidential): |
| 140 | starting_n_unspent = len(self.nodes[0].listlockunspent()) # ELEMENTS |
| 141 | # Create and fund a raw tx for sending 10 BTC |
| 142 | psbtx1 = self.nodes[0].walletcreatefundedpsbt([], [{self.get_address(confidential, 2):10}])['psbt'] |
| 143 | |
| 144 | # If inputs are specified, do not automatically add more: |
| 145 | utxo1 = self.nodes[0].listunspent()[0] |
| 146 | assert_raises_rpc_error(-4, "Insufficient funds", self.nodes[0].walletcreatefundedpsbt, [{"txid": utxo1['txid'], "vout": utxo1['vout']}], [{self.get_address(confidential, 2):90}]) |
| 147 | |
| 148 | psbtx1 = self.nodes[0].walletcreatefundedpsbt([{"txid": utxo1['txid'], "vout": utxo1['vout']}], [{self.get_address(confidential, 2):90}], 0, {"add_inputs": True})['psbt'] |
| 149 | # ELEMENTS: we are on the edge between 2 and 3 inputs; don't check exact value, |
| 150 | # just make sure that we added at least one input |
| 151 | assert len(self.nodes[0].decodepsbt(psbtx1)["inputs"]) > 1 |
| 152 | |
| 153 | # Inputs argument can be null |
| 154 | self.nodes[0].walletcreatefundedpsbt(None, [{self.nodes[2].getnewaddress():10}]) |
| 155 | |
| 156 | # Node 1 should not be able to add anything to it but still return the psbtx same as before |
| 157 | psbtx = self.nodes[1].walletprocesspsbt(psbtx1)['psbt'] |
| 158 | assert_equal(psbtx1, psbtx) |
| 159 | |
| 160 | # ELEMENTS: FIXME failing asserts |
| 161 | # Node 0 should not be able to sign the transaction with the wallet is locked |
| 162 | # self.nodes[0].encryptwallet("password") |
| 163 | # assert_raises_rpc_error(-13, "Please enter the wallet passphrase with walletpassphrase first", self.nodes[0].walletprocesspsbt, psbtx) |
| 164 | |
| 165 | # Node 0 should be able to process without signing though |
| 166 | unsigned_tx = self.nodes[0].walletprocesspsbt(psbtx, False) |
| 167 | assert_equal(unsigned_tx['complete'], False) |
| 168 | |
| 169 | # self.nodes[0].walletpassphrase(passphrase="password", timeout=1000000) |
| 170 | |
| 171 | # Sign the transaction and send |
| 172 | signed_tx = self.nodes[0].walletprocesspsbt(psbt=psbtx, finalize=False)['psbt'] |
| 173 | finalized_tx = self.nodes[0].walletprocesspsbt(psbt=psbtx, finalize=True)['psbt'] |
| 174 | assert signed_tx != finalized_tx |
| 175 | final_tx = self.nodes[0].finalizepsbt(signed_tx)['hex'] |
| 176 | if confidential: |
| 177 | # Can't use assert_equal because there may or may not be change |
| 178 | assert(self.num_blinded_outputs(final_tx) > 0) |
| 179 | self.nodes[0].sendrawtransaction(final_tx) |
| 180 | |
| 181 | # Manually selected inputs can be locked: |
| 182 | assert_equal(len(self.nodes[0].listlockunspent()), starting_n_unspent) |
| 183 | utxo1 = self.nodes[0].listunspent()[0] |
| 184 | psbtx1 = self.nodes[0].walletcreatefundedpsbt([{"txid": utxo1['txid'], "vout": utxo1['vout']}], [{self.get_address(confidential, 2):1}], 0,{"lockUnspents": True})["psbt"] |
| 185 | assert_equal(len(self.nodes[0].listlockunspent()), starting_n_unspent + 1) |
| 186 | |
| 187 | # Locks are ignored for manually selected inputs |
| 188 | self.nodes[0].walletcreatefundedpsbt([{"txid": utxo1['txid'], "vout": utxo1['vout']}], [{self.get_address(confidential, 2):1}], 0) |
| 189 | |
| 190 | # Create p2sh, p2wpkh, and p2wsh addresses |
| 191 | pubkey0 = self.nodes[0].getaddressinfo(self.get_address(confidential, 0))['pubkey'] |
| 192 | pubkey1 = self.nodes[1].getaddressinfo(self.get_address(confidential, 1))['pubkey'] |
| 193 | pubkey2 = self.nodes[2].getaddressinfo(self.get_address(confidential, 2))['pubkey'] |
| 194 | |
| 195 | # Setup watchonly wallets |
| 196 | if confidential: |
no test coverage detected