Skip to content

Commit

Permalink
types: bugfix invalid V derivation on tx json unmarshal (ethereum#3594)
Browse files Browse the repository at this point in the history
  • Loading branch information
bas-vk authored and fjl committed Jan 20, 2017
1 parent 946db8b commit 0126d01
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion core/types/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error {

var V byte
if isProtectedV((*big.Int)(dec.V)) {
V = byte((new(big.Int).Sub((*big.Int)(dec.V), deriveChainId((*big.Int)(dec.V))).Uint64()) - 35)
chainId := deriveChainId((*big.Int)(dec.V)).Uint64()
V = byte(dec.V.ToInt().Uint64() - 35 - 2*chainId)
} else {
V = byte(((*big.Int)(dec.V)).Uint64() - 27)
}
Expand Down
2 changes: 1 addition & 1 deletion core/types/transaction_signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (s EIP155Signer) PublicKey(tx *Transaction) ([]byte, error) {
// needs to be in the [R || S || V] format where V is 0 or 1.
func (s EIP155Signer) WithSignature(tx *Transaction, sig []byte) (*Transaction, error) {
if len(sig) != 65 {
panic(fmt.Sprintf("wrong size for snature: got %d, want 65", len(sig)))
panic(fmt.Sprintf("wrong size for signature: got %d, want 65", len(sig)))
}

cpy := &Transaction{data: tx.data}
Expand Down

0 comments on commit 0126d01

Please sign in to comment.