aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2021-10-18 14:43:26 -0400
committerAndrew Chow <achow101-github@achow101.com>2021-12-08 11:22:29 -0500
commit961b9e4e40019a87eaa11c8a9c3305870f7a6d75 (patch)
tree0192becba6f8810f368a7a458e9fd97e15fb284d
parent0652ee73ec880a66ec88bde007ee03c0b9d1b074 (diff)
wallet: Parse hdKeypath if key_origin is not available
When topping up an inactive HD chain, either key_origin will be available and we can use the path given there, or we need to figure out the path from the string hdKeypath.
-rw-r--r--src/wallet/scriptpubkeyman.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp
index 5a9755d32b..7cca5fba20 100644
--- a/src/wallet/scriptpubkeyman.cpp
+++ b/src/wallet/scriptpubkeyman.cpp
@@ -382,14 +382,22 @@ std::vector<WalletDestination> LegacyScriptPubKeyMan::MarkUnusedAddresses(const
if (it != mapKeyMetadata.end()){
CKeyMetadata meta = it->second;
if (!meta.hd_seed_id.IsNull() && meta.hd_seed_id != m_hd_chain.seed_id) {
- if (meta.key_origin.path.size() < 3) {
- WalletLogPrintf("%s: Adding inactive seed keys failed, insufficient path size: %d, has_key_origin: %s\n",
+ std::vector<uint32_t> path;
+ if (meta.has_key_origin) {
+ path = meta.key_origin.path;
+ } else if (!ParseHDKeypath(meta.hdKeypath, path)) {
+ WalletLogPrintf("%s: Adding inactive seed keys failed, invalid hdKeypath: %s\n",
__func__,
- meta.key_origin.path.size(),
+ meta.hdKeypath);
+ }
+ if (path.size() != 3) {
+ WalletLogPrintf("%s: Adding inactive seed keys failed, invalid path size: %d, has_key_origin: %s\n",
+ __func__,
+ path.size(),
meta.has_key_origin);
} else {
- bool internal = (meta.key_origin.path[1] & ~BIP32_HARDENED_KEY_LIMIT) != 0;
- int64_t index = meta.key_origin.path[2] & ~BIP32_HARDENED_KEY_LIMIT;
+ bool internal = (path[1] & ~BIP32_HARDENED_KEY_LIMIT) != 0;
+ int64_t index = path[2] & ~BIP32_HARDENED_KEY_LIMIT;
if (!TopUpInactiveHDChain(meta.hd_seed_id, index, internal)) {
WalletLogPrintf("%s: Adding inactive seed keys failed\n", __func__);