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.

32 lines
727 B

  1. package rpc
  2. import (
  3. "net/http"
  4. . "github.com/tendermint/tendermint/binary"
  5. . "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. tx := ReadJSON(struct{ Tx }{}, []byte(txJSON), &err).(struct{ Tx }).Tx
  12. if err != nil {
  13. WriteAPIResponse(w, API_INVALID_PARAM, Fmt("Invalid tx: %v", err))
  14. return
  15. }
  16. err = mempoolReactor.BroadcastTx(tx)
  17. if err != nil {
  18. WriteAPIResponse(w, API_ERROR, Fmt("Error broadcasting transaction: %v", err))
  19. return
  20. }
  21. WriteAPIResponse(w, API_OK, "")
  22. return
  23. }
  24. /*
  25. curl -H 'content-type: text/plain;' http://127.0.0.1:8888/submit_tx?tx=...
  26. */