@@ -909,11 +909,38 @@ func addKeyTweaks(unknowns []*psbt.Unknown, desc *lndclient.SignDescriptor) {
909909 }
910910}
911911
912+ // OutputCommitmentConfig is a struct that holds the configuration for the
913+ // output commitment creation process.
914+ type OutputCommitmentConfig struct {
915+ // noSTXOProofs indicates whether we should skip the generation of
916+ // STXO proofs. This should only be done for asset channels to preserve
917+ // the backward compatibility with older peers.
918+ noSTXOProofs bool
919+ }
920+
921+ // OutputCommitmentOption is a functional option that can be used to configure
922+ // the output commitment creation process.
923+ type OutputCommitmentOption func (* OutputCommitmentConfig )
924+
925+ // WithNoSTXOProofs is an option that can be used to skip the generation of
926+ // STXO proofs. This should only be done for asset channels to preserve the
927+ // backward compatibility with older peers.
928+ func WithNoSTXOProofs () OutputCommitmentOption {
929+ return func (cfg * OutputCommitmentConfig ) {
930+ cfg .noSTXOProofs = true
931+ }
932+ }
933+
912934// CreateOutputCommitments creates the final set of Taproot asset commitments
913935// representing the asset sends of the given packets of active and passive
914936// assets.
915- func CreateOutputCommitments (
916- packets []* tappsbt.VPacket ) (tappsbt.OutputCommitments , error ) {
937+ func CreateOutputCommitments (packets []* tappsbt.VPacket ,
938+ opts ... OutputCommitmentOption ) (tappsbt.OutputCommitments , error ) {
939+
940+ cfg := & OutputCommitmentConfig {}
941+ for _ , opt := range opts {
942+ opt (cfg )
943+ }
917944
918945 // Inputs must be unique.
919946 if err := AssertInputsUnique (packets ); err != nil {
@@ -948,7 +975,7 @@ func CreateOutputCommitments(
948975 // And now we commit each packet to the respective anchor output
949976 // commitments.
950977 for _ , vPkt := range packets {
951- err := commitPacket (vPkt , outputCommitments )
978+ err := commitPacket (vPkt , cfg . noSTXOProofs , outputCommitments )
952979 if err != nil {
953980 return nil , err
954981 }
@@ -959,7 +986,7 @@ func CreateOutputCommitments(
959986
960987// commitPacket creates the output commitments for a virtual packet and merges
961988// it with the existing commitments for the anchor outputs.
962- func commitPacket (vPkt * tappsbt.VPacket ,
989+ func commitPacket (vPkt * tappsbt.VPacket , noSTXOProofs bool ,
963990 outputCommitments tappsbt.OutputCommitments ) error {
964991
965992 inputs := vPkt .Inputs
@@ -995,17 +1022,21 @@ func commitPacket(vPkt *tappsbt.VPacket,
9951022 return fmt .Errorf ("error committing assets: %w" , err )
9961023 }
9971024
998- // Collect the spent assets for this output.
999- stxoAssets , err := asset .CollectSTXO (vOut .Asset )
1000- if err != nil {
1001- return fmt .Errorf ("error collecting STXO assets: %w" ,
1002- err )
1003- }
1025+ // To not break backward compatibility with older peers, we skip
1026+ // the generation of STXO proofs for asset channels.
1027+ if ! noSTXOProofs {
1028+ // Collect the spent assets for this output.
1029+ stxoAssets , err := asset .CollectSTXO (vOut .Asset )
1030+ if err != nil {
1031+ return fmt .Errorf ("error collecting STXO " +
1032+ "assets: %w" , err )
1033+ }
10041034
1005- // If we have STXOs, we will encumber vOut.AltLeaves with
1006- // them.They will be merged into the commitment later with
1007- // MergeAltLeaves.
1008- vOut .AltLeaves = append (vOut .AltLeaves , stxoAssets ... )
1035+ // If we have STXOs, we will encumber vOut.AltLeaves
1036+ // with them. They will be merged into the commitment
1037+ // later with MergeAltLeaves.
1038+ vOut .AltLeaves = append (vOut .AltLeaves , stxoAssets ... )
1039+ }
10091040
10101041 // Because the receiver of this output might be receiving
10111042 // through an address (non-interactive), we need to blank out
0 commit comments