@@ -484,8 +484,9 @@ func (a *AuxChanCloser) ShutdownBlob(
484
484
none := lfn .None [lnwire.CustomRecords ]()
485
485
486
486
// If there's no custom blob, then we don't need to do anything.
487
- if req .CommitBlob .IsNone () {
488
- log .Debugf ("No commit blob for ChannelPoint(%v)" , req .ChanPoint )
487
+ if req .FundingBlob .IsNone () {
488
+ log .Debugf ("No funding blob for ChannelPoint(%v)" ,
489
+ req .ChanPoint )
489
490
return none , nil
490
491
}
491
492
@@ -500,16 +501,16 @@ func (a *AuxChanCloser) ShutdownBlob(
500
501
log .Infof ("Creating shutdown blob for close of ChannelPoint(%v)" ,
501
502
req .ChanPoint )
502
503
503
- // Otherwise, we'll decode the commitment , so we can examine the current
504
- // state .
505
- var commitState tapchannelmsg.Commitment
506
- err = lfn .MapOptionZ (req .CommitBlob , func (blob tlv.Blob ) error {
507
- c , err := tapchannelmsg .DecodeCommitment (blob )
504
+ // Otherwise, we'll decode the funding state , so we can examine the
505
+ // different asset IDs in the channel .
506
+ var fundingState tapchannelmsg.OpenChannel
507
+ err = lfn .MapOptionZ (req .FundingBlob , func (blob tlv.Blob ) error {
508
+ c , err := tapchannelmsg .DecodeOpenChannel (blob )
508
509
if err != nil {
509
510
return err
510
511
}
511
512
512
- commitState = * c
513
+ fundingState = * c
513
514
514
515
return nil
515
516
})
@@ -528,38 +529,34 @@ func (a *AuxChanCloser) ShutdownBlob(
528
529
return none , err
529
530
}
530
531
531
- // Next, we'll collect all the assets that we own in this channel.
532
- assets := commitState .LocalAssets .Val .Outputs
532
+ // Next, we'll collect all the asset IDs that were committed to the
533
+ // channel.
534
+ assetIDs := fn .Map (
535
+ fundingState .FundedAssets .Val .Outputs ,
536
+ func (o * tapchannelmsg.AssetOutput ) asset.ID {
537
+ return o .AssetID .Val
538
+ },
539
+ )
533
540
534
541
// Now that we have all the asset IDs, we'll query for a new key for
535
542
// each of them which we'll use as both the internal key and the script
536
543
// key.
537
544
scriptKeys := make (tapchannelmsg.ScriptKeyMap )
538
- for idx := range assets {
539
- channelAsset := assets [idx ]
540
-
545
+ for _ , assetID := range assetIDs {
541
546
newKey , err := a .cfg .AddrBook .NextScriptKey (
542
547
ctx , asset .TaprootAssetsKeyFamily ,
543
548
)
544
549
if err != nil {
545
550
return none , err
546
551
}
547
552
548
- // We now add the a
549
- // TODO(guggero): This only works if there's only a single asset
550
- // in the channel. We need to extend this to support multiple
551
- // assets.
552
- _ , err = a .cfg .AddrBook .NewAddressWithKeys (
553
- ctx , address .V1 , channelAsset .AssetID .Val ,
554
- channelAsset .Amount .Val , newKey , newInternalKey , nil ,
555
- * a .cfg .DefaultCourierAddr ,
556
- )
553
+ err = a .cfg .AddrBook .InsertScriptKey (ctx , newKey , true )
557
554
if err != nil {
558
- return none , fmt .Errorf ("error adding new address: %w" ,
559
- err )
555
+ return none , fmt .Errorf ("error declaring script key: " +
556
+ "%w" , err )
560
557
}
561
558
562
- scriptKeys [channelAsset . AssetID . Val ] = * newKey .PubKey
559
+ scriptKeys [assetID ] = * newKey .PubKey
563
560
}
564
561
565
562
// Finally, we'll map the extra shutdown info to a TLV record map we
0 commit comments