mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
coin_mvt: log channel_open for channels that close before they're locked
We don't push out a coin_move for a channel open until it's locked in, but this causes problems for channels that close before they're locked. So if we go the "close before locked in" route, we push out a channel open event. These will get a blockheight of 0, if we haven't seen the funding transaction in a block yet.
This commit is contained in:
@@ -127,16 +127,13 @@ void notify_feerate_change(struct lightningd *ld)
|
||||
* peer. We *could* do so, however. */
|
||||
}
|
||||
|
||||
void channel_record_open(struct channel *channel)
|
||||
void channel_record_open(struct channel *channel, u32 blockheight)
|
||||
{
|
||||
struct chain_coin_mvt *mvt;
|
||||
u32 blockheight;
|
||||
struct amount_msat start_balance;
|
||||
bool is_pushed = !amount_msat_zero(channel->push);
|
||||
bool is_leased = channel->lease_expiry > 0;
|
||||
|
||||
blockheight = short_channel_id_blocknum(channel->scid);
|
||||
|
||||
/* If funds were pushed, add/sub them from the starting balance */
|
||||
if (channel->opener == LOCAL) {
|
||||
if (!amount_msat_add(&start_balance,
|
||||
@@ -210,7 +207,8 @@ static void lockin_complete(struct channel *channel)
|
||||
|
||||
/* Only record this once we get a real confirmation. */
|
||||
if (channel->scid)
|
||||
channel_record_open(channel);
|
||||
channel_record_open(channel,
|
||||
short_channel_id_blocknum(channel->scid));
|
||||
}
|
||||
|
||||
bool channel_on_funding_locked(struct channel *channel,
|
||||
@@ -869,7 +867,8 @@ bool channel_tell_depth(struct lightningd *ld,
|
||||
get_block_height(channel->peer->ld->topology));
|
||||
|
||||
/* Only record this once we get a real confirmation. */
|
||||
channel_record_open(channel);
|
||||
channel_record_open(channel,
|
||||
short_channel_id_blocknum(channel->scid));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user