@@ -909,11 +909,38 @@ func addKeyTweaks(unknowns []*psbt.Unknown, desc *lndclient.SignDescriptor) {
909
909
}
910
910
}
911
911
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
+
912
934
// CreateOutputCommitments creates the final set of Taproot asset commitments
913
935
// representing the asset sends of the given packets of active and passive
914
936
// 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
+ }
917
944
918
945
// Inputs must be unique.
919
946
if err := AssertInputsUnique (packets ); err != nil {
@@ -948,7 +975,7 @@ func CreateOutputCommitments(
948
975
// And now we commit each packet to the respective anchor output
949
976
// commitments.
950
977
for _ , vPkt := range packets {
951
- err := commitPacket (vPkt , outputCommitments )
978
+ err := commitPacket (vPkt , cfg . noSTXOProofs , outputCommitments )
952
979
if err != nil {
953
980
return nil , err
954
981
}
@@ -959,7 +986,7 @@ func CreateOutputCommitments(
959
986
960
987
// commitPacket creates the output commitments for a virtual packet and merges
961
988
// it with the existing commitments for the anchor outputs.
962
- func commitPacket (vPkt * tappsbt.VPacket ,
989
+ func commitPacket (vPkt * tappsbt.VPacket , noSTXOProofs bool ,
963
990
outputCommitments tappsbt.OutputCommitments ) error {
964
991
965
992
inputs := vPkt .Inputs
@@ -995,17 +1022,21 @@ func commitPacket(vPkt *tappsbt.VPacket,
995
1022
return fmt .Errorf ("error committing assets: %w" , err )
996
1023
}
997
1024
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
+ }
1004
1034
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
+ }
1009
1040
1010
1041
// Because the receiver of this output might be receiving
1011
1042
// through an address (non-interactive), we need to blank out
0 commit comments