From 0a5f982280f9509024a88377df6fe0eaf42241fa Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Wed, 5 Sep 2018 15:49:35 +0200 Subject: [PATCH] utxonursery: pass broadcastHeight to registerPreschoolConf In this commit IncubateOutputs are given an extra parameter broadcastHeight, which is passed from the server and used when called registerPresschoolConf. Earlier the utxonursery used the bestHeight as height hint in this case, which would be wrong in the cases where we got outputs for incubation which was confirmed below the best height. --- server.go | 1 + utxonursery.go | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/server.go b/server.go index 48ed123c..4c9ce4c0 100644 --- a/server.go +++ b/server.go @@ -644,6 +644,7 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB, cc *chainControl, return s.utxoNursery.IncubateOutputs( chanPoint, commitRes, outRes, inRes, + broadcastHeight, ) }, PreimageDB: s.witnessBeacon, diff --git a/utxonursery.go b/utxonursery.go index f3bf362e..5c801dce 100644 --- a/utxonursery.go +++ b/utxonursery.go @@ -343,7 +343,8 @@ func (u *utxoNursery) Stop() error { func (u *utxoNursery) IncubateOutputs(chanPoint wire.OutPoint, commitResolution *lnwallet.CommitOutputResolution, outgoingHtlcs []lnwallet.OutgoingHtlcResolution, - incomingHtlcs []lnwallet.IncomingHtlcResolution) error { + incomingHtlcs []lnwallet.IncomingHtlcResolution, + broadcastHeight uint32) error { numHtlcs := len(incomingHtlcs) + len(outgoingHtlcs) var ( @@ -469,7 +470,9 @@ func (u *utxoNursery) IncubateOutputs(chanPoint wire.OutPoint, // kindergarten bucket. if len(kidOutputs) != 0 { for _, kidOutput := range kidOutputs { - err := u.registerPreschoolConf(&kidOutput, u.bestHeight) + err := u.registerPreschoolConf( + &kidOutput, broadcastHeight, + ) if err != nil { return err }