Encaptulate Get Passphrase Logic in Builder
This commit is contained in:
@@ -124,7 +124,12 @@ func SignAndBuild(name, passphrase string, msg sdk.Msg, cdc *wire.Codec) ([]byte
|
||||
}
|
||||
|
||||
// sign and build the transaction from the msg
|
||||
func SignBuildBroadcast(name string, passphrase string, msg sdk.Msg, cdc *wire.Codec) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
func SignBuildBroadcast(name string, msg sdk.Msg, cdc *wire.Codec) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
passphrase, err := GetPassphraseFromStdin(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
txBytes, err := SignAndBuild(name, passphrase, msg, cdc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -132,3 +137,10 @@ func SignBuildBroadcast(name string, passphrase string, msg sdk.Msg, cdc *wire.C
|
||||
|
||||
return BroadcastTx(txBytes)
|
||||
}
|
||||
|
||||
// get passphrase from std input
|
||||
func GetPassphraseFromStdin(name string) (pass string, err error) {
|
||||
buf := client.BufferStdin()
|
||||
prompt := fmt.Sprintf("Password to sign with '%s':", name)
|
||||
return client.GetPassword(prompt, buf)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user