diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 25893c1156..0d26b9081b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5018,7 +5018,7 @@ UniValue initpegoutwallet(const JSONRPCRequest& request) // Strip off leading key origin if (xpub_str.find("]") != std::string::npos) { - xpub_str = xpub_str.substr(xpub_str.find("]"), std::string::npos); + xpub_str = xpub_str.substr(xpub_str.find("]")+1, std::string::npos); } // Strip off following range diff --git a/test/functional/feature_pak.py b/test/functional/feature_pak.py index 9ae1b7a058..1068c1c5c6 100755 --- a/test/functional/feature_pak.py +++ b/test/functional/feature_pak.py @@ -63,6 +63,8 @@ class PAKTest (BitcoinTestFramework): assert_raises_rpc_error(-8, "bip32_counter must be between 0 and 1,000,000,000, inclusive.", self.nodes[1].initpegoutwallet, xpub, 1000000001) + # Make sure we can also prepend the key origin to the xpub. + self.nodes[1].initpegoutwallet("pkh([deadbeef/44h/0h/0h]"+xpub+"/0/*)") new_init = self.nodes[1].initpegoutwallet(xpub, 2) assert_equal(self.nodes[1].getwalletpakinfo()["bip32_counter"], "2") assert_equal(new_init["address_lookahead"][0], init_results[1]["address_lookahead"][2])