mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-27 05:17:16 +02:00
sweep: make sweeper aware of unconfirmed parent transactions.
Extend the fee estimator to take into account parent transactions with their weights and fees. Do not try to cpfp parent transactions that have a higher fee rate than the sweep tx fee rate.
This commit is contained in:
@@ -3,6 +3,7 @@ package input
|
||||
import (
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
)
|
||||
|
||||
// Input represents an abstract UTXO which is to be spent using a sweeping
|
||||
@@ -41,6 +42,19 @@ type Input interface {
|
||||
// HeightHint returns the minimum height at which a confirmed spending
|
||||
// tx can occur.
|
||||
HeightHint() uint32
|
||||
|
||||
// UnconfParent returns information about a possibly unconfirmed parent
|
||||
// tx.
|
||||
UnconfParent() *TxInfo
|
||||
}
|
||||
|
||||
// TxInfo describes properties of a parent tx that are relevant for CPFP.
|
||||
type TxInfo struct {
|
||||
// Fee is the fee of the tx.
|
||||
Fee btcutil.Amount
|
||||
|
||||
// Weight is the weight of the tx.
|
||||
Weight int64
|
||||
}
|
||||
|
||||
type inputKit struct {
|
||||
@@ -49,6 +63,10 @@ type inputKit struct {
|
||||
signDesc SignDescriptor
|
||||
heightHint uint32
|
||||
blockToMaturity uint32
|
||||
|
||||
// unconfParent contains information about a potential unconfirmed
|
||||
// parent transaction.
|
||||
unconfParent *TxInfo
|
||||
}
|
||||
|
||||
// OutPoint returns the breached output's identifier that is to be included as
|
||||
@@ -82,6 +100,11 @@ func (i *inputKit) BlocksToMaturity() uint32 {
|
||||
return i.blockToMaturity
|
||||
}
|
||||
|
||||
// Cpfp returns information about a possibly unconfirmed parent tx.
|
||||
func (i *inputKit) UnconfParent() *TxInfo {
|
||||
return i.unconfParent
|
||||
}
|
||||
|
||||
// BaseInput contains all the information needed to sweep a basic output
|
||||
// (CSV/CLTV/no time lock)
|
||||
type BaseInput struct {
|
||||
@@ -91,14 +114,16 @@ type BaseInput struct {
|
||||
// MakeBaseInput assembles a new BaseInput that can be used to construct a
|
||||
// sweep transaction.
|
||||
func MakeBaseInput(outpoint *wire.OutPoint, witnessType WitnessType,
|
||||
signDescriptor *SignDescriptor, heightHint uint32) BaseInput {
|
||||
signDescriptor *SignDescriptor, heightHint uint32,
|
||||
unconfParent *TxInfo) BaseInput {
|
||||
|
||||
return BaseInput{
|
||||
inputKit{
|
||||
outpoint: *outpoint,
|
||||
witnessType: witnessType,
|
||||
signDesc: *signDescriptor,
|
||||
heightHint: heightHint,
|
||||
outpoint: *outpoint,
|
||||
witnessType: witnessType,
|
||||
signDesc: *signDescriptor,
|
||||
heightHint: heightHint,
|
||||
unconfParent: unconfParent,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -109,7 +134,7 @@ func NewBaseInput(outpoint *wire.OutPoint, witnessType WitnessType,
|
||||
signDescriptor *SignDescriptor, heightHint uint32) *BaseInput {
|
||||
|
||||
input := MakeBaseInput(
|
||||
outpoint, witnessType, signDescriptor, heightHint,
|
||||
outpoint, witnessType, signDescriptor, heightHint, nil,
|
||||
)
|
||||
|
||||
return &input
|
||||
|
Reference in New Issue
Block a user