mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
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.
This commit is contained in:
@@ -312,6 +312,7 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags)
|
|||||||
struct tlv_open_channel_tlvs *open_tlvs;
|
struct tlv_open_channel_tlvs *open_tlvs;
|
||||||
struct tlv_accept_channel_tlvs *accept_tlvs;
|
struct tlv_accept_channel_tlvs *accept_tlvs;
|
||||||
char *err_reason;
|
char *err_reason;
|
||||||
|
u32 their_mindepth;
|
||||||
|
|
||||||
status_debug("funder_channel_start");
|
status_debug("funder_channel_start");
|
||||||
if (!setup_channel_funder(state))
|
if (!setup_channel_funder(state))
|
||||||
@@ -385,7 +386,7 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags)
|
|||||||
&state->remoteconf.max_htlc_value_in_flight,
|
&state->remoteconf.max_htlc_value_in_flight,
|
||||||
&state->remoteconf.channel_reserve,
|
&state->remoteconf.channel_reserve,
|
||||||
&state->remoteconf.htlc_minimum,
|
&state->remoteconf.htlc_minimum,
|
||||||
&state->minimum_depth,
|
&their_mindepth,
|
||||||
&state->remoteconf.to_self_delay,
|
&state->remoteconf.to_self_delay,
|
||||||
&state->remoteconf.max_accepted_htlcs,
|
&state->remoteconf.max_accepted_htlcs,
|
||||||
&state->their_funding_pubkey,
|
&state->their_funding_pubkey,
|
||||||
@@ -401,6 +402,17 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags)
|
|||||||
}
|
}
|
||||||
set_remote_upfront_shutdown(state, accept_tlvs->upfront_shutdown_script);
|
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:
|
/* BOLT #2:
|
||||||
* - if `channel_type` is set, and `channel_type` was set in
|
* - if `channel_type` is set, and `channel_type` was set in
|
||||||
* `open_channel`, and they are not equal types:
|
* `open_channel`, and they are not equal types:
|
||||||
@@ -461,6 +473,20 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags)
|
|||||||
&state->our_funding_pubkey,
|
&state->our_funding_pubkey,
|
||||||
&state->their_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 */
|
/* Update the billboard with our infos */
|
||||||
peer_billboard(false,
|
peer_billboard(false,
|
||||||
"Funding channel start: awaiting funding_txid with output to %s",
|
"Funding channel start: awaiting funding_txid with output to %s",
|
||||||
|
|||||||
Reference in New Issue
Block a user