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