MCPcopy Create free account
hub / github.com/LUX-Core/lux / ImplicitlyLearnRelatedKeyScripts

Method ImplicitlyLearnRelatedKeyScripts

src/keystore.cpp:20–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20void CBasicKeyStore::ImplicitlyLearnRelatedKeyScripts(const CPubKey& pubkey)
21{
22 AssertLockHeld(cs_KeyStore);
23 CKeyID key_id = pubkey.GetID();
24 // We must actually know about this key already.
25 assert(HaveKey(key_id) || mapWatchKeys.count(key_id));
26 // This adds the redeemscripts necessary to detect P2WPKH and P2SH-P2WPKH
27 // outputs. Technically P2WPKH outputs don't have a redeemscript to be
28 // spent. However, our current IsMine logic requires the corresponding
29 // P2SH-P2WPKH redeemscript to be present in the wallet in order to accept
30 // payment even to P2WPKH outputs.
31 // Also note that having superfluous scripts in the keystore never hurts.
32 // They're only used to guide recursion in signing and IsMine logic - if
33 // a script is present but we can't do anything with it, it has no effect.
34 // "Implicitly" refers to fact that scripts are derived automatically from
35 // existing keys, and are present in memory, even without being explicitly
36 // loaded (e.g. from a file).
37 if (pubkey.IsCompressed()) {
38 CScript script = GetScriptForDestination(WitnessV0KeyHash(key_id));
39 // This does not use AddCScript, as it may be overridden.
40 CScriptID id(script);
41 mapScripts[id] = std::move(script);
42 }
43}
44
45bool CBasicKeyStore::GetPubKey(const CKeyID& address, CPubKey& vchPubKeyOut) const
46{

Callers

nothing calls this directly

Calls 5

GetScriptForDestinationFunction · 0.85
WitnessV0KeyHashClass · 0.85
GetIDMethod · 0.45
countMethod · 0.45
IsCompressedMethod · 0.45

Tested by

no test coverage detected