From 39820773e202f49a018b1248c54bc490979f366c Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Thu, 19 Oct 2023 00:02:47 +0200 Subject: [PATCH] experimental: hide the jamming_endorsement under an experimetal flag Signed-off-by: Vincenzo Palazzo --- doc/lightningd-config.5.md | 5 +++++ lightningd/lightningd.h | 3 +++ lightningd/options.c | 4 ++++ lightningd/peer_htlcs.c | 5 ++++- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/lightningd-config.5.md b/doc/lightningd-config.5.md index 0a91c2bb24a5..624ee4af2b58 100644 --- a/doc/lightningd-config.5.md +++ b/doc/lightningd-config.5.md @@ -787,6 +787,11 @@ don't have to use a worst-case fee, but can bump the commitment transaction if it's needed. Note that this means that we need to keep some funds aside: see `min-emergency-msat`. +* **experimental-jamming-endorsement** + + Specifying this option turn on part of the Channel Jamming mitigation +to forward the `endorsed` inside `update_add_htl` lightning message. + BUGS ---- diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index 03176d9adacd..00ec184f2e7f 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -382,6 +382,9 @@ struct lightningd { /* --experimental-upgrade-protocol */ bool experimental_upgrade_protocol; + /* --experimental-jamming */ + bool experimental_jamming_endorsement; + /* For anchors: how much do we keep for spending close txs? */ struct amount_sat emergency_sat; diff --git a/lightningd/options.c b/lightningd/options.c index 119afbb9b85b..92d616a72098 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -1577,6 +1577,10 @@ static void register_opts(struct lightningd *ld) opt_register_noarg("--experimental-upgrade-protocol", opt_set_bool, &ld->experimental_upgrade_protocol, "experimental: allow channel types to be upgraded on reconnect"); + + opt_register_noarg("--experimental-jamming-endorsement", + opt_set_bool, &ld->experimental_jamming_endorsement, + "experimental: allow htlc endorsement to mitigate channel jamming (incomplete)"); clnopt_witharg("--database-upgrade", OPT_SHOWBOOL, opt_set_db_upgrade, NULL, ld, diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index aabf2ae2ae29..90bebb3d7363 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -1449,7 +1449,10 @@ static bool peer_accepted_htlc(const tal_t *ctx, * we're in hook */ hook_payload->fwd_channel_id = calc_forwarding_channel(ld, hook_payload); - + // FIXME(vincenzopalazzo): ok this do not looks right, the value of + // hook_payload->endorsed should came from the prious pear of from us + // if we are the sender. + hook_payload->endorsed = ld->experimental_jamming_endorsement ? false : NULL; plugin_hook_call_htlc_accepted(ld, NULL, hook_payload); /* Falling through here is ok, after all the HTLC locked */