contractcourt+sweep: make anchor inputs exclusive

We now make sure to sweep each anchor input in its own sweeping tx, if
economically feasible.
This commit is contained in:
yyforyongyu
2025-07-31 05:48:01 +08:00
parent 6c39b9a3d4
commit ae08a75410
2 changed files with 13 additions and 3 deletions

View File

@@ -202,7 +202,10 @@ func (c *anchorResolver) Launch() error {
// an output that we want to sweep only if it is economical to do so.
//
// An exclusive group is not necessary anymore, because we know that
// this is the only anchor that can be swept.
// this is the only anchor that can be swept. However, to avoid this
// anchor input being group with other inputs, we still keep the
// exclusive group here such that the anchor will be swept
// independently.
//
// We also clear the parent tx information for cpfp, because the
// commitment tx is confirmed.
@@ -222,6 +225,8 @@ func (c *anchorResolver) Launch() error {
c.broadcastHeight, nil,
)
exclusiveGroup := c.ShortChanID.ToUint64()
resultChan, err := c.Sweeper.SweepInput(
&anchorInput,
sweep.Params{
@@ -233,6 +238,10 @@ func (c *anchorResolver) Launch() error {
// There's no rush to sweep the anchor, so we use a nil
// deadline here.
DeadlineHeight: fn.None[int32](),
// Use the chan id as the exclusive group. This prevents
// any of the anchors from being batched together.
ExclusiveGroup: &exclusiveGroup,
},
)

View File

@@ -45,8 +45,9 @@ var (
// Params contains the parameters that control the sweeping process.
type Params struct {
// ExclusiveGroup is an identifier that, if set, prevents other inputs
// with the same identifier from being batched together.
// ExclusiveGroup is an identifier that, if set, ensures this input is
// swept in a transaction by itself, and not batched with any other
// inputs.
ExclusiveGroup *uint64
// DeadlineHeight specifies an absolute block height that this input