Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/scriptpubkeyman.cpp
Show First 20 Lines • Show All 422 Lines • ▼ Show 20 Lines | return setInternalKeyPool.size() + setExternalKeyPool.size() + | ||||
set_pre_split_keypool.size(); | set_pre_split_keypool.size(); | ||||
} | } | ||||
int64_t LegacyScriptPubKeyMan::GetTimeFirstKey() const { | int64_t LegacyScriptPubKeyMan::GetTimeFirstKey() const { | ||||
LOCK(cs_KeyStore); | LOCK(cs_KeyStore); | ||||
return nTimeFirstKey; | 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; | |||||
} | |||||
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; | |||||
} | |||||
// 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 * | const CKeyMetadata * | ||||
LegacyScriptPubKeyMan::GetMetadata(const CTxDestination &dest) const { | LegacyScriptPubKeyMan::GetMetadata(const CTxDestination &dest) const { | ||||
LOCK(cs_KeyStore); | LOCK(cs_KeyStore); | ||||
CKeyID key_id = GetKeyForDestination(*this, dest); | CKeyID key_id = GetKeyForDestination(*this, dest); | ||||
if (!key_id.IsNull()) { | if (!key_id.IsNull()) { | ||||
auto it = mapKeyMetadata.find(key_id); | auto it = mapKeyMetadata.find(key_id); | ||||
if (it != mapKeyMetadata.end()) { | if (it != mapKeyMetadata.end()) { | ||||
return &it->second; | return &it->second; | ||||
} | } | ||||
} | } | ||||
CScript scriptPubKey = GetScriptForDestination(dest); | CScript scriptPubKey = GetScriptForDestination(dest); | ||||
auto it = m_script_metadata.find(CScriptID(scriptPubKey)); | auto it = m_script_metadata.find(CScriptID(scriptPubKey)); | ||||
if (it != m_script_metadata.end()) { | if (it != m_script_metadata.end()) { | ||||
return &it->second; | return &it->second; | ||||
} | } | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
uint256 LegacyScriptPubKeyMan::GetID() const { | |||||
return UINT256_ONE(); | |||||
} | |||||
/** | /** | ||||
* Update wallet first key creation time. This should be called whenever keys | * Update wallet first key creation time. This should be called whenever keys | ||||
* are added to the wallet, with the oldest key creation time. | * are added to the wallet, with the oldest key creation time. | ||||
*/ | */ | ||||
void LegacyScriptPubKeyMan::UpdateTimeFirstKey(int64_t nCreateTime) { | void LegacyScriptPubKeyMan::UpdateTimeFirstKey(int64_t nCreateTime) { | ||||
AssertLockHeld(cs_KeyStore); | AssertLockHeld(cs_KeyStore); | ||||
if (nCreateTime <= 1) { | if (nCreateTime <= 1) { | ||||
// Cannot determine birthday information, so set the wallet birthday to | // Cannot determine birthday information, so set the wallet birthday to | ||||
▲ Show 20 Lines • Show All 975 Lines • Show Last 20 Lines |