Skip to content

Commit

Permalink
lightningd: add --dev-allow-shutdown-destination-change to unstick ex…
Browse files Browse the repository at this point in the history
…isting nodes.

This will solve the problem for users who already hit the bug fixed by
the previous patch!

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Feb 14, 2024
1 parent e052c54 commit 4c74ff4
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
3 changes: 2 additions & 1 deletion lightningd/closing_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,8 @@ static struct command_result *json_close(struct command *cmd,
if (close_to_script) {
bool is_p2sh;

if (!tal_arr_eq(close_to_script, channel->shutdown_scriptpubkey[LOCAL])) {
if (!tal_arr_eq(close_to_script, channel->shutdown_scriptpubkey[LOCAL])
&& !cmd->ld->dev_allow_shutdown_destination_change) {
const u8 *defp2tr, *defp2wpkh;
/* We cannot change the closing script once we've
* started shutdown: onchaind relies on it for output
Expand Down
1 change: 1 addition & 0 deletions lightningd/lightningd.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
ld->dev_disable_commit = -1;
ld->dev_no_ping_timer = false;
ld->dev_any_channel_type = false;
ld->dev_allow_shutdown_destination_change = false;

/*~ This is a CCAN list: an embedded double-linked list. It's not
* really typesafe, but relies on convention to access the contents.
Expand Down
3 changes: 3 additions & 0 deletions lightningd/lightningd.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ struct lightningd {
/* Tell openingd/dualopend to accept all, allow sending any. */
bool dev_any_channel_type;

/* Allow changing of shutdown output point even if dangerous */
bool dev_allow_shutdown_destination_change;

/* tor support */
struct wireaddr *proxyaddr;
bool always_use_proxy;
Expand Down
4 changes: 4 additions & 0 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,10 @@ static void dev_register_opts(struct lightningd *ld)
opt_set_bool,
&ld->dev_any_channel_type,
"Allow sending any channel type, and accept any");
clnopt_noarg("--dev-allow-shutdown-destination-change", OPT_DEV,
opt_set_bool,
&ld->dev_allow_shutdown_destination_change,
"Allow destination override on close, even if risky");
}

static const struct config testnet_config = {
Expand Down
8 changes: 0 additions & 8 deletions openingd/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,9 @@ bool check_config_bounds(const tal_t *ctx,
}

u8 *no_upfront_shutdown_script(const tal_t *ctx,
bool developer,
struct feature_set *our_features,
const u8 *their_features)
{
if (developer) {
/* This is a hack, for feature testing */
const char *e = getenv("DEV_OPENINGD_UPFRONT_SHUTDOWN_SCRIPT");
if (e)
return tal_hexdata(ctx, e, strlen(e));
}

/* BOLT #2:
*
* - if both nodes advertised the `option_upfront_shutdown_script`
Expand Down
1 change: 0 additions & 1 deletion openingd/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ bool anchors_negotiated(struct feature_set *our_features,
const u8 *their_features);

u8 *no_upfront_shutdown_script(const tal_t *ctx,
bool developer,
struct feature_set *our_features,
const u8 *their_features);

Expand Down
4 changes: 2 additions & 2 deletions openingd/dualopend.c
Original file line number Diff line number Diff line change
Expand Up @@ -2665,7 +2665,7 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
struct tlv_accept_tlvs *a_tlv = tlv_accept_tlvs_new(tmpctx);
if (!state->upfront_shutdown_script[LOCAL])
state->upfront_shutdown_script[LOCAL]
= no_upfront_shutdown_script(state, state->developer,
= no_upfront_shutdown_script(state,
state->our_features,
state->their_features);

Expand Down Expand Up @@ -3021,7 +3021,7 @@ static void opener_start(struct state *state, u8 *msg)

if (!state->upfront_shutdown_script[LOCAL])
state->upfront_shutdown_script[LOCAL]
= no_upfront_shutdown_script(state, state->developer,
= no_upfront_shutdown_script(state,
state->our_features,
state->their_features);

Expand Down

0 comments on commit 4c74ff4

Please sign in to comment.