Skip to content

Commit be7349d

Browse files
committed
tapchannel: support stxo on aux sweeper
This commit adds stxo support to the aux sweeper. When importing a commit tx to the wallet we now consult the commit blob flag in order to find out whether that commitment was using stxo proofs or not.
1 parent fb57778 commit be7349d

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

tapchannel/aux_sweeper.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,6 +1585,8 @@ func (a *AuxSweeper) importCommitTx(req lnwallet.ResolutionReq,
15851585
}
15861586
}
15871587

1588+
supportSTXO := commitState.STXO.Val
1589+
15881590
// We can now add the witness for the OP_TRUE spend of the commitment
15891591
// output to the vPackets.
15901592
vPackets := maps.Values(vPktsByAssetID)
@@ -1593,8 +1595,13 @@ func (a *AuxSweeper) importCommitTx(req lnwallet.ResolutionReq,
15931595
"packets: %w", err)
15941596
}
15951597

1598+
var opts []tapsend.OutputCommitmentOption
1599+
if !supportSTXO {
1600+
opts = append(opts, tapsend.WithNoSTXOProofs())
1601+
}
1602+
15961603
outCommitments, err := tapsend.CreateOutputCommitments(
1597-
vPackets, tapsend.WithNoSTXOProofs(),
1604+
vPackets, opts...,
15981605
)
15991606
if err != nil {
16001607
return fmt.Errorf("unable to create output "+
@@ -1612,10 +1619,14 @@ func (a *AuxSweeper) importCommitTx(req lnwallet.ResolutionReq,
16121619
for idx := range vPackets {
16131620
vPkt := vPackets[idx]
16141621
for outIdx := range vPkt.Outputs {
1622+
var opts []proof.GenOption
1623+
if !supportSTXO {
1624+
opts = append(opts, proof.WithNoSTXOProofs())
1625+
}
1626+
16151627
proofSuffix, err := tapsend.CreateProofSuffixCustom(
16161628
req.CommitTx, vPkt, outCommitments, outIdx,
1617-
vPackets, exclusionCreator,
1618-
proof.WithNoSTXOProofs(),
1629+
vPackets, exclusionCreator, opts...,
16191630
)
16201631
if err != nil {
16211632
return fmt.Errorf("unable to create "+
@@ -2225,9 +2236,7 @@ func (a *AuxSweeper) sweepContracts(inputs []input.Input,
22252236

22262237
// Now that we have our set of resolutions, we'll make a new commitment
22272238
// out of all the vPackets contained.
2228-
outCommitments, err := tapsend.CreateOutputCommitments(
2229-
directPkts, tapsend.WithNoSTXOProofs(),
2230-
)
2239+
outCommitments, err := tapsend.CreateOutputCommitments(directPkts)
22312240
if err != nil {
22322241
return lfn.Errf[returnType]("unable to create "+
22332242
"output commitments: %w", err)
@@ -2408,9 +2417,7 @@ func (a *AuxSweeper) registerAndBroadcastSweep(req *sweep.BumpRequest,
24082417
}
24092418

24102419
// Now that we have our vPkts, we'll re-create the output commitments.
2411-
outCommitments, err := tapsend.CreateOutputCommitments(
2412-
vPkts.allPkts(), tapsend.WithNoSTXOProofs(),
2413-
)
2420+
outCommitments, err := tapsend.CreateOutputCommitments(vPkts.allPkts())
24142421
if err != nil {
24152422
return fmt.Errorf("unable to create output "+
24162423
"commitments: %w", err)
@@ -2454,7 +2461,7 @@ func (a *AuxSweeper) registerAndBroadcastSweep(req *sweep.BumpRequest,
24542461

24552462
proofSuffix, err := tapsend.CreateProofSuffixCustom(
24562463
sweepTx, vPkt, outCommitments, outIdx, allVpkts,
2457-
exclusionCreator, proof.WithNoSTXOProofs(),
2464+
exclusionCreator,
24582465
)
24592466
if err != nil {
24602467
return fmt.Errorf("unable to create proof "+

0 commit comments

Comments
 (0)