mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Box the wallet: Add multiple keyman maps and loops
Add wallet logic for dealing with multiple ScriptPubKeyMan instances. This doesn't change current behavior because there is still only a single LegacyScriptPubKeyMan. But in the future the new logic will be used to support descriptor wallets.
This commit is contained in:
@@ -470,6 +470,34 @@ int64_t LegacyScriptPubKeyMan::GetTimeFirstKey() const
|
||||
return nTimeFirstKey;
|
||||
}
|
||||
|
||||
const SigningProvider* LegacyScriptPubKeyMan::GetSigningProvider(const CScript& script) const
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
bool LegacyScriptPubKeyMan::CanProvide(const CScript& script, SignatureData& sigdata)
|
||||
{
|
||||
if (IsMine(script) != ISMINE_NO) {
|
||||
// If it IsMine, we can always provide in some way
|
||||
return true;
|
||||
} else if (HaveCScript(CScriptID(script))) {
|
||||
// We can still provide some stuff if we have the script, but IsMine failed because we don't have keys
|
||||
return true;
|
||||
} else {
|
||||
// If, given the stuff in sigdata, we could make a valid sigature, then we can provide for this script
|
||||
ProduceSignature(*this, DUMMY_SIGNATURE_CREATOR, script, sigdata);
|
||||
if (!sigdata.signatures.empty()) {
|
||||
// If we could make signatures, make sure we have a private key to actually make a signature
|
||||
bool has_privkeys = false;
|
||||
for (const auto& key_sig_pair : sigdata.signatures) {
|
||||
has_privkeys |= HaveKey(key_sig_pair.first);
|
||||
}
|
||||
return has_privkeys;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const CKeyMetadata* LegacyScriptPubKeyMan::GetMetadata(const CTxDestination& dest) const
|
||||
{
|
||||
LOCK(cs_KeyStore);
|
||||
@@ -491,6 +519,11 @@ const CKeyMetadata* LegacyScriptPubKeyMan::GetMetadata(const CTxDestination& des
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint256 LegacyScriptPubKeyMan::GetID() const
|
||||
{
|
||||
return UINT256_ONE();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update wallet first key creation time. This should be called whenever keys
|
||||
* are added to the wallet, with the oldest key creation time.
|
||||
|
||||
Reference in New Issue
Block a user