@@ -462,6 +462,13 @@ func (p *pendingAssetFunding) addToFundingCommitment(a *asset.Asset) error {
462462 return fmt .Errorf ("unable to create commitment: %w" , err )
463463 }
464464
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+
465472 // If we don't already have a commitment, then we'll use the one created
466473 // just now and don't need to merge anything.
467474 if p .fundingAssetCommitment == nil {
@@ -1719,35 +1726,25 @@ func (f *FundingController) processFundingReq(fundingFlows fundingFlowIndex,
17191726 // we can derive the tapscript root that'll be used alongside the
17201727 // internal key (which we'll only learn from lnd later as we finalize
17211728 // the funding PSBT).
1722- fundingAssets := make ([]* asset.Asset , 0 , len (fundingVpkt .VPackets ))
17231729 for _ , pkt := range fundingVpkt .VPackets {
17241730 fundingOut , err := pkt .FirstNonSplitRootOutput ()
17251731 if err != nil {
17261732 return fmt .Errorf ("unable to find funding output in " +
17271733 "packet: %w" , err )
17281734 }
17291735
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+ }
17441743 }
17451744
1746- fundingState .fundingAssetCommitment = fundingCommitment
1747-
17481745 tapsend .LogCommitment (
1749- "funding output" , 0 , fundingCommitment , & btcec. PublicKey {} ,
1750- nil , nil ,
1746+ "funding output" , 0 , fundingState . fundingAssetCommitment ,
1747+ & btcec. PublicKey {}, nil , nil ,
17511748 )
17521749
17531750 // Before we can send our OpenChannel message, we'll
@@ -1895,21 +1892,9 @@ func (f *FundingController) chanFunder() {
18951892 continue
18961893 }
18971894
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 ))
19131898
19141899 req .resp <- lfn .Some (tapscriptRoot )
19151900
0 commit comments