| 18 | } |
| 19 | |
| 20 | void 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 | |
| 45 | bool CBasicKeyStore::GetPubKey(const CKeyID& address, CPubKey& vchPubKeyOut) const |
| 46 | { |
nothing calls this directly
no test coverage detected