(self)
| 956 | assert_raises_rpc_error(-8, "PSBTs not compatible (different transactions)", self.nodes[0].combinepsbt, [BLINDED, bad_pset]) |
| 957 | |
| 958 | def run_test(self): |
| 959 | self.generate(self.nodes[0], 200) |
| 960 | self.sync_all() |
| 961 | |
| 962 | # Run all the pre-Elements, tests first with non-confidential addresses, then again with confidential addresses |
| 963 | self.run_basic_tests(False) |
| 964 | self.run_basic_tests(True) |
| 965 | |
| 966 | # BIP 174 test vectors are disabled, because they have embedded serialized CTransactions, and |
| 967 | # the transaction serialization format changed in Elements so none of them work |
| 968 | #self.run_bip174_tests() |
| 969 | |
| 970 | # Some Confidential-Assets-specific tests |
| 971 | self.run_ca_tests() |
| 972 | self.run_unsafe_tests() |
| 973 | |
| 974 | # TODO: Re-enable this for segwit v1 |
| 975 | # self.test_utxo_conversion() |
| 976 | |
| 977 | # Test that psbts with p2pkh outputs are created properly |
| 978 | p2pkh = self.nodes[0].getnewaddress(address_type='legacy') |
| 979 | psbt = self.nodes[1].walletcreatefundedpsbt([], [{p2pkh : 1}], 0, {"includeWatching" : True}, True) |
| 980 | self.nodes[0].decodepsbt(psbt['psbt']) |
| 981 | |
| 982 | # Test decoding error: invalid base64 |
| 983 | assert_raises_rpc_error(-22, "TX decode failed invalid base64", self.nodes[0].decodepsbt, ";definitely not base64;") |
| 984 | |
| 985 | # Test serialisation acceptance of PSBT_ELEMENTS_GLOBAL_SCALAR |
| 986 | old_serialization = 'cHNldP8B+wQCAAAAAQIEAgAAAAEEAQABBQEAJ/wEcHNldAABAgMEBQYHCAkKCwwNDg8QERITFBUWFxgZGhscHR4fIAEAAA==' |
| 987 | new_serialization = 'cHNldP8B+wQCAAAAAQIEAgAAAAEEAQABBQEAJ/wEcHNldAABAgMEBQYHCAkKCwwNDg8QERITFBUWFxgZGhscHR4fIAAA' |
| 988 | assert_equal(self.nodes[1].decodepsbt(old_serialization), self.nodes[1].decodepsbt(new_serialization)) |
| 989 | |
| 990 | # Send to all types of addresses |
| 991 | addr1 = self.nodes[1].getnewaddress("", "bech32") |
| 992 | txid1 = self.nodes[0].sendtoaddress(addr1, 11) |
| 993 | vout1 = find_output(self.nodes[0], txid1, 11) |
| 994 | addr2 = self.nodes[1].getnewaddress("", "legacy") |
| 995 | txid2 = self.nodes[0].sendtoaddress(addr2, 11) |
| 996 | vout2 = find_output(self.nodes[0], txid2, 11) |
| 997 | addr3 = self.nodes[1].getnewaddress("", "p2sh-segwit") |
| 998 | txid3 = self.nodes[0].sendtoaddress(addr3, 11) |
| 999 | vout3 = find_output(self.nodes[0], txid3, 11) |
| 1000 | self.sync_all() |
| 1001 | |
| 1002 | psbt_v2_required_keys = ["previous_vout", "sequence", "previous_txid"] |
| 1003 | |
| 1004 | def test_psbt_input_keys(psbt_input, keys): |
| 1005 | """Check that the psbt input has only the expected keys.""" |
| 1006 | assert_equal(set(keys), set(psbt_input.keys())) |
| 1007 | |
| 1008 | # Create a PSBT. None of the inputs are filled initially |
| 1009 | psbt = self.nodes[1].createpsbt([{"txid":txid1, "vout":vout1},{"txid":txid2, "vout":vout2},{"txid":txid3, "vout":vout3}], [{self.nodes[0].getnewaddress():32.999}]) |
| 1010 | decoded = self.nodes[1].decodepsbt(psbt) |
| 1011 | test_psbt_input_keys(decoded['inputs'][0], psbt_v2_required_keys) |
| 1012 | test_psbt_input_keys(decoded['inputs'][1], psbt_v2_required_keys) |
| 1013 | test_psbt_input_keys(decoded['inputs'][2], psbt_v2_required_keys) |
| 1014 | |
| 1015 | # Update a PSBT with UTXOs from the node |
nothing calls this directly
no test coverage detected