@@ -462,6 +462,13 @@ func (p *pendingAssetFunding) addToFundingCommitment(a *asset.Asset) error {
462
462
return fmt .Errorf ("unable to create commitment: %w" , err )
463
463
}
464
464
465
+ newCommitment , err = commitment .TrimSplitWitnesses (
466
+ & newCommitment .Version , newCommitment ,
467
+ )
468
+ if err != nil {
469
+ return fmt .Errorf ("unable to trim split witness: %w" , err )
470
+ }
471
+
465
472
// If we don't already have a commitment, then we'll use the one created
466
473
// just now and don't need to merge anything.
467
474
if p .fundingAssetCommitment == nil {
@@ -1719,35 +1726,25 @@ func (f *FundingController) processFundingReq(fundingFlows fundingFlowIndex,
1719
1726
// we can derive the tapscript root that'll be used alongside the
1720
1727
// internal key (which we'll only learn from lnd later as we finalize
1721
1728
// the funding PSBT).
1722
- fundingAssets := make ([]* asset.Asset , 0 , len (fundingVpkt .VPackets ))
1723
1729
for _ , pkt := range fundingVpkt .VPackets {
1724
1730
fundingOut , err := pkt .FirstNonSplitRootOutput ()
1725
1731
if err != nil {
1726
1732
return fmt .Errorf ("unable to find funding output in " +
1727
1733
"packet: %w" , err )
1728
1734
}
1729
1735
1730
- fundingAssets = append (fundingAssets , fundingOut .Asset .Copy ())
1731
- }
1732
- fundingCommitVersion , err := tappsbt .CommitmentVersion (
1733
- fundingVpkt .VPackets [0 ].Version ,
1734
- )
1735
- if err != nil {
1736
- return fmt .Errorf ("unable to create commitment: %w" , err )
1737
- }
1738
-
1739
- fundingCommitment , err := commitment .FromAssets (
1740
- fundingCommitVersion , fundingAssets ... ,
1741
- )
1742
- if err != nil {
1743
- return fmt .Errorf ("unable to create commitment: %w" , err )
1736
+ err = fundingState .addToFundingCommitment (
1737
+ fundingOut .Asset .Copy (),
1738
+ )
1739
+ if err != nil {
1740
+ return fmt .Errorf ("unable to add asset to funding " +
1741
+ "commitment: %w" , err )
1742
+ }
1744
1743
}
1745
1744
1746
- fundingState .fundingAssetCommitment = fundingCommitment
1747
-
1748
1745
tapsend .LogCommitment (
1749
- "funding output" , 0 , fundingCommitment , & btcec. PublicKey {} ,
1750
- nil , nil ,
1746
+ "funding output" , 0 , fundingState . fundingAssetCommitment ,
1747
+ & btcec. PublicKey {}, nil , nil ,
1751
1748
)
1752
1749
1753
1750
// Before we can send our OpenChannel message, we'll
@@ -1895,21 +1892,9 @@ func (f *FundingController) chanFunder() {
1895
1892
continue
1896
1893
}
1897
1894
1898
- trimmedCommitment , err := commitment .TrimSplitWitnesses (
1899
- & fundingCommitment .Version , fundingCommitment ,
1900
- )
1901
- if err != nil {
1902
- fErr := fmt .Errorf ("unable to anchor output " +
1903
- "script: %w" , err )
1904
- f .cfg .ErrReporter .ReportError (
1905
- ctxc , fundingFlow .peerPub , pid ,
1906
- fErr ,
1907
- )
1908
- continue
1909
- }
1910
-
1911
- tapscriptRoot := trimmedCommitment .TapscriptRoot (nil )
1912
- log .Infof ("Returning tapscript root: %v" , tapscriptRoot )
1895
+ tapscriptRoot := fundingCommitment .TapscriptRoot (nil )
1896
+ log .Infof ("Returning tapscript root: %x" ,
1897
+ fn .ByteSlice (tapscriptRoot ))
1913
1898
1914
1899
req .resp <- lfn .Some (tapscriptRoot )
1915
1900
0 commit comments