(self)
| 26 | self.skip_if_no_wallet() |
| 27 | |
| 28 | def run_test(self): |
| 29 | |
| 30 | # Transitioning PAK lists and checking lists in RPC tested in feature_dynafed |
| 31 | |
| 32 | self.log.info("Test wallet PAK") |
| 33 | |
| 34 | # We will re-use the same xpub, but each wallet will create its own online pak |
| 35 | # so the lists will be incompatible, even if all else was synced |
| 36 | xpub = "tpubD6NzVbkrYhZ4WaWSyoBvQwbpLkojyoTZPRsgXELWz3Popb3qkjcJyJUGLnL4qHHoQvao8ESaAstxYSnhyswJ76uZPStJRJCTKvosUCJZL5B" |
| 37 | xpub_desc = "pkh("+xpub+"/0/*)" # Transform this into a descriptor |
| 38 | init_results = [] |
| 39 | info_results = [] |
| 40 | for i in range(self.num_nodes): |
| 41 | if i == 0: |
| 42 | assert_raises_rpc_error(-8, "PAK enforcement is not enabled on this network.", self.nodes[i].initpegoutwallet, xpub) |
| 43 | init_results += [None] |
| 44 | info_results += [None] |
| 45 | continue |
| 46 | |
| 47 | init_results += [ self.nodes[i].initpegoutwallet(xpub) ] |
| 48 | info_results += [ self.nodes[i].getwalletpakinfo() ] |
| 49 | assert_equal(init_results[i]["address_lookahead"], info_results[i]["address_lookahead"]) |
| 50 | assert_equal(init_results[i]["pakentry"], info_results[i]["pakentry"]) |
| 51 | assert_equal(init_results[i]["liquid_pak"], info_results[i]["liquid_pak"]) |
| 52 | assert_equal(init_results[i]["liquid_pak_address"], info_results[i]["liquid_pak_address"]) |
| 53 | assert_equal(info_results[i]["bitcoin_descriptor"], xpub_desc) |
| 54 | assert_equal(info_results[i]["bip32_counter"], "0") |
| 55 | validata = self.nodes[i].validateaddress(init_results[i]["address_lookahead"][0]) |
| 56 | assert not validata["isvalid"] |
| 57 | assert validata["isvalid_parent"] |
| 58 | assert not validata["parent_address_info"]["isscript"] |
| 59 | assert not validata["parent_address_info"]["iswitness"] |
| 60 | |
| 61 | # Use custom derivation counter values, check if stored correctly, |
| 62 | # address lookahead looks correct and that new liquid_pak was chosen |
| 63 | assert_raises_rpc_error(-8, "bip32_counter must be between 0 and 1,000,000,000, inclusive.", self.nodes[1].initpegoutwallet, xpub, -1) |
| 64 | |
| 65 | assert_raises_rpc_error(-8, "bip32_counter must be between 0 and 1,000,000,000, inclusive.", self.nodes[1].initpegoutwallet, xpub, 1000000001) |
| 66 | |
| 67 | # Make sure we can also prepend the key origin to the xpub. |
| 68 | self.nodes[1].initpegoutwallet("pkh([deadbeef/44h/0h/0h]"+xpub+"/0/*)") |
| 69 | new_init = self.nodes[1].initpegoutwallet(xpub, 2) |
| 70 | assert_equal(self.nodes[1].getwalletpakinfo()["bip32_counter"], "2") |
| 71 | assert_equal(new_init["address_lookahead"][0], init_results[1]["address_lookahead"][2]) |
| 72 | assert(new_init["liquid_pak"] != init_results[1]["liquid_pak"]) |
| 73 | |
| 74 | # Restart and connect peers to check wallet persistence |
| 75 | self.stop_nodes() |
| 76 | self.start_nodes() |
| 77 | self.connect_nodes(0,1) |
| 78 | self.connect_nodes(1,2) |
| 79 | |
| 80 | # Check PAK settings persistence in wallet across restart |
| 81 | restarted_info = self.nodes[1].getwalletpakinfo() |
| 82 | assert_equal(restarted_info["bitcoin_descriptor"], xpub_desc) |
| 83 | assert_equal(restarted_info["liquid_pak"], new_init["liquid_pak"]) |
| 84 | assert_equal(restarted_info["bip32_counter"], "2") |
| 85 |
nothing calls this directly
no test coverage detected