github.com/lino-network/lino@v0.6.11/client/broadcastcmd.go (about) 1 package client 2 3 import ( 4 "encoding/hex" 5 "fmt" 6 7 // "strings" 8 9 "github.com/spf13/cobra" 10 // "github.com/spf13/viper" 11 "github.com/cosmos/cosmos-sdk/codec" 12 13 linotypes "github.com/lino-network/lino/types" 14 ) 15 16 // GetCmdBoradcast - 17 func GetCmdBroadcast(cdc *codec.Codec) *cobra.Command { 18 cmd := &cobra.Command{ 19 Use: "broadcast", 20 Short: "broadcast <tx-hex>", 21 Args: cobra.ExactArgs(1), 22 RunE: func(cmd *cobra.Command, args []string) error { 23 ctx := NewCoreBroadcastContextFromViper().WithTxEncoder(linotypes.TxEncoder(cdc)) 24 hexstr := args[0] 25 hexbytes, err := hex.DecodeString(hexstr) 26 if err != nil { 27 return err 28 } 29 res, err := ctx.BroadcastTx(hexbytes) 30 if err != nil { 31 return err 32 } 33 fmt.Println(res.String()) 34 return nil 35 }, 36 } 37 return cmd 38 }