11package chanbackup
22
33import (
4+ "context"
45 "fmt"
56
67 "github.com/btcsuite/btcd/wire"
@@ -24,15 +25,17 @@ type LiveChannelSource interface {
2425// passed open channel. The backup includes all information required to restore
2526// the channel, as well as addressing information so we can find the peer and
2627// reconnect to them to initiate the protocol.
27- func assembleChanBackup (addrSource channeldb.AddrSource ,
28+ func assembleChanBackup (ctx context. Context , addrSource channeldb.AddrSource ,
2829 openChan * channeldb.OpenChannel ) (* Single , error ) {
2930
3031 log .Debugf ("Crafting backup for ChannelPoint(%v)" ,
3132 openChan .FundingOutpoint )
3233
3334 // First, we'll query the channel source to obtain all the addresses
3435 // that are associated with the peer for this channel.
35- known , nodeAddrs , err := addrSource .AddrsForNode (openChan .IdentityPub )
36+ known , nodeAddrs , err := addrSource .AddrsForNode (
37+ ctx , openChan .IdentityPub ,
38+ )
3639 if err != nil {
3740 return nil , err
3841 }
@@ -90,7 +93,8 @@ func buildCloseTxInputs(
9093// FetchBackupForChan attempts to create a plaintext static channel backup for
9194// the target channel identified by its channel point. If we're unable to find
9295// the target channel, then an error will be returned.
93- func FetchBackupForChan (chanPoint wire.OutPoint , chanSource LiveChannelSource ,
96+ func FetchBackupForChan (ctx context.Context , chanPoint wire.OutPoint ,
97+ chanSource LiveChannelSource ,
9498 addrSource channeldb.AddrSource ) (* Single , error ) {
9599
96100 // First, we'll query the channel source to see if the channel is known
@@ -104,7 +108,7 @@ func FetchBackupForChan(chanPoint wire.OutPoint, chanSource LiveChannelSource,
104108
105109 // Once we have the target channel, we can assemble the backup using
106110 // the source to obtain any extra information that we may need.
107- staticChanBackup , err := assembleChanBackup (addrSource , targetChan )
111+ staticChanBackup , err := assembleChanBackup (ctx , addrSource , targetChan )
108112 if err != nil {
109113 return nil , fmt .Errorf ("unable to create chan backup: %w" , err )
110114 }
@@ -114,7 +118,7 @@ func FetchBackupForChan(chanPoint wire.OutPoint, chanSource LiveChannelSource,
114118
115119// FetchStaticChanBackups will return a plaintext static channel back up for
116120// all known active/open channels within the passed channel source.
117- func FetchStaticChanBackups (chanSource LiveChannelSource ,
121+ func FetchStaticChanBackups (ctx context. Context , chanSource LiveChannelSource ,
118122 addrSource channeldb.AddrSource ) ([]Single , error ) {
119123
120124 // First, we'll query the backup source for information concerning all
@@ -129,7 +133,7 @@ func FetchStaticChanBackups(chanSource LiveChannelSource,
129133 // channel.
130134 staticChanBackups := make ([]Single , 0 , len (openChans ))
131135 for _ , openChan := range openChans {
132- chanBackup , err := assembleChanBackup (addrSource , openChan )
136+ chanBackup , err := assembleChanBackup (ctx , addrSource , openChan )
133137 if err != nil {
134138 return nil , err
135139 }
0 commit comments