Skip to content

Commit f23996c

Browse files
MrChicolivnev
authored andcommitted
ethsign: index of ledger
@Rain says: This could be done differently, for example by giving a range in the derivation path m/44'/60'/0'/0/0..5 - indexes 0 through 5 m/44'/60'/0'/0/1 - only index 1
1 parent 9562f05 commit f23996c

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

src/ethsign/ethsign.go

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Scan:
8989
}
9090
} else if x.URL().Scheme == "ledger" {
9191
x.Open("")
92-
for j := 0; j <= 3; j++ {
92+
for j := 0; j <= c.Int("n"); j++ {
9393
pathstr := fmt.Sprintf(c.String("hd-path") + "/%d", j)
9494
path, _ := accounts.ParseDerivationPath(pathstr)
9595
y, err := x.Derive(path, true)
@@ -212,6 +212,11 @@ func main() {
212212
EnvVar: "ETH_HDPATH",
213213
Value: defaultHDPath,
214214
},
215+
cli.IntFlag{
216+
Name: "n",
217+
Usage: "maximum ledger index",
218+
Value: 5,
219+
},
215220
},
216221
Action: func(c *cli.Context) error {
217222
wallets := getWallets(c, defaultKeyStores)
@@ -222,7 +227,7 @@ func main() {
222227
}
223228
} else if x.URL().Scheme == "ledger" {
224229
x.Open("")
225-
for j := 0; j <= 3; j++ {
230+
for j := 0; j <= c.Int("n"); j++ {
226231
pathstr := fmt.Sprintf(c.String("hd-path") + "/%d", j)
227232
path, _ := accounts.ParseDerivationPath(pathstr)
228233
z, err := x.Derive(path, false)
@@ -256,6 +261,11 @@ func main() {
256261
EnvVar: "ETH_HDPATH",
257262
Value: defaultHDPath,
258263
},
264+
cli.IntFlag{
265+
Name: "n",
266+
Usage: "maximum ledger index",
267+
Value: 5,
268+
},
259269
cli.BoolFlag{
260270
Name: "create",
261271
Usage: "make a contract creation transaction",
@@ -377,11 +387,16 @@ func main() {
377387
Value: &defaultKeyStores,
378388
},
379389
cli.StringFlag{
380-
Name: "hd-path",
381-
Usage: "hd derivation path",
382-
EnvVar: "ETH_HDPATH",
383-
Value: defaultHDPath,
384-
},
390+
Name: "hd-path",
391+
Usage: "hd derivation path",
392+
EnvVar: "ETH_HDPATH",
393+
Value: defaultHDPath,
394+
},
395+
cli.IntFlag{
396+
Name: "n",
397+
Usage: "maximum ledger index",
398+
Value: 5,
399+
},
385400
cli.StringFlag{
386401
Name: "from",
387402
Usage: "address of signing account",

0 commit comments

Comments
 (0)