-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #656 from chengwenxi/release0.7
Add broadcast command in bank
- Loading branch information
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters