@@ -26,31 +26,31 @@ import (
2626 "github.com/XinFinOrg/XDPoSChain/console"
2727 "github.com/XinFinOrg/XDPoSChain/crypto"
2828 "github.com/XinFinOrg/XDPoSChain/log"
29- "gopkg.in /urfave/cli.v1 "
29+ "github.com /urfave/cli/v2 "
3030)
3131
3232var (
33- walletCommand = cli.Command {
33+ walletCommand = & cli.Command {
3434 Name : "wallet" ,
3535 Usage : "Manage XDPoSChain presale wallets" ,
3636 ArgsUsage : "" ,
37- Category : "ACCOUNT COMMANDS" ,
3837 Description : `
3938 XDC wallet import /path/to/my/presale.wallet
4039
4140will prompt for your password and imports your ether presale account.
4241It can be used non-interactively with the --password option taking a
4342passwordfile as argument containing the wallet password in plaintext.` ,
44- Subcommands : []cli.Command {
43+ Subcommands : []* cli.Command {
4544 {
4645
4746 Name : "import" ,
4847 Usage : "Import XDPoSChain presale wallet" ,
4948 ArgsUsage : "<keyFile>" ,
50- Action : utils . MigrateFlags ( importWallet ) ,
49+ Action : importWallet ,
5150 Category : "ACCOUNT COMMANDS" ,
5251 Flags : []cli.Flag {
5352 utils .DataDirFlag ,
53+ utils .XDCXDataDirFlag ,
5454 utils .KeyStoreDirFlag ,
5555 utils .PasswordFileFlag ,
5656 utils .LightKDFFlag ,
@@ -65,10 +65,9 @@ passwordfile as argument containing the wallet password in plaintext.`,
6565 },
6666 }
6767
68- accountCommand = cli.Command {
69- Name : "account" ,
70- Usage : "Manage accounts" ,
71- Category : "ACCOUNT COMMANDS" ,
68+ accountCommand = & cli.Command {
69+ Name : "account" ,
70+ Usage : "Manage accounts" ,
7271 Description : `
7372
7473Manage accounts, list all existing accounts, import a private key into a new
@@ -89,13 +88,14 @@ It is safe to transfer the entire directory or the individual keys therein
8988between ethereum nodes by simply copying.
9089
9190Make sure you backup your keys regularly.` ,
92- Subcommands : []cli.Command {
91+ Subcommands : []* cli.Command {
9392 {
9493 Name : "list" ,
9594 Usage : "Print summary of existing accounts" ,
96- Action : utils . MigrateFlags ( accountList ) ,
95+ Action : accountList ,
9796 Flags : []cli.Flag {
9897 utils .DataDirFlag ,
98+ utils .XDCXDataDirFlag ,
9999 utils .KeyStoreDirFlag ,
100100 },
101101 Description : `
@@ -104,9 +104,10 @@ Print a short summary of all accounts`,
104104 {
105105 Name : "new" ,
106106 Usage : "Create a new account" ,
107- Action : utils . MigrateFlags ( accountCreate ) ,
107+ Action : accountCreate ,
108108 Flags : []cli.Flag {
109109 utils .DataDirFlag ,
110+ utils .XDCXDataDirFlag ,
110111 utils .KeyStoreDirFlag ,
111112 utils .PasswordFileFlag ,
112113 utils .LightKDFFlag ,
@@ -129,10 +130,11 @@ password to file or expose in any other way.
129130 {
130131 Name : "update" ,
131132 Usage : "Update an existing account" ,
132- Action : utils . MigrateFlags ( accountUpdate ) ,
133+ Action : accountUpdate ,
133134 ArgsUsage : "<address>" ,
134135 Flags : []cli.Flag {
135136 utils .DataDirFlag ,
137+ utils .XDCXDataDirFlag ,
136138 utils .KeyStoreDirFlag ,
137139 utils .LightKDFFlag ,
138140 },
@@ -158,9 +160,10 @@ changing your password is only possible interactively.
158160 {
159161 Name : "import" ,
160162 Usage : "Import a private key into a new account" ,
161- Action : utils . MigrateFlags ( accountImport ) ,
163+ Action : accountImport ,
162164 Flags : []cli.Flag {
163165 utils .DataDirFlag ,
166+ utils .XDCXDataDirFlag ,
164167 utils .KeyStoreDirFlag ,
165168 utils .PasswordFileFlag ,
166169 utils .LightKDFFlag ,
@@ -293,7 +296,7 @@ func ambiguousAddrRecovery(ks *keystore.KeyStore, err *keystore.AmbiguousAddrErr
293296func accountCreate (ctx * cli.Context ) error {
294297 cfg := XDCConfig {Node : defaultNodeConfig ()}
295298 // Load config file.
296- if file := ctx .GlobalString (configFileFlag .Name ); file != "" {
299+ if file := ctx .String (configFileFlag .Name ); file != "" {
297300 if err := loadConfig (file , & cfg ); err != nil {
298301 utils .Fatalf ("%v" , err )
299302 }
@@ -319,13 +322,13 @@ func accountCreate(ctx *cli.Context) error {
319322// accountUpdate transitions an account from a previous format to the current
320323// one, also providing the possibility to change the pass-phrase.
321324func accountUpdate (ctx * cli.Context ) error {
322- if len ( ctx .Args ()) == 0 {
325+ if ctx .Args (). Len ( ) == 0 {
323326 utils .Fatalf ("No accounts specified to update" )
324327 }
325328 stack , _ := makeConfigNode (ctx )
326329 ks := stack .AccountManager ().Backends (keystore .KeyStoreType )[0 ].(* keystore.KeyStore )
327330
328- for _ , addr := range ctx .Args () {
331+ for _ , addr := range ctx .Args (). Slice () {
329332 account , oldPassword := unlockAccount (ctx , ks , addr , 0 , nil )
330333 newPassword := getPassPhrase ("Please give a new password. Do not forget this password." , true , 0 , nil )
331334 if err := ks .Update (account , oldPassword , newPassword ); err != nil {
@@ -336,10 +339,10 @@ func accountUpdate(ctx *cli.Context) error {
336339}
337340
338341func importWallet (ctx * cli.Context ) error {
339- keyfile := ctx .Args ().First ()
340- if len (keyfile ) == 0 {
341- utils .Fatalf ("keyfile must be given as argument" )
342+ if ctx .Args ().Len () != 1 {
343+ utils .Fatalf ("keyfile must be given as the only argument" )
342344 }
345+ keyfile := ctx .Args ().First ()
343346 keyJson , err := os .ReadFile (keyfile )
344347 if err != nil {
345348 utils .Fatalf ("Could not read wallet file: %v" , err )
@@ -358,10 +361,10 @@ func importWallet(ctx *cli.Context) error {
358361}
359362
360363func accountImport (ctx * cli.Context ) error {
361- keyfile := ctx .Args ().First ()
362- if len (keyfile ) == 0 {
363- utils .Fatalf ("keyfile must be given as argument" )
364+ if ctx .Args ().Len () != 1 {
365+ utils .Fatalf ("keyfile must be given as the only argument" )
364366 }
367+ keyfile := ctx .Args ().First ()
365368 key , err := crypto .LoadECDSA (keyfile )
366369 if err != nil {
367370 utils .Fatalf ("Failed to load the private key: %v" , err )
0 commit comments