Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction.cpp
Show First 20 Lines • Show All 940 Lines • ▼ Show 20 Lines | if (!prevTxsUnival.isNull()) { | ||||
std::vector<uint8_t> rsData(ParseHexV(v, "redeemScript")); | std::vector<uint8_t> rsData(ParseHexV(v, "redeemScript")); | ||||
CScript redeemScript(rsData.begin(), rsData.end()); | CScript redeemScript(rsData.begin(), rsData.end()); | ||||
keystore->AddCScript(redeemScript); | keystore->AddCScript(redeemScript); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
SigHashType sigHashType = SigHashType().withForkId(); | SigHashType sigHashType = ParseSighashString(hashType); | ||||
if (!hashType.isNull()) { | |||||
static std::map<std::string, int> mapSigHashValues = { | |||||
{"ALL", SIGHASH_ALL}, | |||||
{"ALL|ANYONECANPAY", SIGHASH_ALL | SIGHASH_ANYONECANPAY}, | |||||
{"ALL|FORKID", SIGHASH_ALL | SIGHASH_FORKID}, | |||||
{"ALL|FORKID|ANYONECANPAY", | |||||
SIGHASH_ALL | SIGHASH_FORKID | SIGHASH_ANYONECANPAY}, | |||||
{"NONE", SIGHASH_NONE}, | |||||
{"NONE|ANYONECANPAY", SIGHASH_NONE | SIGHASH_ANYONECANPAY}, | |||||
{"NONE|FORKID", SIGHASH_NONE | SIGHASH_FORKID}, | |||||
{"NONE|FORKID|ANYONECANPAY", | |||||
SIGHASH_NONE | SIGHASH_FORKID | SIGHASH_ANYONECANPAY}, | |||||
{"SINGLE", SIGHASH_SINGLE}, | |||||
{"SINGLE|ANYONECANPAY", SIGHASH_SINGLE | SIGHASH_ANYONECANPAY}, | |||||
{"SINGLE|FORKID", SIGHASH_SINGLE | SIGHASH_FORKID}, | |||||
{"SINGLE|FORKID|ANYONECANPAY", | |||||
SIGHASH_SINGLE | SIGHASH_FORKID | SIGHASH_ANYONECANPAY}, | |||||
}; | |||||
std::string strHashType = hashType.get_str(); | |||||
if (!mapSigHashValues.count(strHashType)) { | |||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid sighash param"); | |||||
} | |||||
sigHashType = SigHashType(mapSigHashValues[strHashType]); | |||||
if (!sigHashType.hasForkId()) { | if (!sigHashType.hasForkId()) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"Signature must use SIGHASH_FORKID"); | "Signature must use SIGHASH_FORKID"); | ||||
} | } | ||||
} | |||||
// Script verification errors. | // Script verification errors. | ||||
UniValue vErrors(UniValue::VARR); | UniValue vErrors(UniValue::VARR); | ||||
// Use CTransaction for the constant parts of the transaction to avoid | // Use CTransaction for the constant parts of the transaction to avoid | ||||
// rehashing. | // rehashing. | ||||
const CTransaction txConst(mtx); | const CTransaction txConst(mtx); | ||||
// Sign what we can: | // Sign what we can: | ||||
Show All 23 Lines | for (size_t i = 0; i < mtx.vin.size(); i++) { | ||||
ScriptError serror = ScriptError::OK; | ScriptError serror = ScriptError::OK; | ||||
if (!VerifyScript( | if (!VerifyScript( | ||||
txin.scriptSig, prevPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, | txin.scriptSig, prevPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, | ||||
TransactionSignatureChecker(&txConst, i, amount), &serror)) { | TransactionSignatureChecker(&txConst, i, amount), &serror)) { | ||||
if (serror == ScriptError::INVALID_STACK_OPERATION) { | if (serror == ScriptError::INVALID_STACK_OPERATION) { | ||||
// Unable to sign input and verification failed (possible | // Unable to sign input and verification failed (possible | ||||
// attempt to partially sign). | // attempt to partially sign). | ||||
TxInErrorToJSON(txin, vErrors, | TxInErrorToJSON(txin, vErrors, | ||||
"Unable to sign input, invalid " | "Unable to sign input, invalid stack size " | ||||
"stack size (possibly missing " | "(possibly missing key)"); | ||||
"key)"); | |||||
} else { | } else { | ||||
TxInErrorToJSON(txin, vErrors, ScriptErrorString(serror)); | TxInErrorToJSON(txin, vErrors, ScriptErrorString(serror)); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
bool fComplete = vErrors.empty(); | bool fComplete = vErrors.empty(); | ||||
▲ Show 20 Lines • Show All 931 Lines • Show Last 20 Lines |