mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-06 07:34:21 +01:00
fix:Add infor about how many blocks needed until funding is confirmed
1. Rename channel_funding_locked to channel_funding_depth in channeld/channel_wire.csv. 2. Add minimum_depth in struct channel in common/initial_channel.h and change corresponding init function: new_initial_channel(). 3. Add confirmation_needed in struct peer in channeld/channeld.c. 4. Rename channel_tell_funding_locked to channel_tell_depth. 5. Call channel_tell_depth even if depth < minimum, and still call lockin_complete in channel_tell_depth, iff depth > minimum_depth. 6. channeld ignore the channel_funding_depth unless its > minimum_depth(except to update billboard, and set peer->confirmation_needed = minimum_depth - depth).
This commit is contained in:
committed by
Rusty Russell
parent
d140e927bf
commit
92b40cb68a
@@ -222,7 +222,7 @@ static unsigned channel_msg(struct subd *sd, const u8 *msg, const int *fds)
|
||||
|
||||
/* And we never get these from channeld. */
|
||||
case WIRE_CHANNEL_INIT:
|
||||
case WIRE_CHANNEL_FUNDING_LOCKED:
|
||||
case WIRE_CHANNEL_FUNDING_DEPTH:
|
||||
case WIRE_CHANNEL_OFFER_HTLC:
|
||||
case WIRE_CHANNEL_FULFILL_HTLC:
|
||||
case WIRE_CHANNEL_FAIL_HTLC:
|
||||
@@ -341,6 +341,7 @@ void peer_start_channeld(struct channel *channel,
|
||||
&channel->funding_txid,
|
||||
channel->funding_outnum,
|
||||
channel->funding,
|
||||
channel->minimum_depth,
|
||||
&channel->our_config,
|
||||
&channel->channel_info.their_config,
|
||||
channel->channel_info.feerate_per_kw,
|
||||
@@ -393,32 +394,38 @@ void peer_start_channeld(struct channel *channel,
|
||||
try_update_feerates(ld, channel);
|
||||
}
|
||||
|
||||
bool channel_tell_funding_locked(struct lightningd *ld,
|
||||
bool channel_tell_depth(struct lightningd *ld,
|
||||
struct channel *channel,
|
||||
const struct bitcoin_txid *txid,
|
||||
u32 depth)
|
||||
{
|
||||
const char *txidstr;
|
||||
|
||||
txidstr = type_to_string(tmpctx, struct bitcoin_txid, txid);
|
||||
|
||||
/* If not awaiting lockin/announce, it doesn't care any more */
|
||||
if (channel->state != CHANNELD_AWAITING_LOCKIN
|
||||
&& channel->state != CHANNELD_NORMAL) {
|
||||
log_debug(channel->log,
|
||||
"Funding tx confirmed, but peer in state %s",
|
||||
channel_state_name(channel));
|
||||
"Funding tx %s confirmed, but peer in state %s",
|
||||
txidstr, channel_state_name(channel));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!channel->owner) {
|
||||
log_debug(channel->log,
|
||||
"Funding tx confirmed, but peer disconnected");
|
||||
"Funding tx %s confirmed, but peer disconnected",
|
||||
txidstr);
|
||||
return false;
|
||||
}
|
||||
|
||||
subd_send_msg(channel->owner,
|
||||
take(towire_channel_funding_locked(NULL, channel->scid,
|
||||
take(towire_channel_funding_depth(NULL, channel->scid,
|
||||
depth)));
|
||||
|
||||
if (channel->remote_funding_locked
|
||||
&& channel->state == CHANNELD_AWAITING_LOCKIN)
|
||||
&& channel->state == CHANNELD_AWAITING_LOCKIN
|
||||
&& depth >= channel->minimum_depth)
|
||||
lockin_complete(channel);
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user