Skip to content

Commit 0e93b98

Browse files
committed
Transaction was generating incorrect hash because of var changes
1 parent 5da5db5 commit 0e93b98

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

core/state_transition.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (self *StateTransition) BuyGas() error {
112112

113113
sender := self.From()
114114
if sender.Balance().Cmp(MessageGasValue(self.msg)) < 0 {
115-
return fmt.Errorf("Insufficient funds to pre-pay gas. Req %v, has %v", MessageGasValue(self.msg), sender.Balance())
115+
return fmt.Errorf("insufficient ETH for gas (%x). Req %v, has %v", sender.Address()[:4], MessageGasValue(self.msg), sender.Balance())
116116
}
117117

118118
coinbase := self.Coinbase()

core/types/transaction.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func NewTransactionFromValue(val *ethutil.Value) *Transaction {
4747
}
4848

4949
func (tx *Transaction) Hash() []byte {
50-
data := []interface{}{tx.Nonce, tx.gasPrice, tx.gas, tx.recipient, tx.Value, tx.Data}
50+
data := []interface{}{tx.nonce, tx.gasPrice, tx.gas, tx.recipient, tx.value, tx.data}
5151

5252
return crypto.Sha3(ethutil.NewValue(data).Encode())
5353
}
@@ -108,8 +108,8 @@ func (tx *Transaction) PublicKey() []byte {
108108
sig := append(r, s...)
109109
sig = append(sig, v-27)
110110

111-
pubkey := crypto.Ecrecover(append(hash, sig...))
112-
//pubkey, _ := secp256k1.RecoverPubkey(hash, sig)
111+
//pubkey := crypto.Ecrecover(append(hash, sig...))
112+
pubkey, _ := secp256k1.RecoverPubkey(hash, sig)
113113

114114
return pubkey
115115
}
@@ -138,9 +138,7 @@ func (tx *Transaction) Sign(privk []byte) error {
138138
}
139139

140140
func (tx *Transaction) RlpData() interface{} {
141-
data := []interface{}{tx.Nonce, tx.GasPrice, tx.Gas, tx.recipient, tx.Value, tx.Data}
142-
143-
// TODO Remove prefixing zero's
141+
data := []interface{}{tx.nonce, tx.gasPrice, tx.gas, tx.recipient, tx.value, tx.data}
144142

145143
return append(data, tx.v, new(big.Int).SetBytes(tx.r).Bytes(), new(big.Int).SetBytes(tx.s).Bytes())
146144
}
@@ -184,6 +182,7 @@ func (tx *Transaction) String() string {
184182
V: 0x%x
185183
R: 0x%x
186184
S: 0x%x
185+
Hex: %x
187186
`,
188187
tx.Hash(),
189188
len(tx.recipient) == 0,
@@ -192,11 +191,13 @@ func (tx *Transaction) String() string {
192191
tx.nonce,
193192
tx.gasPrice,
194193
tx.gas,
195-
tx.Value,
196-
tx.Data,
194+
tx.value,
195+
tx.data,
197196
tx.v,
198197
tx.r,
199-
tx.s)
198+
tx.s,
199+
ethutil.Encode(tx),
200+
)
200201
}
201202

202203
// Transaction slice type for basic sorting

0 commit comments

Comments
 (0)