Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction.cpp
Show First 20 Lines • Show All 926 Lines • ▼ Show 20 Lines | static UniValue sendrawtransaction(const Config &config, | ||||
Amount max_raw_tx_fee = DEFAULT_MAX_RAW_TX_FEE; | Amount max_raw_tx_fee = DEFAULT_MAX_RAW_TX_FEE; | ||||
// TODO: temporary migration code for old clients. Remove in v0.22 | // TODO: temporary migration code for old clients. Remove in v0.22 | ||||
if (request.params[1].isBool()) { | if (request.params[1].isBool()) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"Second argument must be numeric (maxfeerate) and " | "Second argument must be numeric (maxfeerate) and " | ||||
"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].isNum()) { | } 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); | ||||
} else if (!request.params[1].isNull()) { | |||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | |||||
"second argument (maxfeerate) must be numeric"); | |||||
} | } | ||||
std::string err_string; | std::string err_string; | ||||
AssertLockNotHeld(cs_main); | AssertLockNotHeld(cs_main); | ||||
const TransactionError err = BroadcastTransaction( | const TransactionError err = BroadcastTransaction( | ||||
*g_rpc_node, config, tx, err_string, max_raw_tx_fee, /*relay*/ true, | *g_rpc_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); | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | static UniValue testmempoolaccept(const Config &config, | ||||
Amount max_raw_tx_fee = DEFAULT_MAX_RAW_TX_FEE; | Amount max_raw_tx_fee = DEFAULT_MAX_RAW_TX_FEE; | ||||
// TODO: temporary migration code for old clients. Remove in v0.20 | // TODO: temporary migration code for old clients. Remove in v0.20 | ||||
if (request.params[1].isBool()) { | if (request.params[1].isBool()) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"Second argument must be numeric (maxfeerate) and " | "Second argument must be numeric (maxfeerate) and " | ||||
"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].isNum()) { | } 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); | ||||
} else if (!request.params[1].isNull()) { | |||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | |||||
"second argument (maxfeerate) must be numeric"); | |||||
} | } | ||||
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 962 Lines • Show Last 20 Lines |