aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-19 20:34:53 +0800
committerobscuren <geffobscura@gmail.com>2014-12-19 20:34:53 +0800
commit0e93b98533968f4a0033ec6214391f5ca647a956 (patch)
tree6237862ddbef544dec3c34561cc2bb0421f2b59c /core
parent5da5db5a0a149235c742748aa4b3b94d13d6910f (diff)
downloadgo-tangerine-0e93b98533968f4a0033ec6214391f5ca647a956.tar.gz
go-tangerine-0e93b98533968f4a0033ec6214391f5ca647a956.tar.zst
go-tangerine-0e93b98533968f4a0033ec6214391f5ca647a956.zip
Transaction was generating incorrect hash because of var changes
Diffstat (limited to 'core')
-rw-r--r--core/state_transition.go2
-rw-r--r--core/types/transaction.go19
2 files changed, 11 insertions, 10 deletions
diff --git a/core/state_transition.go b/core/state_transition.go
index 9e81ddf28..a54246eba 100644
--- a/core/state_transition.go
+++ b/core/state_transition.go
@@ -112,7 +112,7 @@ func (self *StateTransition) BuyGas() error {
sender := self.From()
if sender.Balance().Cmp(MessageGasValue(self.msg)) < 0 {
- return fmt.Errorf("Insufficient funds to pre-pay gas. Req %v, has %v", MessageGasValue(self.msg), sender.Balance())
+ return fmt.Errorf("insufficient ETH for gas (%x). Req %v, has %v", sender.Address()[:4], MessageGasValue(self.msg), sender.Balance())
}
coinbase := self.Coinbase()
diff --git a/core/types/transaction.go b/core/types/transaction.go
index c64fb69f0..f6ad0774b 100644
--- a/core/types/transaction.go
+++ b/core/types/transaction.go
@@ -47,7 +47,7 @@ func NewTransactionFromValue(val *ethutil.Value) *Transaction {
}
func (tx *Transaction) Hash() []byte {
- data := []interface{}{tx.Nonce, tx.gasPrice, tx.gas, tx.recipient, tx.Value, tx.Data}
+ data := []interface{}{tx.nonce, tx.gasPrice, tx.gas, tx.recipient, tx.value, tx.data}
return crypto.Sha3(ethutil.NewValue(data).Encode())
}
@@ -108,8 +108,8 @@ func (tx *Transaction) PublicKey() []byte {
sig := append(r, s...)
sig = append(sig, v-27)
- pubkey := crypto.Ecrecover(append(hash, sig...))
- //pubkey, _ := secp256k1.RecoverPubkey(hash, sig)
+ //pubkey := crypto.Ecrecover(append(hash, sig...))
+ pubkey, _ := secp256k1.RecoverPubkey(hash, sig)
return pubkey
}
@@ -138,9 +138,7 @@ func (tx *Transaction) Sign(privk []byte) error {
}
func (tx *Transaction) RlpData() interface{} {
- data := []interface{}{tx.Nonce, tx.GasPrice, tx.Gas, tx.recipient, tx.Value, tx.Data}
-
- // TODO Remove prefixing zero's
+ data := []interface{}{tx.nonce, tx.gasPrice, tx.gas, tx.recipient, tx.value, tx.data}
return append(data, tx.v, new(big.Int).SetBytes(tx.r).Bytes(), new(big.Int).SetBytes(tx.s).Bytes())
}
@@ -184,6 +182,7 @@ func (tx *Transaction) String() string {
V: 0x%x
R: 0x%x
S: 0x%x
+ Hex: %x
`,
tx.Hash(),
len(tx.recipient) == 0,
@@ -192,11 +191,13 @@ func (tx *Transaction) String() string {
tx.nonce,
tx.gasPrice,
tx.gas,
- tx.Value,
- tx.Data,
+ tx.value,
+ tx.data,
tx.v,
tx.r,
- tx.s)
+ tx.s,
+ ethutil.Encode(tx),
+ )
}
// Transaction slice type for basic sorting