@@ -914,13 +914,16 @@ func (f *FundingController) sendInputOwnershipProofs(peerPub btcec.PublicKey,
914914 // We'll now send the signed inputs to the remote party.
915915 //
916916 // TODO(roasbeef): generalize for multi-asset
917- fundingAsset := vPkt .Outputs [0 ].Asset .Copy ()
917+ fundingOut , err := vPkt .FirstNonSplitRootOutput ()
918+ if err != nil {
919+ return fmt .Errorf ("unable to get funding asset: %w" , err )
920+ }
918921 assetOutputMsg := cmsg .NewTxAssetOutputProof (
919- fundingState .pid , * fundingAsset , true ,
922+ fundingState .pid , * fundingOut . Asset , true ,
920923 )
921924
922925 log .Debugf ("Sending TLV for funding asset output to remote party: %v" ,
923- limitSpewer .Sdump (fundingAsset ))
926+ limitSpewer .Sdump (fundingOut . Asset ))
924927
925928 err = f .cfg .PeerMessenger .SendMessage (ctx , peerPub , assetOutputMsg )
926929 if err != nil {
@@ -1167,12 +1170,22 @@ func (f *FundingController) completeChannelFunding(ctx context.Context,
11671170 fundingPackets := fundedVpkt .VPackets
11681171 for idx := range fundingPackets {
11691172 fundingPkt := fundingPackets [idx ]
1170- fundingPkt .Outputs [0 ].AnchorOutputBip32Derivation = nil
1171- fundingPkt .Outputs [0 ].AnchorOutputTaprootBip32Derivation = nil
1173+
1174+ // The funding output is the first non-split output (the split
1175+ // output is only present if there is change from the channel
1176+ // funding).
1177+ fundingOut , err := fundingPkt .FirstNonSplitRootOutput ()
1178+ if err != nil {
1179+ return nil , fmt .Errorf ("unable to find funding output " +
1180+ "in funded packet: %w" , err )
1181+ }
1182+
1183+ fundingOut .AnchorOutputBip32Derivation = nil
1184+ fundingOut .AnchorOutputTaprootBip32Derivation = nil
11721185 fundingInternalKeyDesc := keychain.KeyDescriptor {
11731186 PubKey : fundingInternalKey ,
11741187 }
1175- fundingPkt . Outputs [ 0 ] .SetAnchorInternalKey (
1188+ fundingOut .SetAnchorInternalKey (
11761189 fundingInternalKeyDesc , f .cfg .ChainParams .HDCoinType ,
11771190 )
11781191 }
@@ -1617,11 +1630,16 @@ func (f *FundingController) processFundingReq(fundingFlows fundingFlowIndex,
16171630 // we can derive the tapscript root that'll be used alongside the
16181631 // internal key (which we'll only learn from lnd later as we finalize
16191632 // the funding PSBT).
1620- fundingAssets := fn .Map (
1621- fundingVpkt .VPackets , func (pkt * tappsbt.VPacket ) * asset.Asset {
1622- return pkt .Outputs [0 ].Asset .Copy ()
1623- },
1624- )
1633+ fundingAssets := make ([]* asset.Asset , 0 , len (fundingVpkt .VPackets ))
1634+ for _ , pkt := range fundingVpkt .VPackets {
1635+ fundingOut , err := pkt .FirstNonSplitRootOutput ()
1636+ if err != nil {
1637+ return fmt .Errorf ("unable to find funding output in " +
1638+ "packet: %w" , err )
1639+ }
1640+
1641+ fundingAssets = append (fundingAssets , fundingOut .Asset .Copy ())
1642+ }
16251643 fundingCommitVersion , err := tappsbt .CommitmentVersion (
16261644 fundingVpkt .VPackets [0 ].Version ,
16271645 )
0 commit comments