Skip to content

Commit ccc1fa1

Browse files
Roasbeefguggero
authored andcommitted
input: add ResolutionBlob method to inputKit
We also update breachedOutput w/ the new API.
1 parent b3adc7b commit ccc1fa1

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

contractcourt/breach_arbitrator.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ import (
1515
"github.com/btcsuite/btcd/wire"
1616
"github.com/lightningnetwork/lnd/chainntnfs"
1717
"github.com/lightningnetwork/lnd/channeldb"
18+
"github.com/lightningnetwork/lnd/fn"
1819
"github.com/lightningnetwork/lnd/input"
1920
"github.com/lightningnetwork/lnd/kvdb"
2021
"github.com/lightningnetwork/lnd/labels"
2122
"github.com/lightningnetwork/lnd/lntypes"
2223
"github.com/lightningnetwork/lnd/lnutils"
2324
"github.com/lightningnetwork/lnd/lnwallet"
2425
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
26+
"github.com/lightningnetwork/lnd/tlv"
2527
)
2628

2729
const (
@@ -1067,6 +1069,10 @@ type breachedOutput struct {
10671069
secondLevelTapTweak [32]byte
10681070

10691071
witnessFunc input.WitnessGenerator
1072+
1073+
resolutionBlob fn.Option[tlv.Blob]
1074+
1075+
// TODO(roasbeef): function opt and hook into brar
10701076
}
10711077

10721078
// makeBreachedOutput assembles a new breachedOutput that can be used by the
@@ -1174,6 +1180,12 @@ func (bo *breachedOutput) UnconfParent() *input.TxInfo {
11741180
return nil
11751181
}
11761182

1183+
// ResolutionBlob returns a special opaque blob to be used to sweep/resolve this
1184+
// input.
1185+
func (bo *breachedOutput) ResolutionBlob() fn.Option[tlv.Blob] {
1186+
return bo.resolutionBlob
1187+
}
1188+
11771189
// Add compile-time constraint ensuring breachedOutput implements the Input
11781190
// interface.
11791191
var _ input.Input = (*breachedOutput)(nil)

input/input.go

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import (
66
"github.com/btcsuite/btcd/btcutil"
77
"github.com/btcsuite/btcd/txscript"
88
"github.com/btcsuite/btcd/wire"
9+
"github.com/lightningnetwork/lnd/fn"
910
"github.com/lightningnetwork/lnd/lntypes"
11+
"github.com/lightningnetwork/lnd/tlv"
1012
)
1113

1214
// EmptyOutPoint is a zeroed outpoint.
@@ -63,6 +65,10 @@ type Input interface {
6365
// UnconfParent returns information about a possibly unconfirmed parent
6466
// tx.
6567
UnconfParent() *TxInfo
68+
69+
// ResolutionBlob returns a special opaque blob to be used to
70+
// sweep/resolve this input.
71+
ResolutionBlob() fn.Option[tlv.Blob]
6672
}
6773

6874
// TxInfo describes properties of a parent tx that are relevant for CPFP.
@@ -106,6 +112,8 @@ type inputKit struct {
106112
// unconfParent contains information about a potential unconfirmed
107113
// parent transaction.
108114
unconfParent *TxInfo
115+
116+
resolutionBlob fn.Option[tlv.Blob]
109117
}
110118

111119
// OutPoint returns the breached output's identifier that is to be included as
@@ -156,18 +164,36 @@ func (i *inputKit) UnconfParent() *TxInfo {
156164
return i.unconfParent
157165
}
158166

159-
// inputOpts holds options for the input.
167+
// ResolutionBlob returns a special opaque blob to be used to sweep/resolve
168+
// this input.
169+
func (i *inputKit) ResolutionBlob() fn.Option[tlv.Blob] {
170+
return i.resolutionBlob
171+
}
172+
173+
// inputOpts contains options for constructing a new input.
160174
type inputOpts struct {
175+
// resolutionBlob is an optional blob that can be used to resolve an
176+
// input.
177+
resolutionBlob fn.Option[tlv.Blob]
161178
}
162179

163180
// defaultInputOpts returns a new inputOpts with default values.
164181
func defaultInputOpts() *inputOpts {
165182
return &inputOpts{}
166183
}
167184

168-
// InputOpt is a functional option argument to the input constructor.
185+
// InputOpt is a functional option that can be used to modify the default input
186+
// options.
169187
type InputOpt func(*inputOpts) //nolint:revive
170188

189+
// WithResolutionBlob is an option that can be used to set a resolution blob on
190+
// for an input.
191+
func WithResolutionBlob(b fn.Option[tlv.Blob]) InputOpt {
192+
return func(o *inputOpts) {
193+
o.resolutionBlob = b
194+
}
195+
}
196+
171197
// BaseInput contains all the information needed to sweep a basic
172198
// output (CSV/CLTV/no time lock).
173199
type BaseInput struct {
@@ -187,11 +213,12 @@ func MakeBaseInput(outpoint *wire.OutPoint, witnessType WitnessType,
187213

188214
return BaseInput{
189215
inputKit{
190-
outpoint: *outpoint,
191-
witnessType: witnessType,
192-
signDesc: *signDescriptor,
193-
heightHint: heightHint,
194-
unconfParent: unconfParent,
216+
outpoint: *outpoint,
217+
witnessType: witnessType,
218+
signDesc: *signDescriptor,
219+
heightHint: heightHint,
220+
unconfParent: unconfParent,
221+
resolutionBlob: opt.resolutionBlob,
195222
},
196223
}
197224
}

0 commit comments

Comments
 (0)