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.

41 lines
1.0 KiB

10 years ago
  1. package core
  2. import (
  3. "fmt"
  4. . "github.com/tendermint/tendermint2/common"
  5. "github.com/tendermint/tendermint2/state"
  6. "github.com/tendermint/tendermint2/types"
  7. )
  8. //-----------------------------------------------------------------------------
  9. type Receipt struct {
  10. TxHash []byte
  11. CreatesContract uint8
  12. ContractAddr []byte
  13. }
  14. // pass pointer?
  15. // Note: tx must be signed
  16. func BroadcastTx(tx types.Tx) (*ResponseBroadcastTx, error) {
  17. err := mempoolReactor.BroadcastTx(tx)
  18. if err != nil {
  19. return nil, fmt.Errorf("Error broadcasting transaction: %v", err)
  20. }
  21. txHash := types.TxId(tx)
  22. var createsContract uint8
  23. var contractAddr []byte
  24. // check if creates new contract
  25. if callTx, ok := tx.(*types.CallTx); ok {
  26. if len(callTx.Address) == 0 {
  27. createsContract = 1
  28. contractAddr = state.NewContractAddress(callTx.Input.Address, uint64(callTx.Input.Sequence))
  29. }
  30. }
  31. return &ResponseBroadcastTx{Receipt{txHash, createsContract, contractAddr}}, nil
  32. }
  33. /*
  34. curl -H 'content-type: text/plain;' http://127.0.0.1:8888/submit_tx?tx=...
  35. */