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.
This commit is contained in:
Johan T. Halseth 2018-09-05 15:49:35 +02:00
parent 3a67fe2552
commit 0a5f982280
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26
2 changed files with 6 additions and 2 deletions

@ -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,

@ -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
}