@@ -167,6 +167,7 @@ func (c *sweepTimeLockManualCommand) Execute(_ *cobra.Command, _ []string) error
167
167
startNumChannelsTotal uint16
168
168
maxNumChannelsTotal = c .MaxNumChannelsTotal
169
169
remoteRevocationBasePoint = c .RemoteRevocationBasePoint
170
+ multiSigIdx uint32
170
171
)
171
172
172
173
// We either support specifying the remote revocation base point
@@ -210,7 +211,16 @@ func (c *sweepTimeLockManualCommand) Execute(_ *cobra.Command, _ []string) error
210
211
211
212
startNumChannelsTotal = uint16 (delayPath [4 ])
212
213
maxNumChannelsTotal = startNumChannelsTotal + 1
213
-
214
+ multiSigKeyPath , err := lnd .ParsePath (
215
+ backupChan .LocalChanCfg .MultiSigKey .Path ,
216
+ )
217
+ if err != nil {
218
+ return fmt .Errorf ("error parsing multisigkey path: %w" , err )
219
+ }
220
+ if len (multiSigKeyPath ) != 5 {
221
+ return fmt .Errorf ("invalid delay path '%v'" , multiSigKeyPath )
222
+ }
223
+ multiSigIdx = multiSigKeyPath [4 ]
214
224
case c .ChannelBackup != "" && c .RemoteRevocationBasePoint != "" :
215
225
return errors .New ("cannot use both --frombackup and " +
216
226
"--remoterevbasepoint at the same time" )
@@ -230,14 +240,14 @@ func (c *sweepTimeLockManualCommand) Execute(_ *cobra.Command, _ []string) error
230
240
231
241
return sweepTimeLockManual (
232
242
extendedKey , c .APIURL , c .SweepAddr , c .TimeLockAddr ,
233
- remoteRevPoint , startCsvLimit , maxCsvLimit ,
243
+ remoteRevPoint , multiSigIdx , startCsvLimit , maxCsvLimit ,
234
244
startNumChannelsTotal , maxNumChannelsTotal ,
235
245
c .MaxNumChanUpdates , c .Publish , c .FeeRate ,
236
246
)
237
247
}
238
248
239
249
func sweepTimeLockManual (extendedKey * hdkeychain.ExtendedKey , apiURL string ,
240
- sweepAddr , timeLockAddr string , remoteRevPoint * btcec.PublicKey ,
250
+ sweepAddr , timeLockAddr string , remoteRevPoint * btcec.PublicKey , multiSigIdx uint32 ,
241
251
startCsvTimeout , maxCsvTimeout , startNumChannels , maxNumChannels uint16 ,
242
252
maxNumChanUpdates uint64 , publish bool , feeRate uint32 ) error {
243
253
@@ -302,7 +312,7 @@ func sweepTimeLockManual(extendedKey *hdkeychain.ExtendedKey, apiURL string,
302
312
)
303
313
for i := startNumChannels ; i < maxNumChannels ; i ++ {
304
314
csvTimeout , script , scriptHash , commitPoint , delayDesc , err = tryKey (
305
- baseKey , remoteRevPoint , startCsvTimeout , maxCsvTimeout ,
315
+ baseKey , remoteRevPoint , multiSigIdx , startCsvTimeout , maxCsvTimeout ,
306
316
lockScript , uint32 (i ), maxNumChanUpdates ,
307
317
)
308
318
@@ -413,7 +423,7 @@ func sweepTimeLockManual(extendedKey *hdkeychain.ExtendedKey, apiURL string,
413
423
}
414
424
415
425
func tryKey (baseKey * hdkeychain.ExtendedKey , remoteRevPoint * btcec.PublicKey ,
416
- startCsvTimeout , maxCsvTimeout uint16 , lockScript []byte , idx uint32 ,
426
+ multiSigIdx uint32 , startCsvTimeout , maxCsvTimeout uint16 , lockScript []byte , idx uint32 ,
417
427
maxNumChanUpdates uint64 ) (int32 , []byte , []byte , * btcec.PublicKey ,
418
428
* keychain.KeyDescriptor , error ) {
419
429
@@ -491,11 +501,13 @@ func tryKey(baseKey *hdkeychain.ExtendedKey, remoteRevPoint *btcec.PublicKey,
491
501
keychain .KeyFamilyRevocationRoot ,
492
502
)), 0 , idx ,
493
503
}
494
-
504
+ if multiSigIdx == 0 {
505
+ multiSigIdx = idx
506
+ }
495
507
// Now we try the same with the new revocation producer format.
496
508
multiSigPath := []uint32 {
497
509
lnd .HardenedKey (uint32 (keychain .KeyFamilyMultiSig )),
498
- 0 , idx ,
510
+ 0 , multiSigIdx ,
499
511
}
500
512
multiSigPrivKey , err := lnd .PrivKeyFromPath (baseKey , multiSigPath )
501
513
if err != nil {
0 commit comments