41
41
nonceFlag = flag .NewUint64VarP ("nonce" , "n" , 0 , "set nonce (default using pending nonce)" )
42
42
signerFlag = flag .NewStringVarP ("signer" , "s" , "" , "choose a signing account" )
43
43
bytecodeFlag = flag .NewStringVarP ("bytecode" , "b" , "" , "set the byte code" )
44
+ yesFlag = flag .BoolVarP ("assume-yes" , "y" , false , " answer yes for all confirmations" )
45
+ passwordFlag = flag .NewStringVarP ("password" , "P" , "" , "input password for account" )
44
46
)
45
47
46
48
// ActionCmd represents the action command
@@ -89,6 +91,8 @@ func registerWriteCommand(cmd *cobra.Command) {
89
91
gasPriceFlag .RegisterCommand (cmd )
90
92
signerFlag .RegisterCommand (cmd )
91
93
nonceFlag .RegisterCommand (cmd )
94
+ yesFlag .RegisterCommand (cmd )
95
+ passwordFlag .RegisterCommand (cmd )
92
96
}
93
97
94
98
// gasPriceInRau returns the suggest gas price
@@ -187,15 +191,18 @@ func sendAction(elp action.Envelope, signer string) error {
187
191
return err
188
192
}
189
193
prvKey , err = crypto .HexStringToPrivateKey (prvKeyOrPassword )
190
- } else {
194
+ } else if passwordFlag . Value () == "" {
191
195
fmt .Printf ("Enter password #%s:\n " , signer )
192
196
prvKeyOrPassword , err = util .ReadSecretFromStdin ()
193
197
if err != nil {
194
198
log .L ().Error ("failed to get password" , zap .Error (err ))
195
199
return err
196
200
}
197
- prvKey , err = account .KsAccountToPrivateKey (signer , prvKeyOrPassword )
201
+ } else {
202
+ prvKeyOrPassword = passwordFlag .Value ().(string )
198
203
}
204
+ prvKey , err = account .KsAccountToPrivateKey (signer , prvKeyOrPassword )
205
+
199
206
if err != nil {
200
207
return err
201
208
}
@@ -215,13 +222,15 @@ func sendAction(elp action.Envelope, signer string) error {
215
222
if err != nil {
216
223
return err
217
224
}
218
- var confirm string
219
- fmt .Println ("\n " + actionInfo + "\n " +
220
- "Please confirm your action.\n " +
221
- "Type 'YES' to continue, quit for anything else." )
222
- fmt .Scanf ("%s" , & confirm )
223
- if confirm != "YES" && confirm != "yes" {
224
- return nil
225
+ if yesFlag .Value () == false {
226
+ var confirm string
227
+ fmt .Println ("\n " + actionInfo + "\n " +
228
+ "Please confirm your action.\n " +
229
+ "Type 'YES' to continue, quit for anything else." )
230
+ fmt .Scanf ("%s" , & confirm )
231
+ if confirm != "YES" && confirm != "yes" {
232
+ return nil
233
+ }
225
234
}
226
235
fmt .Println ()
227
236
return sendRaw (selp )
0 commit comments