@@ -169,19 +169,22 @@ func (c *triggerForceCloseCommand) Execute(_ *cobra.Command, _ []string) error {
169
169
pubKeys []string
170
170
outputs []string
171
171
)
172
- for _ , openChan := range channels {
172
+ for idx , openChan := range channels {
173
173
addr := pickAddr (openChan .Node2Info .Node .Addresses )
174
174
peerAddr := fmt .Sprintf ("%s@%s" , openChan .Node2 , addr )
175
175
log .Infof ("Attempting to force close channel %s with " +
176
- "peer %s" , openChan .ChanPoint , peerAddr )
176
+ "peer %s (channel %d of %d)" ,
177
+ openChan .ChanPoint , peerAddr , idx + 1 ,
178
+ len (channels ))
177
179
178
180
outputAddrs , err := closeChannel (
179
181
identityPriv , api , openChan .ChanPoint ,
180
182
peerAddr , c .TorProxy ,
181
183
)
182
184
if err != nil {
183
185
log .Errorf ("Error closing channel %s, " +
184
- "skipping: %v" , openChan .ChanPoint , err )
186
+ "skipping and trying next one. " +
187
+ "Reason: %v" , openChan .ChanPoint , err )
185
188
continue
186
189
}
187
190
@@ -262,13 +265,21 @@ func closeChannel(identityPriv *btcec.PrivateKey, api *btc.ExplorerAPI,
262
265
if err != nil {
263
266
return nil , fmt .Errorf ("error getting spends: %w" , err )
264
267
}
268
+
269
+ counter := 0
265
270
for len (spends ) == 0 {
266
271
log .Infof ("No spends found yet, waiting 5 seconds..." )
267
272
time .Sleep (5 * time .Second )
268
273
spends , err = api .Spends (channelAddress )
269
274
if err != nil {
270
275
return nil , fmt .Errorf ("error getting spends: %w" , err )
271
276
}
277
+
278
+ counter ++
279
+ if counter >= 12 {
280
+ return nil , fmt .Errorf ("no spends found after 60 " +
281
+ "seconds, aborting re-try loop" )
282
+ }
272
283
}
273
284
274
285
log .Infof ("Found force close transaction %v" , spends [0 ].TXID )
0 commit comments