aboutsummaryrefslogtreecommitdiffstats
path: root/xeth
diff options
context:
space:
mode:
Diffstat (limited to 'xeth')
-rw-r--r--xeth/types.go5
-rw-r--r--xeth/xeth.go40
2 files changed, 26 insertions, 19 deletions
diff --git a/xeth/types.go b/xeth/types.go
index 1be5e109c..3bb1447ca 100644
--- a/xeth/types.go
+++ b/xeth/types.go
@@ -139,6 +139,10 @@ type Transaction struct {
}
func NewTx(tx *types.Transaction) *Transaction {
+ sender, err := tx.From()
+ if err != nil {
+ return nil
+ }
hash := tx.Hash().Hex()
var receiver string
@@ -147,7 +151,6 @@ func NewTx(tx *types.Transaction) *Transaction {
} else {
receiver = core.AddressFromMessage(tx).Hex()
}
- sender, _ := tx.From()
createsContract := core.MessageCreatesContract(tx)
var data string
diff --git a/xeth/xeth.go b/xeth/xeth.go
index 157fe76c7..d2f992084 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -885,12 +885,29 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
from = common.HexToAddress(fromStr)
to = common.HexToAddress(toStr)
value = common.Big(valueStr)
- gas = common.Big(gasStr)
- price = common.Big(gasPriceStr)
+ gas *big.Int
+ price *big.Int
data []byte
contractCreation bool
)
+ if len(gasStr) == 0 {
+ gas = DefaultGas()
+ } else {
+ gas = common.Big(gasStr)
+ }
+
+ if len(gasPriceStr) == 0 {
+ price = DefaultGasPrice()
+ } else {
+ price = common.Big(gasPriceStr)
+ }
+
+ data = common.FromHex(codeStr)
+ if len(toStr) == 0 {
+ contractCreation = true
+ }
+
// 2015-05-18 Is this still needed?
// TODO if no_private_key then
//if _, exists := p.register[args.From]; exists {
@@ -916,18 +933,6 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
// TODO: align default values to have the same type, e.g. not depend on
// common.Value conversions later on
- if gas.Cmp(big.NewInt(0)) == 0 {
- gas = DefaultGas()
- }
-
- if price.Cmp(big.NewInt(0)) == 0 {
- price = DefaultGasPrice()
- }
-
- data = common.FromHex(codeStr)
- if len(toStr) == 0 {
- contractCreation = true
- }
var tx *types.Transaction
if contractCreation {
@@ -936,24 +941,23 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
tx = types.NewTransactionMessage(to, value, gas, price, data)
}
- state := self.backend.ChainManager().TxState()
+ state := self.backend.TxPool().State()
var nonce uint64
if len(nonceStr) != 0 {
nonce = common.Big(nonceStr).Uint64()
} else {
- nonce = state.NewNonce(from)
+ nonce = state.GetNonce(from)
}
tx.SetNonce(nonce)
if err := self.sign(tx, from, false); err != nil {
- state.RemoveNonce(from, tx.Nonce())
return "", err
}
if err := self.backend.TxPool().Add(tx); err != nil {
- state.RemoveNonce(from, tx.Nonce())
return "", err
}
+ //state.SetNonce(from, nonce+1)
if contractCreation {
addr := core.AddressFromMessage(tx)