mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
paymod: Add support for the msatoshi override argument
This commit is contained in:
@@ -1858,7 +1858,7 @@ static struct command_result *json_paymod(struct command *cmd,
|
|||||||
char *fail;
|
char *fail;
|
||||||
u64 *maxfee_pct_millionths;
|
u64 *maxfee_pct_millionths;
|
||||||
u32 *maxdelay;
|
u32 *maxdelay;
|
||||||
struct amount_msat *exemptfee;
|
struct amount_msat *exemptfee, *msat;
|
||||||
const char *label;
|
const char *label;
|
||||||
#if DEVELOPER
|
#if DEVELOPER
|
||||||
bool *use_shadow;
|
bool *use_shadow;
|
||||||
@@ -1870,6 +1870,7 @@ static struct command_result *json_paymod(struct command *cmd,
|
|||||||
* would add them to the `param()` call below, and have them be
|
* would add them to the `param()` call below, and have them be
|
||||||
* initialized directly that way. */
|
* initialized directly that way. */
|
||||||
if (!param(cmd, buf, params, p_req("bolt11", param_string, &b11str),
|
if (!param(cmd, buf, params, p_req("bolt11", param_string, &b11str),
|
||||||
|
p_opt("msatoshi", param_msat, &msat),
|
||||||
p_opt("label", param_string, &label),
|
p_opt("label", param_string, &label),
|
||||||
p_opt_def("exemptfee", param_msat, &exemptfee, AMOUNT_MSAT(5000)),
|
p_opt_def("exemptfee", param_msat, &exemptfee, AMOUNT_MSAT(5000)),
|
||||||
p_opt_def("maxdelay", param_number, &maxdelay,
|
p_opt_def("maxdelay", param_number, &maxdelay,
|
||||||
@@ -1897,10 +1898,20 @@ static struct command_result *json_paymod(struct command *cmd,
|
|||||||
if (time_now().ts.tv_sec > b11->timestamp + b11->expiry)
|
if (time_now().ts.tv_sec > b11->timestamp + b11->expiry)
|
||||||
return command_fail(cmd, PAY_INVOICE_EXPIRED, "Invoice expired");
|
return command_fail(cmd, PAY_INVOICE_EXPIRED, "Invoice expired");
|
||||||
|
|
||||||
if (b11->msat)
|
if (b11->msat) {
|
||||||
|
if (msat) {
|
||||||
|
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||||
|
"msatoshi parameter unnecessary");
|
||||||
|
}
|
||||||
p->amount = *b11->msat;
|
p->amount = *b11->msat;
|
||||||
else
|
|
||||||
abort();
|
} else {
|
||||||
|
if (!msat) {
|
||||||
|
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||||
|
"msatoshi parameter required");
|
||||||
|
}
|
||||||
|
p->amount = *msat;
|
||||||
|
}
|
||||||
|
|
||||||
/* Sanity check */
|
/* Sanity check */
|
||||||
if (feature_offered(b11->features, OPT_VAR_ONION)
|
if (feature_offered(b11->features, OPT_VAR_ONION)
|
||||||
|
|||||||
@@ -3077,7 +3077,7 @@ def test_pay_modifiers(node_factory):
|
|||||||
# Make sure that the dummy param is in the help (and therefore assigned to
|
# Make sure that the dummy param is in the help (and therefore assigned to
|
||||||
# the modifier data).
|
# the modifier data).
|
||||||
hlp = l1.rpc.help("paymod")['help'][0]
|
hlp = l1.rpc.help("paymod")['help'][0]
|
||||||
assert(hlp['command'] == 'paymod bolt11 [label] [exemptfee] [maxdelay] [maxfeepercent] [use_shadow]')
|
assert(hlp['command'] == 'paymod bolt11 [msatoshi] [label] [exemptfee] [maxdelay] [maxfeepercent] [use_shadow]')
|
||||||
|
|
||||||
inv = l2.rpc.invoice(123, 'lbl', 'desc')['bolt11']
|
inv = l2.rpc.invoice(123, 'lbl', 'desc')['bolt11']
|
||||||
r = l1.rpc.paymod(inv)
|
r = l1.rpc.paymod(inv)
|
||||||
|
|||||||
Reference in New Issue
Block a user