Skip to content

Commit fb57778

Browse files
committed
tapchannel: use stxo on aux chan closer
For the cooperative channel closing we also need to check if the parties have agreed upon the usage of stxo proofs. If that is the case, we'll include those commitments in the coop channel closing transaction & proof.
1 parent 5c7da7d commit fb57778

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

tapcfg/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger,
620620
GroupVerifier: groupVerifier,
621621
ChainBridge: chainBridge,
622622
IgnoreChecker: ignoreCheckerOpt,
623+
AuxChanNegotiator: auxChanNegotiator,
623624
},
624625
)
625626
auxSweeper := tapchannel.NewAuxSweeper(

tapchannel/aux_closer.go

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/lightninglabs/taproot-assets/fn"
1616
"github.com/lightninglabs/taproot-assets/proof"
1717
"github.com/lightninglabs/taproot-assets/tapchannelmsg"
18+
"github.com/lightninglabs/taproot-assets/tapfeatures"
1819
"github.com/lightninglabs/taproot-assets/tapfreighter"
1920
"github.com/lightninglabs/taproot-assets/tapgarden"
2021
"github.com/lightninglabs/taproot-assets/tappsbt"
@@ -66,6 +67,11 @@ type AuxChanCloserCfg struct {
6667
// IgnoreChecker is an optional function that can be used to check if
6768
// a proof should be ignored.
6869
IgnoreChecker lfn.Option[proof.IgnoreChecker]
70+
71+
// AuxChanNegotiator is responsible for producing the extra tlv blob
72+
// that is encapsulated in the init and reestablish peer messages. This
73+
// helps us communicate custom feature bits with our peer.
74+
AuxChanNegotiator *tapfeatures.AuxChannelNegotiator
6975
}
7076

7177
// assetCloseInfo houses the information we need to finalize the close of an
@@ -454,11 +460,21 @@ func (a *AuxChanCloser) AuxCloseOutputs(
454460
"packets: %w", err)
455461
}
456462

463+
features := a.cfg.AuxChanNegotiator.GetChannelFeatures(
464+
lnwire.NewChanIDFromOutPoint(desc.ChanPoint),
465+
)
466+
supportSTXO := features.HasFeature(tapfeatures.STXOOptional)
467+
468+
var opts []tapsend.OutputCommitmentOption
469+
if !supportSTXO {
470+
opts = append(opts, tapsend.WithNoSTXOProofs())
471+
}
472+
457473
// With the outputs prepared, we can now create the set of output
458474
// commitments, then with the output index locations known, we can set
459475
// the output indexes in the allocations.
460476
outCommitments, err := tapsend.CreateOutputCommitments(
461-
vPackets, tapsend.WithNoSTXOProofs(),
477+
vPackets, opts...,
462478
)
463479
if err != nil {
464480
return none, fmt.Errorf("unable to create output "+
@@ -733,10 +749,22 @@ func (a *AuxChanCloser) FinalizeClose(desc chancloser.AuxCloseDesc,
733749
closeInfo.allocations,
734750
)
735751

752+
features := a.cfg.AuxChanNegotiator.GetChannelFeatures(
753+
lnwire.NewChanIDFromOutPoint(desc.ChanPoint),
754+
)
755+
supportSTXO := features.HasFeature(
756+
tapfeatures.STXOOptional,
757+
)
758+
759+
var opts []proof.GenOption
760+
if !supportSTXO {
761+
opts = append(opts, proof.WithNoSTXOProofs())
762+
}
763+
736764
proofSuffix, err := tapsend.CreateProofSuffixCustom(
737765
closeTx, vPkt, closeInfo.outputCommitments,
738766
outIdx, closeInfo.vPackets, exclusionCreator,
739-
proof.WithNoSTXOProofs(),
767+
opts...,
740768
)
741769
if err != nil {
742770
return fmt.Errorf("unable to create proof "+

0 commit comments

Comments
 (0)