mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
short_channel_id: make mk_short_channel_id return a failure.
We had a bug 0ba547ee10 caused by
short_channel_id overflow. If we'd caught this, we'd have terminated
the peer instead of crashing, so add appropriate checks.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
d69680934e
commit
018a3f1d58
@@ -537,9 +537,15 @@ static enum watch_result funding_lockin_cb(struct lightningd *ld,
|
||||
|
||||
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);
|
||||
if (!mk_short_channel_id(channel->scid,
|
||||
loc->blkheight, loc->index,
|
||||
channel->funding_outnum)) {
|
||||
channel_fail_permanent(channel, "Invalid funding scid %u:%u:%u",
|
||||
loc->blkheight, loc->index,
|
||||
channel->funding_outnum);
|
||||
return DELETE_WATCH;
|
||||
}
|
||||
|
||||
/* We've added scid, update */
|
||||
wallet_channel_save(ld->wallet, channel);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user