From 08c9db9725c342eb04d0f33e1ad424b218def38c Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Thu, 31 Oct 2019 12:42:49 +0100 Subject: [PATCH] cnct: create sweeper interface --- contractcourt/chain_arbitrator.go | 3 +-- contractcourt/interfaces.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/contractcourt/chain_arbitrator.go b/contractcourt/chain_arbitrator.go index e30eec954..6d7c674a1 100644 --- a/contractcourt/chain_arbitrator.go +++ b/contractcourt/chain_arbitrator.go @@ -15,7 +15,6 @@ import ( "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwire" - "github.com/lightningnetwork/lnd/sweep" ) // ErrChainArbExiting signals that the chain arbitrator is shutting down. @@ -141,7 +140,7 @@ type ChainArbitratorConfig struct { DisableChannel func(wire.OutPoint) error // 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 // preimages and settle invoices. diff --git a/contractcourt/interfaces.go b/contractcourt/interfaces.go index a88477856..682eb2acb 100644 --- a/contractcourt/interfaces.go +++ b/contractcourt/interfaces.go @@ -3,11 +3,14 @@ package contractcourt import ( "io" + "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/htlcswitch/hop" + "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/invoices" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnwire" + "github.com/lightningnetwork/lnd/sweep" ) // Registry is an interface which represents the invoice registry. @@ -36,3 +39,16 @@ type OnionProcessor interface { // the passed io.Reader instance. 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) +}