From 651b28c4cab8316f5df4c2a484961580af5c88e2 Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Mon, 30 Sep 2019 17:12:22 +0200 Subject: [PATCH] Fix other bug in initpegoutwallet descriptor parsing --- src/wallet/rpcwallet.cpp | 2 +- test/functional/feature_pak.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6d2c2ebe98..f1c9384393 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5013,7 +5013,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 @@ def run_test(self): 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])