Skip to content

Commit

Permalink
Draft broadcast command #1954
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessio Treglia committed Sep 5, 2018
1 parent 0ada320 commit bfc5747
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions x/auth/client/cli/broadcast.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package cli

import (
"os"

"github.com/cosmos/cosmos-sdk/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.`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
cliCtx := context.NewCLIContext().WithCodec(codec).WithLogger(os.Stdout)
stdTx, err := readAndUnmarshalStdTx(cliCtx.Codec, args[0])
if err != nil {
return
}
txBytes, err := cliCtx.Codec.MarshalBinary(stdTx)
if err != nil {
return
}
return cliCtx.EnsureBroadcastTx(txBytes)
},
}
return cmd
}

0 comments on commit bfc5747

Please sign in to comment.