MCPcopy Create free account
hub / github.com/LUX-Core/lux / GetKeyForDestination

Function GetKeyForDestination

src/keystore.cpp:182–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182CKeyID 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}

Callers 3

validateaddressFunction · 0.85
dumpprivkeyFunction · 0.85
AddrToPubKeyFunction · 0.85

Calls 3

ExtractDestinationFunction · 0.85
GetCScriptMethod · 0.80
CKeyIDClass · 0.70

Tested by

no test coverage detected