Changeset View
Changeset View
Standalone View
Standalone View
src/script/sign.cpp
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | if (provider.GetKeyOrigin(keyid, info)) { | ||||
sigdata.misc_pubkeys.emplace(keyid, | sigdata.misc_pubkeys.emplace(keyid, | ||||
std::make_pair(pubkey, std::move(info))); | std::make_pair(pubkey, std::move(info))); | ||||
} | } | ||||
if (creator.CreateSig(provider, sig_out, keyid, scriptcode)) { | 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; | ||||
} | } | ||||
// Could not make signature or signature not found, add keyid to missing | |||||
sigdata.missing_sigs.push_back(keyid); | |||||
return false; | return false; | ||||
} | } | ||||
/** | /** | ||||
* Sign scriptPubKey using signature made with creator. | * Sign scriptPubKey using signature made with creator. | ||||
* Signatures are returned in scriptSigRet (or returns false if scriptPubKey | * Signatures are returned in scriptSigRet (or returns false if scriptPubKey | ||||
* can't be signed), unless whichTypeRet is TX_SCRIPTHASH, in which case | * can't be signed), unless whichTypeRet is TX_SCRIPTHASH, in which case | ||||
* scriptSigRet is the redemption script. | * scriptSigRet is the redemption script. | ||||
Show All 21 Lines | switch (whichTypeRet) { | ||||
return false; | return false; | ||||
} | } | ||||
ret.push_back(std::move(sig)); | ret.push_back(std::move(sig)); | ||||
return true; | return true; | ||||
case TX_PUBKEYHASH: { | case TX_PUBKEYHASH: { | ||||
CKeyID keyID = CKeyID(uint160(vSolutions[0])); | CKeyID keyID = CKeyID(uint160(vSolutions[0])); | ||||
CPubKey pubkey; | CPubKey pubkey; | ||||
if (!provider.GetPubKey(keyID, pubkey)) { | if (!provider.GetPubKey(keyID, pubkey)) { | ||||
// Pubkey could not be found, add to missing | |||||
sigdata.missing_pubkeys.push_back(keyID); | |||||
return false; | return false; | ||||
} | } | ||||
if (!CreateSig(creator, sigdata, provider, sig, pubkey, | if (!CreateSig(creator, sigdata, provider, sig, pubkey, | ||||
scriptPubKey)) { | scriptPubKey)) { | ||||
return false; | return false; | ||||
} | } | ||||
ret.push_back(std::move(sig)); | ret.push_back(std::move(sig)); | ||||
ret.push_back(ToByteVector(pubkey)); | ret.push_back(ToByteVector(pubkey)); | ||||
return true; | return true; | ||||
} | } | ||||
case TX_SCRIPTHASH: | case TX_SCRIPTHASH: | ||||
if (GetCScript(provider, sigdata, uint160(vSolutions[0]), | h160 = uint160(vSolutions[0]); | ||||
scriptRet)) { | if (GetCScript(provider, sigdata, h160, scriptRet)) { | ||||
ret.push_back( | ret.push_back( | ||||
std::vector<uint8_t>(scriptRet.begin(), scriptRet.end())); | std::vector<uint8_t>(scriptRet.begin(), scriptRet.end())); | ||||
return true; | return true; | ||||
} | } | ||||
// Could not find redeemScript, add to missing | |||||
sigdata.missing_redeem_script = h160; | |||||
return false; | return false; | ||||
case TX_MULTISIG: { | case TX_MULTISIG: { | ||||
size_t required = vSolutions.front()[0]; | size_t required = vSolutions.front()[0]; | ||||
// workaround CHECKMULTISIG bug | // workaround CHECKMULTISIG bug | ||||
ret.push_back(valtype()); | ret.push_back(valtype()); | ||||
for (size_t i = 1; i < vSolutions.size() - 1; ++i) { | for (size_t i = 1; i < vSolutions.size() - 1; ++i) { | ||||
CPubKey pubkey = CPubKey(vSolutions[i]); | CPubKey pubkey = CPubKey(vSolutions[i]); | ||||
if (ret.size() < required + 1 && | if (ret.size() < required + 1 && | ||||
▲ Show 20 Lines • Show All 340 Lines • Show Last 20 Lines |