mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-18 07:40:02 +02:00
input: add ResolutionBlob method to inputKit
We also update breachedOutput w/ the new API.
This commit is contained in:
parent
3f50339898
commit
bf3cf9ef3c
@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
|
"github.com/lightningnetwork/lnd/fn"
|
||||||
"github.com/lightningnetwork/lnd/input"
|
"github.com/lightningnetwork/lnd/input"
|
||||||
"github.com/lightningnetwork/lnd/kvdb"
|
"github.com/lightningnetwork/lnd/kvdb"
|
||||||
"github.com/lightningnetwork/lnd/labels"
|
"github.com/lightningnetwork/lnd/labels"
|
||||||
@ -22,6 +23,7 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnutils"
|
"github.com/lightningnetwork/lnd/lnutils"
|
||||||
"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/tlv"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -1067,6 +1069,10 @@ type breachedOutput struct {
|
|||||||
secondLevelTapTweak [32]byte
|
secondLevelTapTweak [32]byte
|
||||||
|
|
||||||
witnessFunc input.WitnessGenerator
|
witnessFunc input.WitnessGenerator
|
||||||
|
|
||||||
|
resolutionBlob fn.Option[tlv.Blob]
|
||||||
|
|
||||||
|
// TODO(roasbeef): function opt and hook into brar
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeBreachedOutput assembles a new breachedOutput that can be used by the
|
// makeBreachedOutput assembles a new breachedOutput that can be used by the
|
||||||
@ -1174,6 +1180,12 @@ func (bo *breachedOutput) UnconfParent() *input.TxInfo {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ResolutionBlob returns a special opaque blob to be used to sweep/resolve this
|
||||||
|
// input.
|
||||||
|
func (bo *breachedOutput) ResolutionBlob() fn.Option[tlv.Blob] {
|
||||||
|
return bo.resolutionBlob
|
||||||
|
}
|
||||||
|
|
||||||
// Add compile-time constraint ensuring breachedOutput implements the Input
|
// Add compile-time constraint ensuring breachedOutput implements the Input
|
||||||
// interface.
|
// interface.
|
||||||
var _ input.Input = (*breachedOutput)(nil)
|
var _ input.Input = (*breachedOutput)(nil)
|
||||||
|
@ -6,7 +6,9 @@ import (
|
|||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/btcsuite/btcd/txscript"
|
"github.com/btcsuite/btcd/txscript"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
|
"github.com/lightningnetwork/lnd/fn"
|
||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
|
"github.com/lightningnetwork/lnd/tlv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// EmptyOutPoint is a zeroed outpoint.
|
// EmptyOutPoint is a zeroed outpoint.
|
||||||
@ -63,6 +65,10 @@ type Input interface {
|
|||||||
// UnconfParent returns information about a possibly unconfirmed parent
|
// UnconfParent returns information about a possibly unconfirmed parent
|
||||||
// tx.
|
// tx.
|
||||||
UnconfParent() *TxInfo
|
UnconfParent() *TxInfo
|
||||||
|
|
||||||
|
// ResolutionBlob returns a special opaque blob to be used to
|
||||||
|
// sweep/resolve this input.
|
||||||
|
ResolutionBlob() fn.Option[tlv.Blob]
|
||||||
}
|
}
|
||||||
|
|
||||||
// TxInfo describes properties of a parent tx that are relevant for CPFP.
|
// TxInfo describes properties of a parent tx that are relevant for CPFP.
|
||||||
@ -106,6 +112,10 @@ type inputKit struct {
|
|||||||
// unconfParent contains information about a potential unconfirmed
|
// unconfParent contains information about a potential unconfirmed
|
||||||
// parent transaction.
|
// parent transaction.
|
||||||
unconfParent *TxInfo
|
unconfParent *TxInfo
|
||||||
|
|
||||||
|
// resolutionBlob is an optional blob that can be used to resolve an
|
||||||
|
// input.
|
||||||
|
resolutionBlob fn.Option[tlv.Blob]
|
||||||
}
|
}
|
||||||
|
|
||||||
// OutPoint returns the breached output's identifier that is to be included as
|
// OutPoint returns the breached output's identifier that is to be included as
|
||||||
@ -156,8 +166,17 @@ func (i *inputKit) UnconfParent() *TxInfo {
|
|||||||
return i.unconfParent
|
return i.unconfParent
|
||||||
}
|
}
|
||||||
|
|
||||||
// inputOpts holds options for the input.
|
// ResolutionBlob returns a special opaque blob to be used to sweep/resolve
|
||||||
|
// this input.
|
||||||
|
func (i *inputKit) ResolutionBlob() fn.Option[tlv.Blob] {
|
||||||
|
return i.resolutionBlob
|
||||||
|
}
|
||||||
|
|
||||||
|
// inputOpts contains options for constructing a new input.
|
||||||
type inputOpts struct {
|
type inputOpts struct {
|
||||||
|
// resolutionBlob is an optional blob that can be used to resolve an
|
||||||
|
// input.
|
||||||
|
resolutionBlob fn.Option[tlv.Blob]
|
||||||
}
|
}
|
||||||
|
|
||||||
// defaultInputOpts returns a new inputOpts with default values.
|
// defaultInputOpts returns a new inputOpts with default values.
|
||||||
@ -165,9 +184,18 @@ func defaultInputOpts() *inputOpts {
|
|||||||
return &inputOpts{}
|
return &inputOpts{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// InputOpt is a functional option argument to the input constructor.
|
// InputOpt is a functional option that can be used to modify the default input
|
||||||
|
// options.
|
||||||
type InputOpt func(*inputOpts) //nolint:revive
|
type InputOpt func(*inputOpts) //nolint:revive
|
||||||
|
|
||||||
|
// WithResolutionBlob is an option that can be used to set a resolution blob on
|
||||||
|
// for an input.
|
||||||
|
func WithResolutionBlob(b fn.Option[tlv.Blob]) InputOpt {
|
||||||
|
return func(o *inputOpts) {
|
||||||
|
o.resolutionBlob = b
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// BaseInput contains all the information needed to sweep a basic
|
// BaseInput contains all the information needed to sweep a basic
|
||||||
// output (CSV/CLTV/no time lock).
|
// output (CSV/CLTV/no time lock).
|
||||||
type BaseInput struct {
|
type BaseInput struct {
|
||||||
@ -187,11 +215,12 @@ func MakeBaseInput(outpoint *wire.OutPoint, witnessType WitnessType,
|
|||||||
|
|
||||||
return BaseInput{
|
return BaseInput{
|
||||||
inputKit{
|
inputKit{
|
||||||
outpoint: *outpoint,
|
outpoint: *outpoint,
|
||||||
witnessType: witnessType,
|
witnessType: witnessType,
|
||||||
signDesc: *signDescriptor,
|
signDesc: *signDescriptor,
|
||||||
heightHint: heightHint,
|
heightHint: heightHint,
|
||||||
unconfParent: unconfParent,
|
unconfParent: unconfParent,
|
||||||
|
resolutionBlob: opt.resolutionBlob,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user