mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-18 22:54:25 +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:
@@ -8,6 +8,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <lightningd/chaintopology.h>
|
||||
#include <lightningd/channel.h>
|
||||
#include <lightningd/channel_control.h>
|
||||
#include <lightningd/coin_mvts.h>
|
||||
#include <lightningd/hsm_control.h>
|
||||
#include <lightningd/onchain_control.h>
|
||||
@@ -622,6 +623,17 @@ enum watch_result onchaind_funding_spent(struct channel *channel,
|
||||
|
||||
channel_fail_permanent(channel, reason, "Funding transaction spent");
|
||||
|
||||
/* If we haven't posted the open event yet, post an open */
|
||||
if (!channel->scid || !channel->remote_funding_locked) {
|
||||
u32 blkh;
|
||||
/* Note that blockheight will be zero if it's not in chain
|
||||
* yet */
|
||||
blkh = wallet_transaction_height(channel->peer->ld->wallet,
|
||||
&channel->funding.txid);
|
||||
channel_record_open(channel, blkh);
|
||||
}
|
||||
|
||||
|
||||
/* We could come from almost any state. */
|
||||
/* NOTE(mschmoock) above comment is wrong, since we failed above! */
|
||||
channel_set_state(channel,
|
||||
|
||||
Reference in New Issue
Block a user