Skip to content

Commit

Permalink
Merge pull request #656 from chengwenxi/release0.7
Browse files Browse the repository at this point in the history
Add broadcast command in bank
  • Loading branch information
HaoyangLiu committed Nov 19, 2018
2 parents 7d2cd13 + e8ed3f4 commit 0c26e63
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
36 changes: 36 additions & 0 deletions client/bank/cli/broadcast.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package cli

import (
"github.com/irisnet/irishub/client/context"
"github.com/spf13/cobra"
amino "github.com/tendermint/go-amino"
)

// GetSignCommand returns the sign command
func GetBroadcastCommand(codec *amino.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "broadcast <file>",
Short: "Broadcast transactions generated offline",
Long: `Broadcast transactions created with the --generate-only flag and signed with the sign command.
Read a transaction from <file> and broadcast it to a node.`,
Example: "iriscli bank broadcast <file>",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
cliCtx := context.NewCLIContext().WithCodec(codec)
stdTx, err := readAndUnmarshalStdTx(cliCtx.Codec, args[0])
if err != nil {
return
}

txBytes, err := cliCtx.Codec.MarshalBinaryLengthPrefixed(stdTx)
if err != nil {
return
}

_, err = cliCtx.BroadcastTx(txBytes)
return err
},
}

return cmd
}
1 change: 1 addition & 0 deletions client/bank/cli/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Read a transaction from <file>, sign it, and print its JSON encoding.
The --offline flag makes sure that the client will not reach out to the local cache.
Thus account number or sequence number lookups will not be performed and it is
recommended to set such parameters manually.`,
Example: "iriscli bank sign <file> --name <key name> --chain-id=<chain-id>",
RunE: makeSignCmd(codec, decoder),
Args: cobra.ExactArgs(1),
}
Expand Down
1 change: 1 addition & 0 deletions cmd/iriscli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func main() {
client.PostCommands(
bankcmd.SendTxCmd(cdc),
bankcmd.GetSignCommand(cdc, authcmd.GetAccountDecoder(cdc)),
bankcmd.GetBroadcastCommand(cdc),
)...)
rootCmd.AddCommand(
bankCmd,
Expand Down

0 comments on commit 0c26e63

Please sign in to comment.