@@ -914,13 +914,16 @@ func (f *FundingController) sendInputOwnershipProofs(peerPub btcec.PublicKey,
914
914
// We'll now send the signed inputs to the remote party.
915
915
//
916
916
// 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
+ }
918
921
assetOutputMsg := cmsg .NewTxAssetOutputProof (
919
- fundingState .pid , * fundingAsset , true ,
922
+ fundingState .pid , * fundingOut . Asset , true ,
920
923
)
921
924
922
925
log .Debugf ("Sending TLV for funding asset output to remote party: %v" ,
923
- limitSpewer .Sdump (fundingAsset ))
926
+ limitSpewer .Sdump (fundingOut . Asset ))
924
927
925
928
err = f .cfg .PeerMessenger .SendMessage (ctx , peerPub , assetOutputMsg )
926
929
if err != nil {
@@ -1167,12 +1170,22 @@ func (f *FundingController) completeChannelFunding(ctx context.Context,
1167
1170
fundingPackets := fundedVpkt .VPackets
1168
1171
for idx := range fundingPackets {
1169
1172
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
1172
1185
fundingInternalKeyDesc := keychain.KeyDescriptor {
1173
1186
PubKey : fundingInternalKey ,
1174
1187
}
1175
- fundingPkt . Outputs [ 0 ] .SetAnchorInternalKey (
1188
+ fundingOut .SetAnchorInternalKey (
1176
1189
fundingInternalKeyDesc , f .cfg .ChainParams .HDCoinType ,
1177
1190
)
1178
1191
}
@@ -1614,11 +1627,16 @@ func (f *FundingController) processFundingReq(fundingFlows fundingFlowIndex,
1614
1627
// we can derive the tapscript root that'll be used alongside the
1615
1628
// internal key (which we'll only learn from lnd later as we finalize
1616
1629
// the funding PSBT).
1617
- fundingAssets := fn .Map (
1618
- fundingVpkt .VPackets , func (pkt * tappsbt.VPacket ) * asset.Asset {
1619
- return pkt .Outputs [0 ].Asset .Copy ()
1620
- },
1621
- )
1630
+ fundingAssets := make ([]* asset.Asset , 0 , len (fundingVpkt .VPackets ))
1631
+ for _ , pkt := range fundingVpkt .VPackets {
1632
+ fundingOut , err := pkt .FirstNonSplitRootOutput ()
1633
+ if err != nil {
1634
+ return fmt .Errorf ("unable to find funding output in " +
1635
+ "packet: %w" , err )
1636
+ }
1637
+
1638
+ fundingAssets = append (fundingAssets , fundingOut .Asset .Copy ())
1639
+ }
1622
1640
fundingCommitVersion , err := tappsbt .CommitmentVersion (
1623
1641
fundingVpkt .VPackets [0 ].Version ,
1624
1642
)
0 commit comments