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.

36 lines
676 B

  1. package main
  2. import (
  3. "encoding/hex"
  4. "fmt"
  5. "os"
  6. "context"
  7. "github.com/tendermint/go-wire"
  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. fmt.Println(string(wire.JSONBytes(res)))
  30. }