cnct: create sweeper interface

This commit is contained in:
Joost Jager 2019-10-31 12:42:49 +01:00
parent 919ab60540
commit 08c9db9725
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7
2 changed files with 17 additions and 2 deletions

@ -15,7 +15,6 @@ import (
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/sweep"
) )
// ErrChainArbExiting signals that the chain arbitrator is shutting down. // ErrChainArbExiting signals that the chain arbitrator is shutting down.
@ -141,7 +140,7 @@ type ChainArbitratorConfig struct {
DisableChannel func(wire.OutPoint) error DisableChannel func(wire.OutPoint) error
// Sweeper allows resolvers to sweep their final outputs. // Sweeper allows resolvers to sweep their final outputs.
Sweeper *sweep.UtxoSweeper Sweeper UtxoSweeper
// Registry is the invoice database that is used by resolvers to lookup // Registry is the invoice database that is used by resolvers to lookup
// preimages and settle invoices. // preimages and settle invoices.

@ -3,11 +3,14 @@ package contractcourt
import ( import (
"io" "io"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/htlcswitch/hop"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/invoices" "github.com/lightningnetwork/lnd/invoices"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/sweep"
) )
// Registry is an interface which represents the invoice registry. // Registry is an interface which represents the invoice registry.
@ -36,3 +39,16 @@ type OnionProcessor interface {
// the passed io.Reader instance. // the passed io.Reader instance.
ReconstructHopIterator(r io.Reader, rHash []byte) (hop.Iterator, error) ReconstructHopIterator(r io.Reader, rHash []byte) (hop.Iterator, error)
} }
// UtxoSweeper defines the sweep functions that contract court requires.
type UtxoSweeper interface {
// SweepInput sweeps inputs back into the wallet.
SweepInput(input input.Input,
feePreference sweep.FeePreference) (chan sweep.Result, error)
// CreateSweepTx accepts a list of inputs and signs and generates a txn
// that spends from them. This method also makes an accurate fee
// estimate before generating the required witnesses.
CreateSweepTx(inputs []input.Input, feePref sweep.FeePreference,
currentBlockHeight uint32) (*wire.MsgTx, error)
}