Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction.cpp
Show First 20 Lines • Show All 1,052 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
}, | }, | ||||
{"maxfeerate", RPCArg::Type::AMOUNT, | {"maxfeerate", RPCArg::Type::AMOUNT, | ||||
/* default */ | /* default */ | ||||
FormatMoney(DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK()), | FormatMoney(DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK()), | ||||
"Reject transactions whose fee rate is higher than the specified " | "Reject transactions whose fee rate is higher than the specified " | ||||
"value, expressed in " + | "value, expressed in " + | ||||
Currency::get().ticker + "/kB\n"}, | Currency::get().ticker + "/kB\n"}, | ||||
}, | }, | ||||
RPCResult{RPCResult::Type::ARR, | RPCResult{ | ||||
RPCResult::Type::ARR, | |||||
"", | "", | ||||
"The result of the mempool acceptance test for each raw " | "The result of the mempool acceptance test for each raw " | ||||
"transaction in the input array.\n" | "transaction in the input array.\n" | ||||
"Length is exactly one for now.", | "Length is exactly one for now.", | ||||
{ | { | ||||
{RPCResult::Type::OBJ, | {RPCResult::Type::OBJ, | ||||
"", | "", | ||||
"", | "", | ||||
{ | { | ||||
{RPCResult::Type::STR_HEX, "txid", | {RPCResult::Type::STR_HEX, "txid", | ||||
"The transaction hash in hex"}, | "The transaction hash in hex"}, | ||||
{RPCResult::Type::BOOL, "allowed", | {RPCResult::Type::BOOL, "allowed", | ||||
"If the mempool allows this tx to be inserted"}, | "If the mempool allows this tx to be inserted"}, | ||||
{RPCResult::Type::NUM, "size", "The transaction size"}, | |||||
{RPCResult::Type::OBJ, | |||||
"fees", | |||||
"Transaction fees (only present if 'allowed' is true)", | |||||
{ | |||||
{RPCResult::Type::STR_AMOUNT, "base", | |||||
"transaction fee in " + Currency::get().ticker}, | |||||
}}, | |||||
{RPCResult::Type::STR, "reject-reason", | {RPCResult::Type::STR, "reject-reason", | ||||
"Rejection string (only present when 'allowed' is " | "Rejection string (only present when 'allowed' is " | ||||
"false)"}, | "false)"}, | ||||
}}, | }}, | ||||
}}, | }}, | ||||
RPCExamples{ | RPCExamples{ | ||||
"\nCreate a transaction\n" + | "\nCreate a transaction\n" + | ||||
HelpExampleCli( | HelpExampleCli( | ||||
"createrawtransaction", | "createrawtransaction", | ||||
"\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" " | "\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" " | ||||
"\"{\\\"myaddress\\\":10000}\"") + | "\"{\\\"myaddress\\\":10000}\"") + | ||||
"Sign the transaction, and get back the hex\n" + | "Sign the transaction, and get back the hex\n" + | ||||
HelpExampleCli("signrawtransactionwithwallet", "\"myhex\"") + | HelpExampleCli("signrawtransactionwithwallet", "\"myhex\"") + | ||||
Show All 34 Lines | static UniValue testmempoolaccept(const Config &config, | ||||
Amount max_raw_tx_fee = max_raw_tx_fee_rate.GetFee(virtual_size); | Amount max_raw_tx_fee = max_raw_tx_fee_rate.GetFee(virtual_size); | ||||
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; | ||||
Amount fee; | |||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
test_accept_res = AcceptToMemoryPool( | test_accept_res = AcceptToMemoryPool( | ||||
config, 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 */, &fee); | ||||
} | } | ||||
result_0.pushKV("allowed", test_accept_res); | result_0.pushKV("allowed", test_accept_res); | ||||
if (!test_accept_res) { | |||||
// Only return the fee and size if the transaction would pass ATMP. | |||||
// These can be used to calculate the feerate. | |||||
if (test_accept_res) { | |||||
result_0.pushKV("size", virtual_size); | |||||
UniValue fees(UniValue::VOBJ); | |||||
fees.pushKV("base", fee); | |||||
result_0.pushKV("fees", fees); | |||||
} else { | |||||
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 { | ||||
result_0.pushKV("reject-reason", | result_0.pushKV("reject-reason", | ||||
strprintf("%s", state.GetRejectReason())); | strprintf("%s", state.GetRejectReason())); | ||||
} | } | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 1,022 Lines • Show Last 20 Lines |