diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-20 14:13:29 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-20 14:13:29 +0800 |
commit | aa3918efa711a51c241a70d675b27fc0f0c01ec3 (patch) | |
tree | cc312606bf39db44bc750605fc11f928184adcb0 /xeth | |
parent | e038a42d7a0e7e2c6ad7cef6c6446ad1e9454fe5 (diff) | |
download | dexon-aa3918efa711a51c241a70d675b27fc0f0c01ec3.tar.gz dexon-aa3918efa711a51c241a70d675b27fc0f0c01ec3.tar.zst dexon-aa3918efa711a51c241a70d675b27fc0f0c01ec3.zip |
Move transact gas check to XEth
Diffstat (limited to 'xeth')
-rw-r--r-- | xeth/xeth.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/xeth/xeth.go b/xeth/xeth.go index 3d44e292c..e1e25ba09 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -521,8 +521,8 @@ func (self *XEth) Transact(fromStr, toStr, valueStr, gasStr, gasPriceStr, codeSt from []byte to []byte value = common.NewValue(valueStr) - gas = common.NewValue(gasStr) - price = common.NewValue(gasPriceStr) + gas = common.Big(gasStr) + price = common.Big(gasPriceStr) data []byte contractCreation bool ) @@ -549,6 +549,16 @@ func (self *XEth) Transact(fromStr, toStr, valueStr, gasStr, gasPriceStr, codeSt } */ + // 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 + } + from = common.FromHex(fromStr) data = common.FromHex(codeStr) to = common.FromHex(toStr) @@ -558,9 +568,9 @@ func (self *XEth) Transact(fromStr, toStr, valueStr, gasStr, gasPriceStr, codeSt var tx *types.Transaction if contractCreation { - tx = types.NewContractCreationTx(value.BigInt(), gas.BigInt(), price.BigInt(), data) + tx = types.NewContractCreationTx(value.BigInt(), gas, price, data) } else { - tx = types.NewTransactionMessage(to, value.BigInt(), gas.BigInt(), price.BigInt(), data) + tx = types.NewTransactionMessage(to, value.BigInt(), gas, price, data) } state := self.chainManager.TxState() |