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