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
726 B

  1. package main
  2. import (
  3. "encoding/hex"
  4. "encoding/json"
  5. "fmt"
  6. "os"
  7. "context"
  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 := json.Marshal(res)
  30. if err != nil {
  31. fmt.Println(err)
  32. os.Exit(1)
  33. }
  34. fmt.Println(string(bz))
  35. }