Skip to content

Commit 70134eb

Browse files
committed
wallet: Properly set hd chain counters when loading
When build CHDChains out of CKeyMetadata, the chain counters are actually 1 based, not 0 based, so 1 must be added to each index.
1 parent 961b9e4 commit 70134eb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/wallet/walletdb.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,9 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
556556
}
557557
if (internal) {
558558
chain.nVersion = CHDChain::VERSION_HD_CHAIN_SPLIT;
559-
chain.nInternalChainCounter = std::max(chain.nInternalChainCounter, index);
559+
chain.nInternalChainCounter = std::max(chain.nInternalChainCounter, index + 1);
560560
} else {
561-
chain.nExternalChainCounter = std::max(chain.nExternalChainCounter, index);
561+
chain.nExternalChainCounter = std::max(chain.nExternalChainCounter, index + 1);
562562
}
563563
}
564564
} else if (strType == DBKeys::WATCHMETA) {

0 commit comments

Comments
 (0)