From 46c2c3a8bf3d5411fd9d58468f62b0f2be6897bd Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 20 May 2022 15:41:56 +0200 Subject: [PATCH] openingd: If we have negotiated zeroconf we use our mindepth With `option_zeroconf` we may now send `channel_ready` at any time we want, rendering the `mindepth` parameter a mere heads up. We ignore it in favor of our own value, since we plan to trigger releasing the `channel_ready` once we reach our own depth. --- openingd/openingd.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/openingd/openingd.c b/openingd/openingd.c index b929a998f..89f18383b 100644 --- a/openingd/openingd.c +++ b/openingd/openingd.c @@ -313,6 +313,7 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags) struct tlv_open_channel_tlvs *open_tlvs; struct tlv_accept_channel_tlvs *accept_tlvs; char *err_reason; + u32 their_mindepth; status_debug("funder_channel_start"); if (!setup_channel_funder(state)) @@ -386,7 +387,7 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags) &state->remoteconf.max_htlc_value_in_flight, &state->remoteconf.channel_reserve, &state->remoteconf.htlc_minimum, - &state->minimum_depth, + &their_mindepth, &state->remoteconf.to_self_delay, &state->remoteconf.max_accepted_htlcs, &state->their_funding_pubkey, @@ -402,6 +403,17 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags) } set_remote_upfront_shutdown(state, accept_tlvs->upfront_shutdown_script); + status_debug( + "accept_channel: max_htlc_value_in_flight=%s, channel_reserve=%s, " + "htlc_minimum=%s, minimum_depth=%d", + type_to_string(tmpctx, struct amount_msat, + &state->remoteconf.max_htlc_value_in_flight), + type_to_string(tmpctx, struct amount_sat, + &state->remoteconf.channel_reserve), + type_to_string(tmpctx, struct amount_msat, + &state->remoteconf.htlc_minimum), + their_mindepth); + /* BOLT #2: * - if `channel_type` is set, and `channel_type` was set in * `open_channel`, and they are not equal types: @@ -462,6 +474,20 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags) &state->our_funding_pubkey, &state->their_funding_pubkey)); + /* If we have negotiated `option_zeroconf` then we're allowed + * to send `channel_ready` whenever we want. So ignore their + * `minimum_depth` and use ours instead. Otherwise we use the + * old behavior of using their value and both side will wait + * for that number of confirmations. */ + if (feature_negotiated(state->our_features, state->their_features, + OPT_ZEROCONF)) { + status_debug( + "We negotiated option_zeroconf, using our minimum_depth=%d", + state->minimum_depth); + } else { + state->minimum_depth = their_mindepth; + } + /* Update the billboard with our infos */ peer_billboard(false, "Funding channel start: awaiting funding_txid with output to %s",