Changeset View
Changeset View
Standalone View
Standalone View
src/script/sign.cpp
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | static bool SignStep(const SigningProvider &provider, | ||||
const CScript &scriptPubKey, std::vector<valtype> &ret, | const CScript &scriptPubKey, std::vector<valtype> &ret, | ||||
txnouttype &whichTypeRet, SignatureData &sigdata) { | txnouttype &whichTypeRet, SignatureData &sigdata) { | ||||
CScript scriptRet; | CScript scriptRet; | ||||
uint160 h160; | uint160 h160; | ||||
ret.clear(); | ret.clear(); | ||||
std::vector<uint8_t> sig; | std::vector<uint8_t> sig; | ||||
std::vector<valtype> vSolutions; | std::vector<valtype> vSolutions; | ||||
if (!Solver(scriptPubKey, whichTypeRet, vSolutions)) { | whichTypeRet = Solver(scriptPubKey, vSolutions); | ||||
return false; | |||||
} | |||||
switch (whichTypeRet) { | switch (whichTypeRet) { | ||||
case TX_NONSTANDARD: | case TX_NONSTANDARD: | ||||
case TX_NULL_DATA: | case TX_NULL_DATA: | ||||
return false; | return false; | ||||
case TX_PUBKEY: | case TX_PUBKEY: | ||||
if (!CreateSig(creator, sigdata, provider, sig, | if (!CreateSig(creator, sigdata, provider, sig, | ||||
CPubKey(vSolutions[0]).GetID(), scriptPubKey)) { | CPubKey(vSolutions[0]).GetID(), scriptPubKey)) { | ||||
▲ Show 20 Lines • Show All 179 Lines • ▼ Show 20 Lines | SignatureData DataFromTransaction(const CMutableTransaction &tx, | ||||
SignatureExtractorChecker extractor_checker(data, tx_checker); | SignatureExtractorChecker extractor_checker(data, tx_checker); | ||||
if (VerifyScript(data.scriptSig, txout.scriptPubKey, | if (VerifyScript(data.scriptSig, txout.scriptPubKey, | ||||
STANDARD_SCRIPT_VERIFY_FLAGS, extractor_checker)) { | STANDARD_SCRIPT_VERIFY_FLAGS, extractor_checker)) { | ||||
data.complete = true; | data.complete = true; | ||||
return data; | return data; | ||||
} | } | ||||
// Get scripts | // Get scripts | ||||
txnouttype script_type; | |||||
std::vector<std::vector<uint8_t>> solutions; | std::vector<std::vector<uint8_t>> solutions; | ||||
Solver(txout.scriptPubKey, script_type, solutions); | txnouttype script_type = Solver(txout.scriptPubKey, solutions); | ||||
CScript next_script = txout.scriptPubKey; | CScript next_script = txout.scriptPubKey; | ||||
if (script_type == TX_SCRIPTHASH && !stack.script.empty() && | if (script_type == TX_SCRIPTHASH && !stack.script.empty() && | ||||
!stack.script.back().empty()) { | !stack.script.back().empty()) { | ||||
// Get the redeemScript | // Get the redeemScript | ||||
CScript redeem_script(stack.script.back().begin(), | CScript redeem_script(stack.script.back().begin(), | ||||
stack.script.back().end()); | stack.script.back().end()); | ||||
data.redeem_script = redeem_script; | data.redeem_script = redeem_script; | ||||
next_script = std::move(redeem_script); | next_script = std::move(redeem_script); | ||||
// Get redeemScript type | // Get redeemScript type | ||||
Solver(next_script, script_type, solutions); | script_type = Solver(next_script, solutions); | ||||
stack.script.pop_back(); | stack.script.pop_back(); | ||||
} | } | ||||
if (script_type == TX_MULTISIG && !stack.script.empty()) { | if (script_type == TX_MULTISIG && !stack.script.empty()) { | ||||
// Build a map of pubkey -> signature by matching sigs to pubkeys: | // Build a map of pubkey -> signature by matching sigs to pubkeys: | ||||
assert(solutions.size() > 1); | assert(solutions.size() > 1); | ||||
unsigned int num_pubkeys = solutions.size() - 2; | unsigned int num_pubkeys = solutions.size() - 2; | ||||
unsigned int last_success_key = 0; | unsigned int last_success_key = 0; | ||||
for (const valtype &sig : stack.script) { | for (const valtype &sig : stack.script) { | ||||
▲ Show 20 Lines • Show All 305 Lines • Show Last 20 Lines |