sweep: add new AuxSweeper interface
In this commit, we add a new AuxSweeper interface. This'll take a set of inputs, and a change addr for the sweep transaction, then optionally return a new sweep output to be added to the sweep transaction. We also add a new NotifyBroadcast method. This'll be used to notify that we're _about_ to broadcast a sweeping transaction. The set of inputs is passed in, which allows the caller to prepare for the ultimate broadcast of the sweeping transaction. We also add ExtraTxOut to BumpRequest pass fees to NotifyBroadcast. This allows the callee to know the total fee of the sweeping transaction.
This commit is contained in:
7 files changed
+166
-62
No files matched your search
@@ -1,8 +1,12 @@
|
||||
package sweep
|
||||
|
||||
import (
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/fn"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
)
|
||||
|
||||
@@ -57,3 +61,31 @@ type Wallet interface {
|
||||
// service.
|
||||
BackEnd() string
|
||||
}
|
||||
|
||||
// SweepOutput is an output used to sweep funds from a channel output.
|
||||
type SweepOutput struct { //nolint:revive
|
||||
wire.TxOut
|
||||
|
||||
// IsExtra indicates whether this output is an extra output that was
|
||||
// added by a party other than the sweeper.
|
||||
IsExtra bool
|
||||
|
||||
// InternalKey is the taproot internal key of the extra output. This is
|
||||
// None, if this isn't a taproot output.
|
||||
InternalKey fn.Option[keychain.KeyDescriptor]
|
||||
}
|
||||
|
||||
// AuxSweeper is used to enable a 3rd party to further shape the sweeping
|
||||
// transaction by adding a set of extra outputs to the sweeping transaction.
|
||||
type AuxSweeper interface {
|
||||
// DeriveSweepAddr takes a set of inputs, and the change address we'd
|
||||
// use to sweep them, and maybe results an extra sweep output that we
|
||||
// should add to the sweeping transaction.
|
||||
DeriveSweepAddr(inputs []input.Input,
|
||||
change lnwallet.AddrWithKey) fn.Result[SweepOutput]
|
||||
|
||||
// NotifyBroadcast is used to notify external callers of the broadcast
|
||||
// of a sweep transaction, generated by the passed BumpRequest.
|
||||
NotifyBroadcast(req *BumpRequest, tx *wire.MsgTx,
|
||||
totalFees btcutil.Amount) error
|
||||
}
|
||||
Reference in new issue
Block a user