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.

34 lines
998 B

  1. package core
  2. import (
  3. "fmt"
  4. ctypes "github.com/tendermint/tendermint/rpc/core/types"
  5. "github.com/tendermint/tendermint/state"
  6. "github.com/tendermint/tendermint/types"
  7. )
  8. //-----------------------------------------------------------------------------
  9. // Note: tx must be signed
  10. func BroadcastTx(tx types.Tx) (*ctypes.Receipt, error) {
  11. err := mempoolReactor.BroadcastTx(tx)
  12. if err != nil {
  13. return nil, fmt.Errorf("Error broadcasting transaction: %v", err)
  14. }
  15. txHash := types.TxId(mempoolReactor.Mempool.GetState().ChainID, tx)
  16. var createsContract uint8
  17. var contractAddr []byte
  18. // check if creates new contract
  19. if callTx, ok := tx.(*types.CallTx); ok {
  20. if len(callTx.Address) == 0 {
  21. createsContract = 1
  22. contractAddr = state.NewContractAddress(callTx.Input.Address, uint64(callTx.Input.Sequence))
  23. }
  24. }
  25. return &ctypes.Receipt{txHash, createsContract, contractAddr}, nil
  26. }
  27. func ListUnconfirmedTxs() ([]types.Tx, error) {
  28. return mempoolReactor.Mempool.GetProposalTxs(), nil
  29. }