| 175 | } |
| 176 | |
| 177 | CKeyID GetKeyForDestination(const CKeyStore& store, const CTxDestination& dest) |
| 178 | { |
| 179 | // Only supports destinations which map to single public keys, i.e. P2PKH, |
| 180 | // P2WPKH, and P2SH-P2WPKH. |
| 181 | if (auto id = boost::get<CKeyID>(&dest)) { |
| 182 | return *id; |
| 183 | } |
| 184 | if (auto witness_id = boost::get<WitnessV0KeyHash>(&dest)) { |
| 185 | return CKeyID(*witness_id); |
| 186 | } |
| 187 | if (auto script_id = boost::get<CScriptID>(&dest)) { |
| 188 | CScript script; |
| 189 | CTxDestination inner_dest; |
| 190 | if (store.GetCScript(*script_id, script) && ExtractDestination(script, inner_dest)) { |
| 191 | if (auto inner_witness_id = boost::get<WitnessV0KeyHash>(&inner_dest)) { |
| 192 | return CKeyID(*inner_witness_id); |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | return CKeyID(); |
| 197 | } |
| 198 | |
| 199 | bool HaveKey(const CKeyStore& store, const CKey& key) |
| 200 | { |
no test coverage detected