Skip to content

Commit 6b5fffb

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 204dbe4 commit 6b5fffb

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

tapcfg/server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,8 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger,
568568
GroupVerifier: tapgarden.GenGroupVerifier(
569569
context.Background(), assetMintingStore,
570570
),
571-
ChainBridge: chainBridge,
571+
ChainBridge: chainBridge,
572+
AuxChanNegotiator: auxChanNegotiator,
572573
},
573574
)
574575
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"
@@ -62,6 +63,11 @@ type AuxChanCloserCfg struct {
6263

6364
// ChainBridge is used to fetch blocks from the main chain.
6465
ChainBridge tapgarden.ChainBridge
66+
67+
// AuxChanNegotiator is responsible for producing the extra tlv blob
68+
// that is encapsulated in the init and reestablish peer messages. This
69+
// helps us communicate custom feature bits with our peer.
70+
AuxChanNegotiator *tapfeatures.AuxChannelNegotiator
6571
}
6672

6773
// assetCloseInfo houses the information we need to finalize the close of an
@@ -450,11 +456,21 @@ func (a *AuxChanCloser) AuxCloseOutputs(
450456
"packets: %w", err)
451457
}
452458

459+
features := a.cfg.AuxChanNegotiator.GetChannelFeatures(
460+
lnwire.NewChanIDFromOutPoint(desc.ChanPoint),
461+
)
462+
supportSTXO := features.HasFeature(tapfeatures.STXOOptional)
463+
464+
var opts []tapsend.OutputCommitmentOption
465+
if !supportSTXO {
466+
opts = append(opts, tapsend.WithNoSTXOProofs())
467+
}
468+
453469
// With the outputs prepared, we can now create the set of output
454470
// commitments, then with the output index locations known, we can set
455471
// the output indexes in the allocations.
456472
outCommitments, err := tapsend.CreateOutputCommitments(
457-
vPackets, tapsend.WithNoSTXOProofs(),
473+
vPackets, opts...,
458474
)
459475
if err != nil {
460476
return none, fmt.Errorf("unable to create output "+
@@ -723,10 +739,22 @@ func (a *AuxChanCloser) FinalizeClose(desc chancloser.AuxCloseDesc,
723739
closeInfo.allocations,
724740
)
725741

742+
features := a.cfg.AuxChanNegotiator.GetChannelFeatures(
743+
lnwire.NewChanIDFromOutPoint(desc.ChanPoint),
744+
)
745+
supportSTXO := features.HasFeature(
746+
tapfeatures.STXOOptional,
747+
)
748+
749+
var opts []proof.GenOption
750+
if !supportSTXO {
751+
opts = append(opts, proof.WithNoSTXOProofs())
752+
}
753+
726754
proofSuffix, err := tapsend.CreateProofSuffixCustom(
727755
closeTx, vPkt, closeInfo.outputCommitments,
728756
outIdx, closeInfo.vPackets, exclusionCreator,
729-
proof.WithNoSTXOProofs(),
757+
opts...,
730758
)
731759
if err != nil {
732760
return fmt.Errorf("unable to create proof "+

0 commit comments

Comments
 (0)