You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
759 B

  1. package main
  2. import (
  3. "encoding/hex"
  4. "fmt"
  5. "os"
  6. "context"
  7. "github.com/tendermint/go-amino"
  8. "github.com/tendermint/tendermint/rpc/grpc"
  9. )
  10. var grpcAddr = "tcp://localhost:36656"
  11. func main() {
  12. args := os.Args
  13. if len(args) == 1 {
  14. fmt.Println("Must enter a transaction to send (hex)")
  15. os.Exit(1)
  16. }
  17. tx := args[1]
  18. txBytes, err := hex.DecodeString(tx)
  19. if err != nil {
  20. fmt.Println("Invalid hex", err)
  21. os.Exit(1)
  22. }
  23. clientGRPC := core_grpc.StartGRPCClient(grpcAddr)
  24. res, err := clientGRPC.BroadcastTx(context.Background(), &core_grpc.RequestBroadcastTx{txBytes})
  25. if err != nil {
  26. fmt.Println(err)
  27. os.Exit(1)
  28. }
  29. bz, err := amino.NewCodec().MarshalJSON(res)
  30. if err != nil {
  31. fmt.Println(err)
  32. os.Exit(1)
  33. }
  34. fmt.Println(string(bz))
  35. }