Skip to content

Commit f6fc5ae

Browse files
committed
keysend: Add maxfee to keysend for consistency with pay
1 parent 78b9ccf commit f6fc5ae

File tree

10 files changed

+719
-677
lines changed

10 files changed

+719
-677
lines changed

.msggen.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,7 @@
15211521
"KeySend.extratlvs": 9,
15221522
"KeySend.label": 3,
15231523
"KeySend.maxdelay": 6,
1524+
"KeySend.maxfee": 11,
15241525
"KeySend.maxfeepercent": 4,
15251526
"KeySend.msatoshi": 2,
15261527
"KeySend.retry_for": 5,
@@ -6362,6 +6363,10 @@
63626363
"added": "pre-v0.10.1",
63636364
"deprecated": null
63646365
},
6366+
"KeySend.maxfee": {
6367+
"added": "v24.11",
6368+
"deprecated": null
6369+
},
63656370
"KeySend.maxfeepercent": {
63666371
"added": "pre-v0.10.1",
63676372
"deprecated": null

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55

6+
## [Unreleased]
7+
8+
### Added
9+
10+
- keysend: Add `maxfee` to keysend for consistency with pay. ([#7227])
611

712
## [24.08] - 2024-08-28: "Steel Backed-up Channels"
813

cln-grpc/proto/node.proto

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cln-grpc/src/convert.rs

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cln-grpc/src/test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ fn test_keysend() {
293293
}],
294294
}),
295295
extratlvs: None,
296+
maxfee: None
296297
};
297298

298299
let u: cln_rpc::model::requests::KeysendRequest = g.into();

cln-rpc/src/model.rs

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contrib/msggen/msggen/schema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15048,6 +15048,13 @@
1504815048
"description": [
1504915049
"Dictionary of additional fields to insert into the final tlv. The format is 'fieldnumber': 'hexstring'."
1505015050
]
15051+
},
15052+
"maxfee": {
15053+
"added": "v24.11",
15054+
"type": "msat",
15055+
"description": [
15056+
"*maxfee* overrides both *maxfeepercent* and *exemptfee* defaults (and if you specify *maxfee* you cannot specify either of those), and creates an absolute limit on what fee we will pay. This allows you to implement your own heuristics rather than the primitive ones used here."
15057+
]
1505115058
}
1505215059
}
1505315060
},

contrib/pyln-grpc-proto/pyln/grpc/node_pb2.py

Lines changed: 674 additions & 674 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/schemas/lightning-keysend.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@
103103
"description": [
104104
"Dictionary of additional fields to insert into the final tlv. The format is 'fieldnumber': 'hexstring'."
105105
]
106+
},
107+
"maxfee": {
108+
"added": "v24.11",
109+
"type": "msat",
110+
"description": [
111+
"*maxfee* overrides both *maxfeepercent* and *exemptfee* defaults (and if you specify *maxfee* you cannot specify either of those), and creates an absolute limit on what fee we will pay. This allows you to implement your own heuristics rather than the primitive ones used here."
112+
]
106113
}
107114
}
108115
},

plugins/keysend.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static u64 *accepted_extra_tlvs;
2323
* ================
2424
*
2525
* The keysend modifier adds the payment preimage to the TLV payload. This
26-
* enables the recipient to accept the payment despite it not correspondin to
26+
* enables the recipient to accept the payment despite it not corresponding to
2727
* an invoice that the recipient created. Keysend does not provide any proof
2828
* or payment, but does not require an out-of-band communication round to get
2929
* an invoice first.
@@ -215,7 +215,7 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
215215
{
216216
struct payment *p;
217217
const char *label;
218-
struct amount_msat *exemptfee, *msat;
218+
struct amount_msat *exemptfee, *msat, *maxfee;
219219
struct node_id *destination;
220220
u64 *maxfee_pct_millionths;
221221
u32 *maxdelay;
@@ -237,6 +237,7 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
237237
p_opt_def("exemptfee", param_msat, &exemptfee, AMOUNT_MSAT(5000)),
238238
p_opt("extratlvs", param_extra_tlvs, &extra_fields),
239239
p_opt("routehints", param_routehint_array, &hints),
240+
p_opt("maxfee", param_msat, &maxfee),
240241
p_opt_dev("dev_use_shadow", param_bool, &dev_use_shadow, true),
241242
NULL))
242243
return command_param_failed();
@@ -284,7 +285,18 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
284285
payment_mod_keysend_get_data(p)->extra_tlvs =
285286
tal_steal(p, extra_fields);
286287

287-
payment_mod_exemptfee_get_data(p)->amount = *exemptfee;
288+
if (maxfee) {
289+
if (maxfee_pct_millionths || exemptfee) {
290+
return command_fail(
291+
cmd, JSONRPC2_INVALID_PARAMS,
292+
"If you specify maxfee, cannot specify maxfeepercent or exemptfee.");
293+
}
294+
p->constraints.fee_budget = *maxfee;
295+
payment_mod_exemptfee_get_data(p)->amount = AMOUNT_MSAT(0);
296+
} else {
297+
payment_mod_exemptfee_get_data(p)->amount = *exemptfee;
298+
}
299+
288300
payment_mod_shadowroute_get_data(p)->use_shadow = *dev_use_shadow;
289301
p->label = tal_steal(p, label);
290302

0 commit comments

Comments
 (0)