Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction.cpp
Show First 20 Lines • Show All 703 Lines • ▼ Show 20 Lines | static UniValue combinerawtransaction(const Config &config, | ||||
// mergedTx will end up with all the signatures; it | // mergedTx will end up with all the signatures; it | ||||
// starts as a clone of the rawtx: | // starts as a clone of the rawtx: | ||||
CMutableTransaction mergedTx(txVariants[0]); | CMutableTransaction mergedTx(txVariants[0]); | ||||
// Fetch previous transactions (inputs): | // Fetch previous transactions (inputs): | ||||
CCoinsView viewDummy; | CCoinsView viewDummy; | ||||
CCoinsViewCache view(&viewDummy); | CCoinsViewCache view(&viewDummy); | ||||
{ | { | ||||
const CTxMemPool &mempool = EnsureMemPool(); | |||||
LOCK(cs_main); | LOCK(cs_main); | ||||
LOCK(g_mempool.cs); | LOCK(mempool.cs); | ||||
CCoinsViewCache &viewChain = ::ChainstateActive().CoinsTip(); | CCoinsViewCache &viewChain = ::ChainstateActive().CoinsTip(); | ||||
CCoinsViewMemPool viewMempool(&viewChain, g_mempool); | CCoinsViewMemPool viewMempool(&viewChain, mempool); | ||||
// temporarily switch cache backend to db+mempool view | // temporarily switch cache backend to db+mempool view | ||||
view.SetBackend(viewMempool); | view.SetBackend(viewMempool); | ||||
for (const CTxIn &txin : mergedTx.vin) { | for (const CTxIn &txin : mergedTx.vin) { | ||||
// Load entries from viewChain into view; can fail. | // Load entries from viewChain into view; can fail. | ||||
view.AccessCoin(txin.prevout); | view.AccessCoin(txin.prevout); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | static UniValue signrawtransactionwithkey(const Config &config, | ||||
} | } | ||||
// Fetch previous transactions (inputs): | // Fetch previous transactions (inputs): | ||||
std::map<COutPoint, Coin> coins; | std::map<COutPoint, Coin> coins; | ||||
for (const CTxIn &txin : mtx.vin) { | for (const CTxIn &txin : mtx.vin) { | ||||
// Create empty map entry keyed by prevout. | // Create empty map entry keyed by prevout. | ||||
coins[txin.prevout]; | coins[txin.prevout]; | ||||
} | } | ||||
FindCoins(coins); | FindCoins(*g_rpc_node, coins); | ||||
// Parse the prevtxs array | // Parse the prevtxs array | ||||
ParsePrevouts(request.params[2], &keystore, coins); | ParsePrevouts(request.params[2], &keystore, coins); | ||||
UniValue result(UniValue::VOBJ); | UniValue result(UniValue::VOBJ); | ||||
SignTransaction(mtx, &keystore, coins, request.params[3], result); | SignTransaction(mtx, &keystore, coins, request.params[3], result); | ||||
return result; | return result; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | if (request.params[1].isBool()) { | ||||
"no longer supports a boolean. To allow a " | "no longer supports a boolean. To allow a " | ||||
"transaction with high fees, set maxfeerate to 0."); | "transaction with high fees, set maxfeerate to 0."); | ||||
} else if (!request.params[1].isNull()) { | } else if (!request.params[1].isNull()) { | ||||
size_t sz = tx->GetTotalSize(); | size_t sz = tx->GetTotalSize(); | ||||
CFeeRate fr(AmountFromValue(request.params[1])); | CFeeRate fr(AmountFromValue(request.params[1])); | ||||
max_raw_tx_fee = fr.GetFee(sz); | max_raw_tx_fee = fr.GetFee(sz); | ||||
} | } | ||||
CTxMemPool &mempool = EnsureMemPool(); | |||||
UniValue result(UniValue::VARR); | UniValue result(UniValue::VARR); | ||||
UniValue result_0(UniValue::VOBJ); | UniValue result_0(UniValue::VOBJ); | ||||
result_0.pushKV("txid", txid.GetHex()); | result_0.pushKV("txid", txid.GetHex()); | ||||
TxValidationState state; | TxValidationState state; | ||||
bool test_accept_res; | bool test_accept_res; | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
test_accept_res = AcceptToMemoryPool( | test_accept_res = AcceptToMemoryPool( | ||||
config, g_mempool, state, std::move(tx), false /* bypass_limits */, | config, mempool, state, std::move(tx), false /* bypass_limits */, | ||||
max_raw_tx_fee, true /* test_accept */); | max_raw_tx_fee, true /* test_accept */); | ||||
} | } | ||||
result_0.pushKV("allowed", test_accept_res); | result_0.pushKV("allowed", test_accept_res); | ||||
if (!test_accept_res) { | if (!test_accept_res) { | ||||
if (state.IsInvalid()) { | if (state.IsInvalid()) { | ||||
if (state.GetResult() == TxValidationResult::TX_MISSING_INPUTS) { | if (state.GetResult() == TxValidationResult::TX_MISSING_INPUTS) { | ||||
result_0.pushKV("reject-reason", "missing-inputs"); | result_0.pushKV("reject-reason", "missing-inputs"); | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 659 Lines • ▼ Show 20 Lines | UniValue utxoupdatepsbt(const Config &config, const JSONRPCRequest &request) { | ||||
// precaution. | // precaution. | ||||
HidingSigningProvider public_provider(&provider, /* nosign */ true, | HidingSigningProvider public_provider(&provider, /* nosign */ true, | ||||
/* nobip32derivs */ false); | /* nobip32derivs */ false); | ||||
// Fetch previous transactions (inputs): | // Fetch previous transactions (inputs): | ||||
CCoinsView viewDummy; | CCoinsView viewDummy; | ||||
CCoinsViewCache view(&viewDummy); | CCoinsViewCache view(&viewDummy); | ||||
{ | { | ||||
LOCK2(cs_main, g_mempool.cs); | const CTxMemPool &mempool = EnsureMemPool(); | ||||
LOCK2(cs_main, mempool.cs); | |||||
CCoinsViewCache &viewChain = ::ChainstateActive().CoinsTip(); | CCoinsViewCache &viewChain = ::ChainstateActive().CoinsTip(); | ||||
CCoinsViewMemPool viewMempool(&viewChain, g_mempool); | CCoinsViewMemPool viewMempool(&viewChain, mempool); | ||||
// temporarily switch cache backend to db+mempool view | // temporarily switch cache backend to db+mempool view | ||||
view.SetBackend(viewMempool); | view.SetBackend(viewMempool); | ||||
for (const CTxIn &txin : psbtx.tx->vin) { | for (const CTxIn &txin : psbtx.tx->vin) { | ||||
// Load entries from viewChain into view; can fail. | // Load entries from viewChain into view; can fail. | ||||
view.AccessCoin(txin.prevout); | view.AccessCoin(txin.prevout); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 272 Lines • Show Last 20 Lines |