Experimental option option_shutdown_wrong_funding: help me, I screwed up!

It's not unheard of for people to give the wrong funding tx to us,
getting their funds stuck.  Interestingly, we can allow mutual close
using a different txid and output number as long as they (solely)
funded the channel, and the channel hasn't been used.

This defines a "play area" feature to do just that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-03-15 14:09:44 +10:30
parent 1b02d15695
commit cc6d2afe21
5 changed files with 40 additions and 1 deletions

View file

@ -73,6 +73,10 @@ static const struct feature_style feature_styles[] = {
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
[BOLT11_FEATURE] = FEATURE_REPRESENT,
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT} },
{ OPT_SHUTDOWN_WRONG_FUNDING,
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT} },
#if EXPERIMENTAL_FEATURES
{ OPT_ANCHOR_OUTPUTS,
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,

View file

@ -129,4 +129,7 @@ u8 *featurebits_or(const tal_t *ctx, const u8 *f1 TAKES, const u8 *f2 TAKES);
* | 102/103 | `option_onion_messages` |... INC+ ...
*/
#define OPT_ONION_MESSAGES 102
#define OPT_SHUTDOWN_WRONG_FUNDING 104
#endif /* LIGHTNING_COMMON_FEATURES_H */

View file

@ -583,6 +583,15 @@ corresponding functionality, which are in draft status as BOLT12\.
This usually requires \fBexperimental-onion-messages\fR as well\. See
\fBlightning-offer\fR(7) and \fBlightning-fetchinvoice\fR(7)\.
\fBexperimental-shutdown-wrong-funding\fR
Specifying this allows the \fBwrong_funding\fR field in shutdown: if a
remote node has opened a channel using the incorrect txid (and it
hasn't been used yet at all) this allows them to negotiate a clean
shutdown with the txid they offer\.
.SH BUGS
You should report bugs on our github issues page, and maybe submit a fix
@ -608,4 +617,4 @@ Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
Note: the modules in the ccan/ directory have their own licenses, but
the rest of the code is covered by the BSD-style MIT license\.
\" SHA256STAMP:8e18374d48aff1d2574667c603e36cdac81c35e09a49397dc6982f1688dd454a
\" SHA256STAMP:ecfd7ac60b50a20cad39dfa0e423e4885256a94658b5886f577df50773555e7e

View file

@ -483,6 +483,13 @@ corresponding functionality, which are in draft status as BOLT12.
This usually requires **experimental-onion-messages** as well. See
lightning-offer(7) and lightning-fetchinvoice(7).
**experimental-shutdown-wrong-funding**
Specifying this allows the `wrong_funding` field in shutdown: if a
remote node has opened a channel using the incorrect txid (and it
hasn't been used yet at all) this allows them to negotiate a clean
shutdown with the txid they offer.
BUGS
----

View file

@ -814,6 +814,14 @@ static char *opt_set_onion_messages(struct lightningd *ld)
return NULL;
}
static char *opt_set_shutdown_wrong_funding(struct lightningd *ld)
{
feature_set_or(ld->our_features,
take(feature_set_for_feature(NULL,
OPTIONAL_FEATURE(OPT_SHUTDOWN_WRONG_FUNDING))));
return NULL;
}
static char *opt_set_offers(struct lightningd *ld)
{
ld->config.exp_offers = true;
@ -878,6 +886,9 @@ static void register_opts(struct lightningd *ld)
opt_set_offers, ld,
"EXPERIMENTAL: enable send and receive of offers"
" (also sets experimental-onion-messages)");
opt_register_early_noarg("--experimental-shutdown-wrong-funding",
opt_set_shutdown_wrong_funding, ld,
"EXPERIMENTAL: allow shutdown with alternate txids");
opt_register_noarg("--help|-h", opt_lightningd_usage, ld,
"Print this message.");
@ -1301,6 +1312,11 @@ static void add_config(struct lightningd *ld,
OPT_ONION_MESSAGES));
} else if (opt->cb == (void *)opt_set_offers) {
json_add_bool(response, name0, ld->config.exp_offers);
} else if (opt->cb == (void *)opt_set_shutdown_wrong_funding) {
json_add_bool(response, name0,
feature_offered(ld->our_features
->bits[INIT_FEATURE],
OPT_SHUTDOWN_WRONG_FUNDING));
} else if (opt->cb == (void *)plugin_opt_flag_set) {
/* Noop, they will get added below along with the
* OPT_HASARG options. */