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(); | const CTxMemPool &mempool = EnsureMemPool(request.context); | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
LOCK(mempool.cs); | LOCK(mempool.cs); | ||||
CCoinsViewCache &viewChain = ::ChainstateActive().CoinsTip(); | CCoinsViewCache &viewChain = ::ChainstateActive().CoinsTip(); | ||||
CCoinsViewMemPool viewMempool(&viewChain, 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) { | ||||
▲ Show 20 Lines • Show All 148 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(*g_rpc_node, coins); | NodeContext &node = EnsureNodeContext(request.context); | ||||
FindCoins(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 54 Lines • ▼ Show 20 Lines | if (request.params[1].isBool()) { | ||||
"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); | ||||
} | } | ||||
std::string err_string; | std::string err_string; | ||||
AssertLockNotHeld(cs_main); | AssertLockNotHeld(cs_main); | ||||
NodeContext &node = EnsureNodeContext(request.context); | |||||
const TransactionError err = BroadcastTransaction( | const TransactionError err = BroadcastTransaction( | ||||
*g_rpc_node, config, tx, err_string, max_raw_tx_fee, /*relay*/ true, | node, config, tx, err_string, max_raw_tx_fee, /*relay*/ true, | ||||
/*wait_callback*/ true); | /*wait_callback*/ true); | ||||
if (err != TransactionError::OK) { | if (err != TransactionError::OK) { | ||||
throw JSONRPCTransactionError(err, err_string); | throw JSONRPCTransactionError(err, err_string); | ||||
} | } | ||||
return tx->GetHash().GetHex(); | return tx->GetHash().GetHex(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 78 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(); | CTxMemPool &mempool = EnsureMemPool(request.context); | ||||
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; | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 670 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); | ||||
{ | { | ||||
const CTxMemPool &mempool = EnsureMemPool(); | const CTxMemPool &mempool = EnsureMemPool(request.context); | ||||
LOCK2(cs_main, mempool.cs); | LOCK2(cs_main, mempool.cs); | ||||
CCoinsViewCache &viewChain = ::ChainstateActive().CoinsTip(); | CCoinsViewCache &viewChain = ::ChainstateActive().CoinsTip(); | ||||
CCoinsViewMemPool viewMempool(&viewChain, 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. | ||||
▲ Show 20 Lines • Show All 275 Lines • Show Last 20 Lines |