mirror of https://github.com/poanetwork/quorum.git
Use eip155 signer for public transactions (#375)
Use eip155 for public transaction
This commit is contained in:
parent
f3d1315269
commit
87d7c906e9
|
@ -278,7 +278,7 @@ func (ks *KeyStore) SignTx(a accounts.Account, tx *types.Transaction, chainID *b
|
|||
return nil, ErrLocked
|
||||
}
|
||||
// Depending on the presence of the chain ID, sign with EIP155 or homestead
|
||||
if chainID != nil && !isQuorum {
|
||||
if chainID != nil && !tx.IsPrivate() {
|
||||
return types.SignTx(tx, types.NewEIP155Signer(chainID), unlockedKey.PrivateKey)
|
||||
}
|
||||
return types.SignTx(tx, types.HomesteadSigner{}, unlockedKey.PrivateKey)
|
||||
|
|
|
@ -133,9 +133,7 @@ func isProtectedV(V *big.Int) bool {
|
|||
if V.BitLen() <= 8 {
|
||||
v := V.Uint64()
|
||||
// 27 / 28 are pre eip 155 -- ie unprotected.
|
||||
// TODO(joel): this is a hack. Everywhere else we maintain vanilla ethereum
|
||||
// compatibility and we should figure out how to extend that to here
|
||||
return !(v == 27 || v == 28 || v == 37 || v == 38)
|
||||
return !(v == 27 || v == 28)
|
||||
}
|
||||
// anything not 27 or 28 are considered unprotected
|
||||
return true
|
||||
|
|
|
@ -27,6 +27,9 @@ import (
|
|||
"bytes"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts"
|
||||
"github.com/ethereum/go-ethereum/accounts/keystore"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
|
@ -45,8 +48,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/syndtr/goleveldb/leveldb"
|
||||
"github.com/syndtr/goleveldb/leveldb/util"
|
||||
"net/http"
|
||||
"sync"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -378,7 +379,7 @@ func (s *PrivateAccountAPI) SendTransaction(ctx context.Context, args SendTxArgs
|
|||
tx := args.toTransaction()
|
||||
|
||||
var chainID *big.Int
|
||||
if config := s.b.ChainConfig(); config.IsEIP155(s.b.CurrentBlock().Number()) {
|
||||
if config := s.b.ChainConfig(); config.IsEIP155(s.b.CurrentBlock().Number()) && !isPrivate {
|
||||
chainID = config.ChainId
|
||||
}
|
||||
signed, err := wallet.SignTxWithPassphrase(account, passwd, tx, chainID)
|
||||
|
@ -835,7 +836,7 @@ type RPCTransaction struct {
|
|||
func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64) *RPCTransaction {
|
||||
var signer types.Signer = types.HomesteadSigner{}
|
||||
// joel: this is one of the two places we used a wrong signer to print txes
|
||||
if tx.Protected() {
|
||||
if tx.Protected() && !tx.IsPrivate() {
|
||||
signer = types.NewEIP155Signer(tx.ChainId())
|
||||
}
|
||||
from, _ := types.Sender(signer, tx)
|
||||
|
@ -1005,7 +1006,7 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(hash common.Hash) (map[
|
|||
receipt, _, _, _ := core.GetReceipt(s.b.ChainDb(), hash) // Old receipts don't have the lookup data available
|
||||
|
||||
var signer types.Signer = types.HomesteadSigner{}
|
||||
if tx.Protected() {
|
||||
if tx.Protected() && !tx.IsPrivate() {
|
||||
signer = types.NewEIP155Signer(tx.ChainId())
|
||||
}
|
||||
from, _ := types.Sender(signer, tx)
|
||||
|
@ -1051,10 +1052,9 @@ func (s *PublicTransactionPoolAPI) sign(addr common.Address, tx *types.Transacti
|
|||
}
|
||||
// Request the wallet to sign the transaction
|
||||
var chainID *big.Int
|
||||
isQuorum := false
|
||||
if config := s.b.ChainConfig(); config.IsEIP155(s.b.CurrentBlock().Number()) {
|
||||
isQuorum := tx.IsPrivate()
|
||||
if config := s.b.ChainConfig(); config.IsEIP155(s.b.CurrentBlock().Number()) && !tx.IsPrivate() {
|
||||
chainID = config.ChainId
|
||||
isQuorum = true
|
||||
}
|
||||
return wallet.SignTx(account, tx, chainID, isQuorum)
|
||||
}
|
||||
|
@ -1169,10 +1169,9 @@ func (s *PublicTransactionPoolAPI) SendTransaction(ctx context.Context, args Sen
|
|||
tx := args.toTransaction()
|
||||
|
||||
var chainID *big.Int
|
||||
isQuorum := false
|
||||
if config := s.b.ChainConfig(); config.IsEIP155(s.b.CurrentBlock().Number()) {
|
||||
isQuorum := tx.IsPrivate()
|
||||
if config := s.b.ChainConfig(); config.IsEIP155(s.b.CurrentBlock().Number()) && !isPrivate {
|
||||
chainID = config.ChainId
|
||||
isQuorum = true
|
||||
}
|
||||
signed, err := wallet.SignTx(account, tx, chainID, isQuorum)
|
||||
if err != nil {
|
||||
|
@ -1257,7 +1256,7 @@ func (s *PublicTransactionPoolAPI) PendingTransactions() ([]*RPCTransaction, err
|
|||
transactions := make([]*RPCTransaction, 0, len(pending))
|
||||
for _, tx := range pending {
|
||||
var signer types.Signer = types.HomesteadSigner{}
|
||||
if tx.Protected() {
|
||||
if tx.Protected() && !tx.IsPrivate() {
|
||||
signer = types.NewEIP155Signer(tx.ChainId())
|
||||
}
|
||||
from, _ := types.Sender(signer, tx)
|
||||
|
@ -1285,7 +1284,7 @@ func (s *PublicTransactionPoolAPI) Resend(ctx context.Context, sendArgs SendTxAr
|
|||
|
||||
for _, p := range pending {
|
||||
var signer types.Signer = types.HomesteadSigner{}
|
||||
if p.Protected() {
|
||||
if p.Protected() && !p.IsPrivate() {
|
||||
signer = types.NewEIP155Signer(p.ChainId())
|
||||
}
|
||||
wantSigHash := signer.Hash(matchTx)
|
||||
|
|
Loading…
Reference in New Issue