Here in the function AttachChain
there is block of code:
// Unless allowed, ensure wallet files are not reused across chains:
if (!gArgs.GetBoolArg("-walletcrosschain", DEFAULT_WALLETCROSSCHAIN)) {
WalletBatch batch(walletInstance->GetDatabase());
CBlockLocator locator;
if (batch.ReadBestBlock(locator) && locator.vHave.size() > 0 && chain.getHeight()) {
// Wallet is assumed to be from another chain, if genesis block in the active
// chain differs from the genesis block known to the wallet.
if (chain.getBlockHash(0) != locator.vHave.back()) {
error = Untranslated("Wallet files should not be reused across chains. Restart bitcoind with -walletcrosschain to override.");
return false;
}
}
}
I've seen the CBlockLocator
contructor and with no argument, it does nothing so the vHave
member of locator
is always empty. So next if
statement will never execute because:
batch.ReadBestBlock(locator) && locator.vHave.size() > 0 && chain.getHeight()
Is alway false
. I think I'm missing something here, because if I'm correct the if statement is like if(0)
and so it's not useful.