66	"encoding/json" 
77	"fmt" 
88	"io/ioutil" 
9+ 	"os" 
910	"time" 
1011
1112	"github.com/lightninglabs/chantools/lnd" 
@@ -20,6 +21,8 @@ type zombieRecoveryPrepareKeysCommand struct {
2021	MatchFile   string 
2122	PayoutAddr  string 
2223
24+ 	NumKeys  uint32 
25+ 
2326	rootKey  * rootKey 
2427	cmd      * cobra.Command 
2528}
@@ -47,7 +50,12 @@ correct ones for the matched channels.`,
4750	cc .cmd .Flags ().StringVar (
4851		& cc .PayoutAddr , "payout_addr" , "" , "the address where this " + 
4952			"node's rescued funds should be sent to, must be a " + 
50- 			"P2WPKH (native SegWit) address" )
53+ 			"P2WPKH (native SegWit) address" ,
54+ 	)
55+ 	cc .cmd .Flags ().Uint32Var (
56+ 		& cc .NumKeys , "num_keys" , numMultisigKeys , "the number of " + 
57+ 			"multisig keys to derive" ,
58+ 	)
5159
5260	cc .rootKey  =  newRootKey (cc .cmd , "deriving the multisig keys" )
5361
@@ -108,9 +116,9 @@ func (c *zombieRecoveryPrepareKeysCommand) Execute(_ *cobra.Command,
108116	}
109117
110118	// Derive all 2500 keys now, this might take a while. 
111- 	for  index  :=  0 ; index  <  numMultisigKeys ; index ++  {
119+ 	for  index  :=  uint32 ( 0 ) ; index  <  c . NumKeys ; index ++  {
112120		_ , pubKey , _ , err  :=  lnd .DeriveKey (
113- 			extendedKey , lnd .MultisigPath (chainParams , index ),
121+ 			extendedKey , lnd .MultisigPath (chainParams , int ( index ) ),
114122			chainParams ,
115123		)
116124		if  err  !=  nil  {
@@ -134,5 +142,5 @@ func (c *zombieRecoveryPrepareKeysCommand) Execute(_ *cobra.Command,
134142	fileName  :=  fmt .Sprintf ("results/preparedkeys-%s-%s.json" ,
135143		time .Now ().Format ("2006-01-02" ), pubKeyStr )
136144	log .Infof ("Writing result to %s" , fileName )
137- 	return  ioutil .WriteFile (fileName , matchBytes , 0644 )
145+ 	return  os .WriteFile (fileName , matchBytes , 0644 )
138146}
0 commit comments