diff --git a/doc/lightning-listconfigs.7.md b/doc/lightning-listconfigs.7.md index aa8ec475b..6d6e4506d 100644 --- a/doc/lightning-listconfigs.7.md +++ b/doc/lightning-listconfigs.7.md @@ -135,6 +135,9 @@ On success, an object is returned, containing: - **experimental-peer-storage** (object, optional) *(added v23.02)*: - **set** (boolean): `true` if set in config or cmdline - **source** (string): source of configuration setting + - **experimental-anchors** (object, optional) *(added v23.08)*: + - **set** (boolean): `true` if set in config or cmdline + - **source** (string): source of configuration setting - **database-upgrade** (object, optional): - **value\_bool** (boolean): field from config or cmdline, or default - **source** (string): source of configuration setting @@ -463,4 +466,4 @@ RESOURCES Main web site: -[comment]: # ( SHA256STAMP:0440e4634e4a28681323f891307c7bb61143aacad4824f952f24f027a7543835) +[comment]: # ( SHA256STAMP:d24d8d540253bbe3cf9113b265fd3128e351d4615c28f6054730d1b03b363155) diff --git a/doc/lightningd-config.5.md b/doc/lightningd-config.5.md index deaab2cb2..b0bfecb3b 100644 --- a/doc/lightningd-config.5.md +++ b/doc/lightningd-config.5.md @@ -728,6 +728,16 @@ protocol to update channel types. At the moment, we only support setting this option. +* **experimental-anchors** + + Specifying this option turns on the `option_anchors_zero_fee_htlc_tx` +feature, meaning we can open anchor-based channels. This will become +the default for new channels in future, after more testing. Anchor-based +channels use larger commitment transactions, with the trade-off that they +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`. + BUGS ---- diff --git a/doc/schemas/listconfigs.schema.json b/doc/schemas/listconfigs.schema.json index cac3ecbdf..9a1339d93 100644 --- a/doc/schemas/listconfigs.schema.json +++ b/doc/schemas/listconfigs.schema.json @@ -493,6 +493,25 @@ } } }, + "experimental-anchors": { + "type": "object", + "added": "v23.08", + "additionalProperties": false, + "required": [ + "set", + "source" + ], + "properties": { + "set": { + "type": "boolean", + "description": "`true` if set in config or cmdline" + }, + "source": { + "type": "string", + "description": "source of configuration setting" + } + } + }, "database-upgrade": { "type": "object", "additionalProperties": false, diff --git a/lightningd/hsm_control.c b/lightningd/hsm_control.c index f553c3e47..14f340e94 100644 --- a/lightningd/hsm_control.c +++ b/lightningd/hsm_control.c @@ -160,6 +160,12 @@ struct ext_key *hsm_init(struct lightningd *ld) hsmd_wire_name(ld->hsm_capabilities[i])); } + if (feature_offered(ld->our_features->bits[INIT_FEATURE], + OPT_ANCHORS_ZERO_FEE_HTLC_TX) + && !hsm_capable(ld, WIRE_HSMD_SIGN_ANCHORSPEND)) { + fatal("--experimental-anchors needs HSM capable of signing anchors!"); + } + /* This is equivalent to makesecret("bolt12-invoice-base") */ msg = towire_hsmd_derive_secret(NULL, tal_dup_arr(tmpctx, u8, (const u8 *)INVOICE_PATH_BASE_STRING, diff --git a/lightningd/options.c b/lightningd/options.c index 46b063116..0db82c321 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -20,7 +20,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -1187,6 +1189,15 @@ static char *opt_set_quiesce(struct lightningd *ld) return NULL; } +static char *opt_set_anchor_zero_fee_htlc_tx(struct lightningd *ld) +{ + /* Requires static_remotekey, but we always set that */ + feature_set_or(ld->our_features, + take(feature_set_for_feature(NULL, + OPTIONAL_FEATURE(OPT_ANCHORS_ZERO_FEE_HTLC_TX)))); + return NULL; +} + static char *opt_set_offers(struct lightningd *ld) { ld->config.exp_offers = true; @@ -1284,6 +1295,10 @@ static void register_opts(struct lightningd *ld) opt_set_quiesce, ld, "experimental: Advertise ability to quiesce" " channels."); + opt_register_early_noarg("--experimental-anchors", + opt_set_anchor_zero_fee_htlc_tx, ld, + "EXPERIMENTAL: enable option_anchors_zero_fee_htlc_tx" + " to open zero-fee-anchor channels"); clnopt_witharg("--announce-addr-dns", OPT_EARLY|OPT_SHOWBOOL, opt_set_bool_arg, opt_show_bool, &ld->announce_dns,