| 268 | } |
| 269 | |
| 270 | CKeyID GetKeyForDestination(const SigningProvider& store, const CTxDestination& dest) |
| 271 | { |
| 272 | // Only supports destinations which map to single public keys: |
| 273 | // P2PKH, P2WPKH, P2SH-P2WPKH, P2TR |
| 274 | if (auto id = std::get_if<PKHash>(&dest)) { |
| 275 | return ToKeyID(*id); |
| 276 | } |
| 277 | if (auto witness_id = std::get_if<WitnessV0KeyHash>(&dest)) { |
| 278 | return ToKeyID(*witness_id); |
| 279 | } |
| 280 | if (auto script_hash = std::get_if<ScriptHash>(&dest)) { |
| 281 | CScript script; |
| 282 | CScriptID script_id = ToScriptID(*script_hash); |
| 283 | CTxDestination inner_dest; |
| 284 | if (store.GetCScript(script_id, script) && ExtractDestination(script, inner_dest)) { |
| 285 | if (auto inner_witness_id = std::get_if<WitnessV0KeyHash>(&inner_dest)) { |
| 286 | return ToKeyID(*inner_witness_id); |
| 287 | } |
| 288 | } |
| 289 | } |
| 290 | if (auto output_key = std::get_if<WitnessV1Taproot>(&dest)) { |
| 291 | TaprootSpendData spenddata; |
| 292 | CPubKey pub; |
| 293 | if (store.GetTaprootSpendData(*output_key, spenddata) |
| 294 | && !spenddata.internal_key.IsNull() |
| 295 | && spenddata.merkle_root.IsNull() |
| 296 | && store.GetPubKeyByXOnly(spenddata.internal_key, pub)) { |
| 297 | return pub.GetID(); |
| 298 | } |
| 299 | } |
| 300 | return CKeyID(); |
| 301 | } |
| 302 | |
| 303 | void MultiSigningProvider::AddProvider(std::unique_ptr<SigningProvider> provider) |
| 304 | { |
no test coverage detected