Skip to content

Commit 28af39c

Browse files
yyforyongyuguggero
authored andcommitted
contractcourt+sweep: make anchor inputs exclusive
We now make sure to sweep each anchor input in its own sweeping tx, if economically feasible.
1 parent 558ea0f commit 28af39c

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

contractcourt/anchor_resolver.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,10 @@ func (c *anchorResolver) Launch() error {
202202
// an output that we want to sweep only if it is economical to do so.
203203
//
204204
// An exclusive group is not necessary anymore, because we know that
205-
// this is the only anchor that can be swept.
205+
// this is the only anchor that can be swept. However, to avoid this
206+
// anchor input being group with other inputs, we still keep the
207+
// exclusive group here such that the anchor will be swept
208+
// independently.
206209
//
207210
// We also clear the parent tx information for cpfp, because the
208211
// commitment tx is confirmed.
@@ -222,6 +225,8 @@ func (c *anchorResolver) Launch() error {
222225
c.broadcastHeight, nil,
223226
)
224227

228+
exclusiveGroup := c.ShortChanID.ToUint64()
229+
225230
resultChan, err := c.Sweeper.SweepInput(
226231
&anchorInput,
227232
sweep.Params{
@@ -233,6 +238,10 @@ func (c *anchorResolver) Launch() error {
233238
// There's no rush to sweep the anchor, so we use a nil
234239
// deadline here.
235240
DeadlineHeight: fn.None[int32](),
241+
242+
// Use the chan id as the exclusive group. This prevents
243+
// any of the anchors from being batched together.
244+
ExclusiveGroup: &exclusiveGroup,
236245
},
237246
)
238247

sweep/sweeper.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ var (
4545

4646
// Params contains the parameters that control the sweeping process.
4747
type Params struct {
48-
// ExclusiveGroup is an identifier that, if set, prevents other inputs
49-
// with the same identifier from being batched together.
48+
// ExclusiveGroup is an identifier that, if set, ensures this input is
49+
// swept in a transaction by itself, and not batched with any other
50+
// inputs.
5051
ExclusiveGroup *uint64
5152

5253
// DeadlineHeight specifies an absolute block height that this input

0 commit comments

Comments
 (0)