Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 2,820 Lines • ▼ Show 20 Lines | static UniValue settxfee(const Config &config, const JSONRPCRequest &request) { | ||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"settxfee", | "settxfee", | ||||
"Set the transaction fee per kB for this wallet. Overrides the " | "Set the transaction fee per kB for this wallet. Overrides the " | ||||
"global -paytxfee command line parameter.\n", | "global -paytxfee command line parameter.\n" | ||||
"Can be deactivated by passing 0 as the fee. In that case automatic " | |||||
"fee selection will be used by default.\n", | |||||
{ | { | ||||
{"amount", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, | {"amount", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, | ||||
"The transaction fee in " + CURRENCY_UNIT + "/kB"}, | "The transaction fee in " + CURRENCY_UNIT + "/kB"}, | ||||
}, | }, | ||||
RPCResult{RPCResult::Type::BOOL, "", "Returns true if successful"}, | RPCResult{RPCResult::Type::BOOL, "", "Returns true if successful"}, | ||||
RPCExamples{HelpExampleCli("settxfee", "0.00001") + | RPCExamples{HelpExampleCli("settxfee", "0.00001") + | ||||
HelpExampleRpc("settxfee", "0.00001")}, | HelpExampleRpc("settxfee", "0.00001")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
Amount nAmount = AmountFromValue(request.params[0]); | Amount nAmount = AmountFromValue(request.params[0]); | ||||
CFeeRate tx_fee_rate(nAmount, 1000); | CFeeRate tx_fee_rate(nAmount, 1000); | ||||
CFeeRate max_tx_fee_rate(pwallet->m_default_max_tx_fee, 1000); | |||||
if (tx_fee_rate == CFeeRate()) { | if (tx_fee_rate == CFeeRate()) { | ||||
// automatic selection | // automatic selection | ||||
} else if (tx_fee_rate < pwallet->chain().relayMinFee()) { | } else if (tx_fee_rate < pwallet->chain().relayMinFee()) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_PARAMETER, | RPC_INVALID_PARAMETER, | ||||
strprintf("txfee cannot be less than min relay tx fee (%s)", | strprintf("txfee cannot be less than min relay tx fee (%s)", | ||||
pwallet->chain().relayMinFee().ToString())); | pwallet->chain().relayMinFee().ToString())); | ||||
} else if (tx_fee_rate < pwallet->m_min_fee) { | } else if (tx_fee_rate < pwallet->m_min_fee) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_PARAMETER, | RPC_INVALID_PARAMETER, | ||||
strprintf("txfee cannot be less than wallet min fee (%s)", | strprintf("txfee cannot be less than wallet min fee (%s)", | ||||
pwallet->m_min_fee.ToString())); | pwallet->m_min_fee.ToString())); | ||||
} else if (tx_fee_rate > max_tx_fee_rate) { | |||||
throw JSONRPCError( | |||||
RPC_INVALID_PARAMETER, | |||||
strprintf("txfee cannot be more than wallet max tx fee (%s)", | |||||
max_tx_fee_rate.ToString())); | |||||
} | } | ||||
pwallet->m_pay_tx_fee = tx_fee_rate; | pwallet->m_pay_tx_fee = tx_fee_rate; | ||||
return true; | return true; | ||||
} | } | ||||
static UniValue getbalances(const Config &config, | static UniValue getbalances(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
▲ Show 20 Lines • Show All 2,224 Lines • Show Last 20 Lines |