mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
JSON-API: fundchannel_start uses amount fieldname to replace satoshi
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include <lightningd/log.h>
|
||||
#include <lightningd/notification.h>
|
||||
#include <lightningd/opening_control.h>
|
||||
#include <lightningd/options.h>
|
||||
#include <lightningd/peer_control.h>
|
||||
#include <lightningd/plugin_hook.h>
|
||||
#include <lightningd/subd.h>
|
||||
@@ -1069,16 +1070,41 @@ static struct command_result *json_fund_channel_start(struct command *cmd,
|
||||
fc->cancels = tal_arr(fc, struct command *, 0);
|
||||
fc->uc = NULL;
|
||||
fc->inflight = false;
|
||||
if (!param(fc->cmd, buffer, params,
|
||||
p_req("id", param_node_id, &id),
|
||||
p_req("satoshi", param_sat, &amount),
|
||||
p_opt("feerate", param_feerate, &feerate_per_kw),
|
||||
p_opt_def("announce", param_bool, &announce_channel, true),
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
|
||||
/* For generating help, give new-style. */
|
||||
if (!params || !deprecated_apis || params->type == JSMN_ARRAY) {
|
||||
if (!param(fc->cmd, buffer, params,
|
||||
p_req("id", param_node_id, &id),
|
||||
p_req("amount", param_sat, &amount),
|
||||
p_opt("feerate", param_feerate, &feerate_per_kw),
|
||||
p_opt_def("announce", param_bool, &announce_channel, true),
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
} else {
|
||||
/* For json object type when allow deprecated api, 'check' command
|
||||
* can't find the error if we don't set 'amount' nor 'satoshi'.
|
||||
*/
|
||||
struct amount_sat *satoshi;
|
||||
if (!param(fc->cmd, buffer, params,
|
||||
p_req("id", param_node_id, &id),
|
||||
p_opt("amount", param_sat, &amount),
|
||||
p_opt("satoshi", param_sat, &satoshi),
|
||||
p_opt("feerate", param_feerate, &feerate_per_kw),
|
||||
p_opt_def("announce", param_bool, &announce_channel, true),
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
|
||||
if (!amount) {
|
||||
if (satoshi)
|
||||
amount = satoshi;
|
||||
else
|
||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"Need set 'amount' field");
|
||||
}
|
||||
}
|
||||
|
||||
if (amount_sat_greater(*amount, max_funding_satoshi))
|
||||
return command_fail(cmd, FUND_MAX_EXCEEDED,
|
||||
return command_fail(cmd, FUND_MAX_EXCEEDED,
|
||||
"Amount exceeded %s",
|
||||
type_to_string(tmpctx, struct amount_sat,
|
||||
&max_funding_satoshi));
|
||||
|
||||
Reference in New Issue
Block a user