multi: modify sweeper.CreateSweepTx to accept conf target, style changes

In this commit, we modify the newly introduced UtxoSweeper.CreateSweepTx
to accept the confirmation target as a param of the method rather than a
struct level variable. We do this as this allows each caller to decide
at sweep time, what the fee rate should be, rather than using a global
value that is meant to work in all scenarios. For example, anytime
we're sweeping an output with a CLTV lock that's has a dependant
transaction we need to sweep/cancel, we may require a higher fee rate
than a regular force close with a CSV output.
This commit is contained in:
Olaoluwa Osuntokun committed 2018-10-18 18:08:27 -07:00
1 parent 90fe860a3c
commit fc21bf091a
6 files changed
+93 -71

No files matched your search

+10 -5
View File
@@ -4,11 +4,12 @@ import (
"bytes"
"encoding/binary"
"fmt"
"github.com/lightningnetwork/lnd/sweep"
"io"
"sync"
"sync/atomic"
"github.com/lightningnetwork/lnd/sweep"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
@@ -182,6 +183,10 @@ type NurseryConfig struct {
// determining outputs in the chain as confirmed.
ConfDepth uint32
// SweepTxConfTarget assigns a confirmation target for sweep txes on
// which the fee calculation will be based.
SweepTxConfTarget uint32
// FetchClosedChannels provides access to a user's channels, such that
// they can be marked fully closed after incubation has concluded.
FetchClosedChannels func(pendingOnly bool) (
@@ -871,15 +876,15 @@ func (u *utxoNursery) graduateClass(classHeight uint32) error {
// generated a sweep txn for this height. Generate one if there
// are kindergarten outputs or cltv crib outputs to be spent.
if len(kgtnOutputs) > 0 {
sweepInputs := make([]sweep.Input,
len(kgtnOutputs))
sweepInputs := make([]sweep.Input, len(kgtnOutputs))
for i := range kgtnOutputs {
sweepInputs[i] = &kgtnOutputs[i]
}
finalTx, err = u.cfg.Sweeper.CreateSweepTx(
sweepInputs, classHeight)
sweepInputs, u.cfg.SweepTxConfTarget,
classHeight,
)
if err != nil {
utxnLog.Errorf("Failed to create sweep txn at "+
"height=%d", classHeight)