Skip to content

Commit 6fdc32e

Browse files
committed
tapchannel: support stxo on aux sweeper
1 parent 4efa453 commit 6fdc32e

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

tapchannel/aux_sweeper.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,8 @@ func (a *AuxSweeper) importCommitTx(req lnwallet.ResolutionReq,
15821582
}
15831583
}
15841584

1585+
supportSTXO := commitState.STXO.Val
1586+
15851587
// We can now add the witness for the OP_TRUE spend of the commitment
15861588
// output to the vPackets.
15871589
vPackets := maps.Values(vPktsByAssetID)
@@ -1590,8 +1592,13 @@ func (a *AuxSweeper) importCommitTx(req lnwallet.ResolutionReq,
15901592
"packets: %w", err)
15911593
}
15921594

1595+
var opts []tapsend.OutputCommitmentOption
1596+
if !supportSTXO {
1597+
opts = append(opts, tapsend.WithNoSTXOProofs())
1598+
}
1599+
15931600
outCommitments, err := tapsend.CreateOutputCommitments(
1594-
vPackets, tapsend.WithNoSTXOProofs(),
1601+
vPackets, opts...,
15951602
)
15961603
if err != nil {
15971604
return fmt.Errorf("unable to create output "+
@@ -1609,10 +1616,14 @@ func (a *AuxSweeper) importCommitTx(req lnwallet.ResolutionReq,
16091616
for idx := range vPackets {
16101617
vPkt := vPackets[idx]
16111618
for outIdx := range vPkt.Outputs {
1619+
var opts []proof.GenOption
1620+
if !supportSTXO {
1621+
opts = append(opts, proof.WithNoSTXOProofs())
1622+
}
1623+
16121624
proofSuffix, err := tapsend.CreateProofSuffixCustom(
16131625
req.CommitTx, vPkt, outCommitments, outIdx,
1614-
vPackets, exclusionCreator,
1615-
proof.WithNoSTXOProofs(),
1626+
vPackets, exclusionCreator, opts...,
16161627
)
16171628
if err != nil {
16181629
return fmt.Errorf("unable to create "+
@@ -2222,9 +2233,7 @@ func (a *AuxSweeper) sweepContracts(inputs []input.Input,
22222233

22232234
// Now that we have our set of resolutions, we'll make a new commitment
22242235
// out of all the vPackets contained.
2225-
outCommitments, err := tapsend.CreateOutputCommitments(
2226-
directPkts, tapsend.WithNoSTXOProofs(),
2227-
)
2236+
outCommitments, err := tapsend.CreateOutputCommitments(directPkts)
22282237
if err != nil {
22292238
return lfn.Errf[returnType]("unable to create "+
22302239
"output commitments: %w", err)
@@ -2405,9 +2414,7 @@ func (a *AuxSweeper) registerAndBroadcastSweep(req *sweep.BumpRequest,
24052414
}
24062415

24072416
// Now that we have our vPkts, we'll re-create the output commitments.
2408-
outCommitments, err := tapsend.CreateOutputCommitments(
2409-
vPkts.allPkts(), tapsend.WithNoSTXOProofs(),
2410-
)
2417+
outCommitments, err := tapsend.CreateOutputCommitments(vPkts.allPkts())
24112418
if err != nil {
24122419
return fmt.Errorf("unable to create output "+
24132420
"commitments: %w", err)
@@ -2451,7 +2458,7 @@ func (a *AuxSweeper) registerAndBroadcastSweep(req *sweep.BumpRequest,
24512458

24522459
proofSuffix, err := tapsend.CreateProofSuffixCustom(
24532460
sweepTx, vPkt, outCommitments, outIdx, allVpkts,
2454-
exclusionCreator, proof.WithNoSTXOProofs(),
2461+
exclusionCreator,
24552462
)
24562463
if err != nil {
24572464
return fmt.Errorf("unable to create proof "+

tapchannel/commitment.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ func GenerateCommitmentAllocations(prevState *cmsg.Commitment,
651651
// Next, we can convert the allocations to auxiliary leaves and from
652652
// those construct our Commitment struct that will in the end also hold
653653
// our proof suffixes.
654-
newCommitment, err := ToCommitment(allocations, vPackets)
654+
newCommitment, err := ToCommitment(allocations, vPackets, stxo)
655655
if err != nil {
656656
return nil, nil, fmt.Errorf("unable to convert to commitment: "+
657657
"%w", err)
@@ -1155,7 +1155,7 @@ func LeavesFromTapscriptScriptTree(
11551155

11561156
// ToCommitment converts the allocations to a Commitment struct.
11571157
func ToCommitment(allocations []*tapsend.Allocation,
1158-
vPackets []*tappsbt.VPacket) (*cmsg.Commitment, error) {
1158+
vPackets []*tappsbt.VPacket, stxo bool) (*cmsg.Commitment, error) {
11591159

11601160
var (
11611161
localAssets []*cmsg.AssetOutput
@@ -1278,7 +1278,7 @@ func ToCommitment(allocations []*tapsend.Allocation,
12781278

12791279
return cmsg.NewCommitment(
12801280
localAssets, remoteAssets, outgoingHtlcs, incomingHtlcs,
1281-
auxLeaves, false,
1281+
auxLeaves, stxo,
12821282
), nil
12831283
}
12841284

0 commit comments

Comments
 (0)