Extract prevention of outdated option names

This will be reused in `sendall` so we extract it to avoid
duplication.
24.x
Murch 3 years ago
parent 9344697e57
commit 35ed094e4b
No known key found for this signature in database
GPG Key ID: 7BA035CA5B901713

@ -21,7 +21,8 @@
namespace wallet { namespace wallet {
static void ParseRecipients(const UniValue& address_amounts, const UniValue& subtract_fee_outputs, std::vector<CRecipient> &recipients) { static void ParseRecipients(const UniValue& address_amounts, const UniValue& subtract_fee_outputs, std::vector<CRecipient> &recipients)
{
std::set<CTxDestination> destinations; std::set<CTxDestination> destinations;
int i = 0; int i = 0;
for (const std::string& address: address_amounts.getKeys()) { for (const std::string& address: address_amounts.getKeys()) {
@ -51,6 +52,28 @@ static void ParseRecipients(const UniValue& address_amounts, const UniValue& sub
} }
} }
static void PreventOutdatedOptions(const UniValue& options)
{
if (options.exists("feeRate")) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Use fee_rate (" + CURRENCY_ATOM + "/vB) instead of feeRate");
}
if (options.exists("changeAddress")) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Use change_address");
}
if (options.exists("changePosition")) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Use change_position");
}
if (options.exists("includeWatching")) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Use include_watching");
}
if (options.exists("lockUnspents")) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Use lock_unspents");
}
if (options.exists("subtractFeeFromOutputs")) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Use subtract_fee_from_outputs");
}
}
UniValue SendMoney(CWallet& wallet, const CCoinControl &coin_control, std::vector<CRecipient> &recipients, mapValue_t map_value, bool verbose) UniValue SendMoney(CWallet& wallet, const CCoinControl &coin_control, std::vector<CRecipient> &recipients, mapValue_t map_value, bool verbose)
{ {
EnsureWalletIsUnlocked(wallet); EnsureWalletIsUnlocked(wallet);
@ -1144,24 +1167,7 @@ RPCHelpMan send()
if (!options["conf_target"].isNull() && (options["estimate_mode"].isNull() || (options["estimate_mode"].get_str() == "unset"))) { if (!options["conf_target"].isNull() && (options["estimate_mode"].isNull() || (options["estimate_mode"].get_str() == "unset"))) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Specify estimate_mode"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Specify estimate_mode");
} }
if (options.exists("feeRate")) { PreventOutdatedOptions(options);
throw JSONRPCError(RPC_INVALID_PARAMETER, "Use fee_rate (" + CURRENCY_ATOM + "/vB) instead of feeRate");
}
if (options.exists("changeAddress")) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Use change_address");
}
if (options.exists("changePosition")) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Use change_position");
}
if (options.exists("includeWatching")) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Use include_watching");
}
if (options.exists("lockUnspents")) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Use lock_unspents");
}
if (options.exists("subtractFeeFromOutputs")) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Use subtract_fee_from_outputs");
}
const bool psbt_opt_in = options.exists("psbt") && options["psbt"].get_bool(); const bool psbt_opt_in = options.exists("psbt") && options["psbt"].get_bool();

Loading…
Cancel
Save