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.

33 lines
714 B

  1. package rpc
  2. import (
  3. "net/http"
  4. "github.com/tendermint/tendermint/binary"
  5. blk "github.com/tendermint/tendermint/block"
  6. . "github.com/tendermint/tendermint/common"
  7. )
  8. func BroadcastTxHandler(w http.ResponseWriter, r *http.Request) {
  9. txJSON := GetParam(r, "tx")
  10. var err error
  11. var tx blk.Tx
  12. binary.ReadJSON(&tx, []byte(txJSON), &err)
  13. if err != nil {
  14. WriteAPIResponse(w, API_INVALID_PARAM, Fmt("Invalid tx: %v", err))
  15. return
  16. }
  17. err = mempoolReactor.BroadcastTx(tx)
  18. if err != nil {
  19. WriteAPIResponse(w, API_ERROR, Fmt("Error broadcasting transaction: %v", err))
  20. return
  21. }
  22. WriteAPIResponse(w, API_OK, "")
  23. return
  24. }
  25. /*
  26. curl -H 'content-type: text/plain;' http://127.0.0.1:8888/submit_tx?tx=...
  27. */