diff --git a/accounts/keystore/keystore.go b/accounts/keystore/keystore.go index 10c0db70ff..fa04214c20 100644 --- a/accounts/keystore/keystore.go +++ b/accounts/keystore/keystore.go @@ -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) diff --git a/core/types/transaction.go b/core/types/transaction.go index 8dd166c176..b60b5f379c 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -131,7 +131,8 @@ func (tx *Transaction) Protected() bool { func isProtectedV(V *big.Int) bool { if V.BitLen() <= 8 { v := V.Uint64() - return v != 27 && v != 28 + // 27 / 28 are pre eip 155 -- ie unprotected. + return !(v == 27 || v == 28) } // anything not 27 or 28 are considered unprotected return true diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index 883711571f..6938141137 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -40,9 +40,6 @@ type sigCache struct { // MakeSigner returns a Signer based on the given chain config and block number. func MakeSigner(config *params.ChainConfig, blockNumber *big.Int) Signer { - if config.IsQuorum { - return HomesteadSigner{} - } var signer Signer switch { case config.IsEIP155(blockNumber): @@ -128,6 +125,9 @@ func (s EIP155Signer) Equal(s2 Signer) bool { var big8 = big.NewInt(8) func (s EIP155Signer) Sender(tx *Transaction) (common.Address, error) { + if tx.IsPrivate() { + return HomesteadSigner{}.Sender(tx) + } if !tx.Protected() { return HomesteadSigner{}.Sender(tx) } @@ -136,12 +136,16 @@ func (s EIP155Signer) Sender(tx *Transaction) (common.Address, error) { } V := new(big.Int).Sub(tx.data.V, s.chainIdMul) V.Sub(V, big8) - return recoverPlain(s.Hash(tx), tx.data.R, tx.data.S, V, true, false) + return recoverPlain(s.Hash(tx), tx.data.R, tx.data.S, V, true, tx.IsPrivate()) } // WithSignature returns a new transaction with the given signature. This signature // needs to be in the [R || S || V] format where V is 0 or 1. func (s EIP155Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big.Int, err error) { + if tx.IsPrivate() { + return HomesteadSigner{}.SignatureValues(tx, sig) + } + R, S, V, err = HomesteadSigner{}.SignatureValues(tx, sig) if err != nil { return nil, nil, nil, err diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 0c7bb43191..9c4fa692ce 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -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) @@ -834,7 +835,7 @@ type RPCTransaction struct { // representation, with the given location metadata set (if available). func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64) *RPCTransaction { var signer types.Signer = types.HomesteadSigner{} - if tx.Protected() { + if tx.Protected() & !tx.IsPrivate() { signer = types.NewEIP155Signer(tx.ChainId()) } from, _ := types.Sender(signer, tx) @@ -1004,7 +1005,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) @@ -1050,10 +1051,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) } @@ -1168,10 +1168,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 { @@ -1256,7 +1255,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) @@ -1284,7 +1283,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)