aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/transaction.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-06-17 00:25:24 +0800
committerobscuren <geffobscura@gmail.com>2014-06-17 00:25:24 +0800
commit5a0e75173626704c3d58be582dff318218569ef3 (patch)
tree801ec6d33fe21e46230a3082cd069534f64aa251 /ethchain/transaction.go
parent006ac772e6c81271a84ff56e00527b2adbc0129c (diff)
parentff0f15f7634ca713b0ce8232a8fa63eec5c3fad7 (diff)
downloadgo-tangerine-5a0e75173626704c3d58be582dff318218569ef3.tar
go-tangerine-5a0e75173626704c3d58be582dff318218569ef3.tar.gz
go-tangerine-5a0e75173626704c3d58be582dff318218569ef3.tar.bz2
go-tangerine-5a0e75173626704c3d58be582dff318218569ef3.tar.lz
go-tangerine-5a0e75173626704c3d58be582dff318218569ef3.tar.xz
go-tangerine-5a0e75173626704c3d58be582dff318218569ef3.tar.zst
go-tangerine-5a0e75173626704c3d58be582dff318218569ef3.zip
Merge branch 'release/0.5.13'
Diffstat (limited to 'ethchain/transaction.go')
-rw-r--r--ethchain/transaction.go22
1 files changed, 14 insertions, 8 deletions
diff --git a/ethchain/transaction.go b/ethchain/transaction.go
index 2cb946b3b..3d52e4f73 100644
--- a/ethchain/transaction.go
+++ b/ethchain/transaction.go
@@ -1,6 +1,7 @@
package ethchain
import (
+ "bytes"
"fmt"
"github.com/ethereum/eth-go/ethutil"
"github.com/obscuren/secp256k1-go"
@@ -24,7 +25,7 @@ type Transaction struct {
}
func NewContractCreationTx(value, gas, gasPrice *big.Int, script []byte) *Transaction {
- return &Transaction{Value: value, Gas: gas, GasPrice: gasPrice, Data: script, contractCreation: true}
+ return &Transaction{Recipient: ContractAddr, Value: value, Gas: gas, GasPrice: gasPrice, Data: script, contractCreation: true}
}
func NewTransactionMessage(to []byte, value, gas, gasPrice *big.Int, data []byte) *Transaction {
@@ -45,15 +46,18 @@ func NewTransactionFromValue(val *ethutil.Value) *Transaction {
return tx
}
+func (self *Transaction) GasValue() *big.Int {
+ return new(big.Int).Mul(self.Gas, self.GasPrice)
+}
+
+func (self *Transaction) TotalValue() *big.Int {
+ v := self.GasValue()
+ return v.Add(v, self.Value)
+}
+
func (tx *Transaction) Hash() []byte {
data := []interface{}{tx.Nonce, tx.GasPrice, tx.Gas, tx.Recipient, tx.Value, tx.Data}
- /*
- if tx.contractCreation {
- data = append(data, tx.Init)
- }
- */
-
return ethutil.Sha3Bin(ethutil.NewValue(data).Encode())
}
@@ -144,7 +148,8 @@ func (tx *Transaction) RlpValueDecode(decoder *ethutil.Value) {
tx.v = byte(decoder.Get(6).Uint())
tx.r = decoder.Get(7).Bytes()
tx.s = decoder.Get(8).Bytes()
- if len(tx.Recipient) == 0 {
+
+ if bytes.Compare(tx.Recipient, ContractAddr) == 0 {
tx.contractCreation = true
}
}
@@ -183,6 +188,7 @@ type Receipt struct {
PostState []byte
CumulativeGasUsed *big.Int
}
+type Receipts []*Receipt
func NewRecieptFromValue(val *ethutil.Value) *Receipt {
r := &Receipt{}