Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction.cpp
Show First 20 Lines • Show All 859 Lines • ▼ Show 20 Lines | CCoinsViewCache view(&viewDummy); | ||||
view.SetBackend(viewDummy); | view.SetBackend(viewDummy); | ||||
} | } | ||||
bool fGivenKeys = false; | bool fGivenKeys = false; | ||||
CBasicKeyStore tempKeystore; | CBasicKeyStore tempKeystore; | ||||
if (request.params.size() > 2 && !request.params[2].isNull()) { | if (request.params.size() > 2 && !request.params[2].isNull()) { | ||||
fGivenKeys = true; | fGivenKeys = true; | ||||
UniValue keys = request.params[2].get_array(); | UniValue keys = request.params[2].get_array(); | ||||
for (unsigned int idx = 0; idx < keys.size(); idx++) { | for (size_t idx = 0; idx < keys.size(); idx++) { | ||||
UniValue k = keys[idx]; | UniValue k = keys[idx]; | ||||
CBitcoinSecret vchSecret; | CBitcoinSecret vchSecret; | ||||
bool fGood = vchSecret.SetString(k.get_str()); | bool fGood = vchSecret.SetString(k.get_str()); | ||||
if (!fGood) { | if (!fGood) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Invalid private key"); | "Invalid private key"); | ||||
} | } | ||||
Show All 9 Lines | #ifdef ENABLE_WALLET | ||||
} else if (pwalletMain) { | } else if (pwalletMain) { | ||||
EnsureWalletIsUnlocked(); | EnsureWalletIsUnlocked(); | ||||
#endif | #endif | ||||
} | } | ||||
// Add previous txouts given in the RPC call: | // Add previous txouts given in the RPC call: | ||||
if (request.params.size() > 1 && !request.params[1].isNull()) { | if (request.params.size() > 1 && !request.params[1].isNull()) { | ||||
UniValue prevTxs = request.params[1].get_array(); | UniValue prevTxs = request.params[1].get_array(); | ||||
for (unsigned int idx = 0; idx < prevTxs.size(); idx++) { | for (size_t idx = 0; idx < prevTxs.size(); idx++) { | ||||
const UniValue &p = prevTxs[idx]; | const UniValue &p = prevTxs[idx]; | ||||
if (!p.isObject()) { | if (!p.isObject()) { | ||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, | throw JSONRPCError(RPC_DESERIALIZATION_ERROR, | ||||
"expected object with " | "expected object with " | ||||
"{\"txid'\",\"vout\",\"scriptPubKey\"}"); | "{\"txid'\",\"vout\",\"scriptPubKey\"}"); | ||||
} | } | ||||
UniValue prevOut = p.get_obj(); | UniValue prevOut = p.get_obj(); | ||||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < mergedTx.vin.size(); i++) { | ||||
prevPubKey, | prevPubKey, | ||||
TransactionSignatureChecker(&txConst, i, amount), sigdata, | TransactionSignatureChecker(&txConst, i, amount), sigdata, | ||||
DataFromTransaction(txv, i)); | DataFromTransaction(txv, i)); | ||||
} | } | ||||
} | } | ||||
UpdateTransaction(mergedTx, i, sigdata); | UpdateTransaction(mergedTx, i, sigdata); | ||||
ScriptError serror = SCRIPT_ERR_OK; | // Because we do not know if forkid is used or not, we just try both. | ||||
if (!VerifyScript( | // TODO: Remove after the Hard Fork. | ||||
txin.scriptSig, prevPubKey, | ScriptError serror0 = SCRIPT_ERR_OK; | ||||
STANDARD_SCRIPT_VERIFY_FLAGS | SCRIPT_ENABLE_SIGHASH_FORKID, | ScriptError serror1 = SCRIPT_ERR_OK; | ||||
TransactionSignatureChecker(&txConst, i, amount), &serror)) { | TransactionSignatureChecker checker(&txConst, i, amount); | ||||
TxInErrorToJSON(txin, vErrors, ScriptErrorString(serror)); | if (!VerifyScript(txin.scriptSig, prevPubKey, | ||||
STANDARD_SCRIPT_VERIFY_FLAGS | | |||||
SCRIPT_ENABLE_SIGHASH_FORKID, | |||||
checker, &serror0) && | |||||
!VerifyScript(txin.scriptSig, prevPubKey, | |||||
STANDARD_SCRIPT_VERIFY_FLAGS, checker, &serror1)) { | |||||
std::string error; | |||||
error += ScriptErrorString(serror0); | |||||
error += " "; | |||||
error += ScriptErrorString(serror1); | |||||
TxInErrorToJSON(txin, vErrors, error); | |||||
} | } | ||||
} | } | ||||
bool fComplete = vErrors.empty(); | bool fComplete = vErrors.empty(); | ||||
UniValue result(UniValue::VOBJ); | UniValue result(UniValue::VOBJ); | ||||
result.push_back(Pair("hex", EncodeHexTx(mergedTx))); | result.push_back(Pair("hex", EncodeHexTx(mergedTx))); | ||||
result.push_back(Pair("complete", fComplete)); | result.push_back(Pair("complete", fComplete)); | ||||
▲ Show 20 Lines • Show All 121 Lines • Show Last 20 Lines |