Skip to content

Commit

Permalink
keysend: Add maxfee to keysend for consistency with pay
Browse files Browse the repository at this point in the history
  • Loading branch information
s373nZ committed Sep 9, 2024
1 parent 78b9ccf commit f6fc5ae
Show file tree
Hide file tree
Showing 10 changed files with 719 additions and 677 deletions.
5 changes: 5 additions & 0 deletions .msggen.json
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,7 @@
"KeySend.extratlvs": 9,
"KeySend.label": 3,
"KeySend.maxdelay": 6,
"KeySend.maxfee": 11,
"KeySend.maxfeepercent": 4,
"KeySend.msatoshi": 2,
"KeySend.retry_for": 5,
Expand Down Expand Up @@ -6362,6 +6363,10 @@
"added": "pre-v0.10.1",
"deprecated": null
},
"KeySend.maxfee": {
"added": "v24.11",
"deprecated": null
},
"KeySend.maxfeepercent": {
"added": "pre-v0.10.1",
"deprecated": null
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.

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

## [Unreleased]

### Added

- keysend: Add `maxfee` to keysend for consistency with pay. ([#7227])

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

Expand Down
1 change: 1 addition & 0 deletions cln-grpc/proto/node.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cln-grpc/src/convert.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cln-grpc/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ fn test_keysend() {
}],
}),
extratlvs: None,
maxfee: None
};

let u: cln_rpc::model::requests::KeysendRequest = g.into();
Expand Down
2 changes: 2 additions & 0 deletions cln-rpc/src/model.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions contrib/msggen/msggen/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -15048,6 +15048,13 @@
"description": [
"Dictionary of additional fields to insert into the final tlv. The format is 'fieldnumber': 'hexstring'."
]
},
"maxfee": {
"added": "v24.11",
"type": "msat",
"description": [
"*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."
]
}
}
},
Expand Down
1,348 changes: 674 additions & 674 deletions contrib/pyln-grpc-proto/pyln/grpc/node_pb2.py

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions doc/schemas/lightning-keysend.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@
"description": [
"Dictionary of additional fields to insert into the final tlv. The format is 'fieldnumber': 'hexstring'."
]
},
"maxfee": {
"added": "v24.11",
"type": "msat",
"description": [
"*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."
]
}
}
},
Expand Down
18 changes: 15 additions & 3 deletions plugins/keysend.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static u64 *accepted_extra_tlvs;
* ================
*
* The keysend modifier adds the payment preimage to the TLV payload. This
* enables the recipient to accept the payment despite it not correspondin to
* enables the recipient to accept the payment despite it not corresponding to
* an invoice that the recipient created. Keysend does not provide any proof
* or payment, but does not require an out-of-band communication round to get
* an invoice first.
Expand Down Expand Up @@ -215,7 +215,7 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
{
struct payment *p;
const char *label;
struct amount_msat *exemptfee, *msat;
struct amount_msat *exemptfee, *msat, *maxfee;
struct node_id *destination;
u64 *maxfee_pct_millionths;
u32 *maxdelay;
Expand All @@ -237,6 +237,7 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
p_opt_def("exemptfee", param_msat, &exemptfee, AMOUNT_MSAT(5000)),
p_opt("extratlvs", param_extra_tlvs, &extra_fields),
p_opt("routehints", param_routehint_array, &hints),
p_opt("maxfee", param_msat, &maxfee),
p_opt_dev("dev_use_shadow", param_bool, &dev_use_shadow, true),
NULL))
return command_param_failed();
Expand Down Expand Up @@ -284,7 +285,18 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
payment_mod_keysend_get_data(p)->extra_tlvs =
tal_steal(p, extra_fields);

payment_mod_exemptfee_get_data(p)->amount = *exemptfee;
if (maxfee) {
if (maxfee_pct_millionths || exemptfee) {
return command_fail(
cmd, JSONRPC2_INVALID_PARAMS,
"If you specify maxfee, cannot specify maxfeepercent or exemptfee.");
}
p->constraints.fee_budget = *maxfee;
payment_mod_exemptfee_get_data(p)->amount = AMOUNT_MSAT(0);
} else {
payment_mod_exemptfee_get_data(p)->amount = *exemptfee;
}

payment_mod_shadowroute_get_data(p)->use_shadow = *dev_use_shadow;
p->label = tal_steal(p, label);

Expand Down

0 comments on commit f6fc5ae

Please sign in to comment.