Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction_util.cpp
Show First 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | static void TxInErrorToJSON(const CTxIn &txin, UniValue &vErrorsRet, | ||||
entry.pushKV("vout", uint64_t(txin.prevout.GetN())); | entry.pushKV("vout", uint64_t(txin.prevout.GetN())); | ||||
entry.pushKV("scriptSig", | entry.pushKV("scriptSig", | ||||
HexStr(txin.scriptSig.begin(), txin.scriptSig.end())); | HexStr(txin.scriptSig.begin(), txin.scriptSig.end())); | ||||
entry.pushKV("sequence", uint64_t(txin.nSequence)); | entry.pushKV("sequence", uint64_t(txin.nSequence)); | ||||
entry.pushKV("error", strMessage); | entry.pushKV("error", strMessage); | ||||
vErrorsRet.push_back(entry); | vErrorsRet.push_back(entry); | ||||
} | } | ||||
// TODO(https://github.com/bitcoin/bitcoin/pull/10973#discussion_r267084237): | UniValue SignTransaction(CMutableTransaction &mtx, | ||||
// This function is called from both wallet and node rpcs | |||||
// (signrawtransactionwithwallet and signrawtransactionwithkey). It should be | |||||
// moved to a util file so wallet code doesn't need to link against node code. | |||||
// Also the dependency on interfaces::Chain should be removed, so | |||||
// signrawtransactionwithkey doesn't need access to a Chain instance. | |||||
UniValue SignTransaction(interfaces::Chain &chain, CMutableTransaction &mtx, | |||||
const UniValue &prevTxsUnival, | const UniValue &prevTxsUnival, | ||||
CBasicKeyStore *keystore, bool is_temp_keystore, | CBasicKeyStore *keystore, | ||||
const UniValue &hashType) { | std::map<COutPoint, Coin> &coins, | ||||
// Fetch previous transactions (inputs): | bool is_temp_keystore, const UniValue &hashType) { | ||||
std::map<COutPoint, Coin> coins; | |||||
for (const CTxIn &txin : mtx.vin) { | |||||
// Create empty map entry keyed by prevout. | |||||
coins[txin.prevout]; | |||||
} | |||||
chain.findCoins(coins); | |||||
// Add previous txouts given in the RPC call: | // Add previous txouts given in the RPC call: | ||||
if (!prevTxsUnival.isNull()) { | if (!prevTxsUnival.isNull()) { | ||||
UniValue prevTxs = prevTxsUnival.get_array(); | UniValue prevTxs = prevTxsUnival.get_array(); | ||||
for (size_t 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 " | ||||
▲ Show 20 Lines • Show All 141 Lines • Show Last 20 Lines |