From 54f849a62e0b24d75f79ec7b98c3f52ab90bbe3e Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 5 Jun 2017 15:05:07 -0700 Subject: [PATCH] lnwallet: use the FundingBroadcastHeight as height hint for spend ntfns --- lnwallet/channel.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 2aba8a57..57d25179 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -799,8 +799,18 @@ func NewLightningChannel(signer Signer, events chainntnfs.ChainNotifier, // the remote party has broadcasted a commitment transaction // on-chain. fundingOut := &lc.fundingTxIn.PreviousOutPoint - openHeight := lc.channelState.OpeningHeight - channelCloseNtfn, err := lc.channelEvents.RegisterSpendNtfn(fundingOut, openHeight) + + // As a height hint, we'll try to use the opening height, but + // if the channel isn't yet open, then we'll use the height it + // was broadcast at. + heightHint := lc.channelState.OpeningHeight + if heightHint == 0 { + heightHint = lc.channelState.FundingBroadcastHeight + } + + channelCloseNtfn, err := lc.channelEvents.RegisterSpendNtfn( + fundingOut, heightHint, + ) if err != nil { return nil, err }