Key pool: Change ReturnDestination interface to take address instead of key

In order for ScriptPubKeyMan to be generic and work with future
ScriptPubKeyMans, ScriptPubKeyMan::ReturnDestination is changed to
take a CTxDestination instead of a CPubKey. Since LegacyScriptPubKeyMan
still deals with keys internally, a new map m_reserved_key_to_index is
added in order to track the keypool indexes that have been reserved.

The CPubKey argument of KeepDestination is also  removed so that it is
more generic. Instead of taking a CPubKey or a CTxDestination, we just use
the nIndex given to find the pubkey.
This commit is contained in:
Andrew Chow
2019-10-07 14:11:34 -04:00
parent ba41aa4969
commit 386a994b85
4 changed files with 20 additions and 16 deletions

View File

@@ -3305,10 +3305,8 @@ bool ReserveDestination::GetReservedDestination(CTxDestination& dest, bool inter
if (!m_spk_man->GetReservedDestination(type, internal, address, nIndex, keypool)) {
return false;
}
vchPubKey = keypool.vchPubKey;
fInternal = keypool.fInternal;
}
assert(vchPubKey.IsValid());
dest = address;
return true;
}
@@ -3316,20 +3314,18 @@ bool ReserveDestination::GetReservedDestination(CTxDestination& dest, bool inter
void ReserveDestination::KeepDestination()
{
if (nIndex != -1) {
m_spk_man->KeepDestination(nIndex, type, vchPubKey);
m_spk_man->KeepDestination(nIndex, type);
}
nIndex = -1;
vchPubKey = CPubKey();
address = CNoDestination();
}
void ReserveDestination::ReturnDestination()
{
if (nIndex != -1) {
m_spk_man->ReturnDestination(nIndex, fInternal, vchPubKey);
m_spk_man->ReturnDestination(nIndex, fInternal, address);
}
nIndex = -1;
vchPubKey = CPubKey();
address = CNoDestination();
}