Changeset View
Changeset View
Standalone View
Standalone View
src/script/sign.cpp
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | static bool GetCScript(const SigningProvider &provider, | ||||
// Look for scripts in SignatureData | // Look for scripts in SignatureData | ||||
if (CScriptID(sigdata.redeem_script) == scriptid) { | if (CScriptID(sigdata.redeem_script) == scriptid) { | ||||
script = sigdata.redeem_script; | script = sigdata.redeem_script; | ||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
static bool GetPubKey(const SigningProvider &provider, | static bool GetPubKey(const SigningProvider &provider, SignatureData &sigdata, | ||||
const SignatureData &sigdata, const CKeyID &address, | const CKeyID &address, CPubKey &pubkey) { | ||||
CPubKey &pubkey) { | |||||
if (provider.GetPubKey(address, pubkey)) { | if (provider.GetPubKey(address, pubkey)) { | ||||
sigdata.misc_pubkeys.emplace(pubkey.GetID(), pubkey); | |||||
return true; | return true; | ||||
} | } | ||||
// Look for pubkey in all partial sigs | // Look for pubkey in all partial sigs | ||||
const auto it = sigdata.signatures.find(address); | const auto it = sigdata.signatures.find(address); | ||||
if (it != sigdata.signatures.end()) { | if (it != sigdata.signatures.end()) { | ||||
pubkey = it->second.first; | pubkey = it->second.first; | ||||
return true; | return true; | ||||
} | } | ||||
// Look for pubkey in pubkey list | |||||
const auto &pk_it = sigdata.misc_pubkeys.find(address); | |||||
if (pk_it != sigdata.misc_pubkeys.end()) { | |||||
pubkey = pk_it->second; | |||||
return true; | |||||
} | |||||
return false; | return false; | ||||
} | } | ||||
static bool CreateSig(const BaseSignatureCreator &creator, | static bool CreateSig(const BaseSignatureCreator &creator, | ||||
SignatureData &sigdata, const SigningProvider &provider, | SignatureData &sigdata, const SigningProvider &provider, | ||||
std::vector<uint8_t> &sig_out, const CKeyID &keyid, | std::vector<uint8_t> &sig_out, const CKeyID &keyid, | ||||
const CScript &scriptcode) { | const CScript &scriptcode) { | ||||
const auto it = sigdata.signatures.find(keyid); | const auto it = sigdata.signatures.find(keyid); | ||||
if (it != sigdata.signatures.end()) { | if (it != sigdata.signatures.end()) { | ||||
sig_out = it->second.second; | sig_out = it->second.second; | ||||
return true; | return true; | ||||
} | } | ||||
if (creator.CreateSig(provider, sig_out, keyid, scriptcode)) { | |||||
CPubKey pubkey; | CPubKey pubkey; | ||||
GetPubKey(provider, sigdata, keyid, pubkey); | GetPubKey(provider, sigdata, keyid, pubkey); | ||||
if (creator.CreateSig(provider, sig_out, keyid, scriptcode)) { | |||||
auto i = sigdata.signatures.emplace(keyid, SigPair(pubkey, sig_out)); | auto i = sigdata.signatures.emplace(keyid, SigPair(pubkey, sig_out)); | ||||
assert(i.second); | assert(i.second); | ||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 328 Lines • Show Last 20 Lines |