mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 09:34:24 +01:00
lightningd: commit short-channel-id to db when we create it.
We'd usually commit to the db soon, but there's a window where it could be missed. Also moves loc into the block it's used and make it tmpctx to avoid an explicit free. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -628,7 +628,6 @@ static enum watch_result funding_lockin_cb(struct channel *channel,
|
||||
unsigned int depth)
|
||||
{
|
||||
const char *txidstr;
|
||||
struct txlocator *loc;
|
||||
bool channel_ready;
|
||||
struct lightningd *ld = channel->peer->ld;
|
||||
|
||||
@@ -640,16 +639,18 @@ static enum watch_result funding_lockin_cb(struct channel *channel,
|
||||
if (depth < channel->minimum_depth)
|
||||
return KEEP_WATCHING;
|
||||
|
||||
loc = wallet_transaction_locate(channel, ld->wallet, txid);
|
||||
|
||||
/* If we restart, we could already have peer->scid from database */
|
||||
if (!channel->scid) {
|
||||
struct txlocator *loc;
|
||||
|
||||
loc = wallet_transaction_locate(tmpctx, ld->wallet, txid);
|
||||
channel->scid = tal(channel, struct short_channel_id);
|
||||
mk_short_channel_id(channel->scid,
|
||||
loc->blkheight, loc->index,
|
||||
channel->funding_outnum);
|
||||
/* We've added scid, update */
|
||||
wallet_channel_save(ld->wallet, channel);
|
||||
}
|
||||
tal_free(loc);
|
||||
|
||||
/* In theory, it could have been buried before we got back
|
||||
* from accepting openingd or disconnected: just wait for next one. */
|
||||
|
||||
Reference in New Issue
Block a user