diff --git a/core/tx_pool.go b/core/tx_pool.go index f2400198d6..f363d5b1fa 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -551,21 +551,6 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { return ErrInvalidSender } - // Ensure gold transfers are whitelisted if transfers are frozen. - if tx.Value().Sign() > 0 { - to := *tx.To() - if isFrozen, err := freezer.IsFrozen(params.GoldTokenRegistryId, nil, nil); err != nil { - log.Warn("Error determining if transfers are frozen, will proceed as if they are not", "err", err) - } else if isFrozen { - log.Info("Transfers are frozen") - if !transfer_whitelist.IsWhitelisted(to, from, nil, nil) { - log.Debug("Attempt to transfer between non-whitelisted addresses", "hash", tx.Hash(), "to", to, "from", from) - return ErrTransfersFrozen - } - log.Info("Transfer is whitelisted", "hash", tx.Hash(), "to", to, "from", from) - } - } - // Ensure the fee currency is native or whitelisted. if tx.FeeCurrency() != nil && !currency.IsWhitelisted(*tx.FeeCurrency(), nil, nil) { return ErrNonWhitelistedFeeCurrency @@ -606,6 +591,21 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { return ErrGasPriceDoesNotExceedMinimum } + // Ensure gold transfers are whitelisted if transfers are frozen. + if tx.Value().Sign() > 0 { + to := *tx.To() + if isFrozen, err := freezer.IsFrozen(params.GoldTokenRegistryId, nil, nil); err != nil { + log.Warn("Error determining if transfers are frozen, will proceed as if they are not", "err", err) + } else if isFrozen { + log.Info("Transfers are frozen") + if !transfer_whitelist.IsWhitelisted(to, from, nil, nil) { + log.Debug("Attempt to transfer between non-whitelisted addresses", "hash", tx.Hash(), "to", to, "from", from) + return ErrTransfersFrozen + } + log.Info("Transfer is whitelisted", "hash", tx.Hash(), "to", to, "from", from) + } + } + return nil } diff --git a/light/txpool.go b/light/txpool.go index 04945395c1..3b969b9146 100644 --- a/light/txpool.go +++ b/light/txpool.go @@ -367,21 +367,6 @@ func (pool *TxPool) validateTx(ctx context.Context, tx *types.Transaction) error return core.ErrNonceTooLow } - // Ensure gold transfers are whitelisted if transfers are frozen. - if tx.Value().Sign() > 0 { - to := *tx.To() - if isFrozen, err := freezer.IsFrozen(params.GoldTokenRegistryId, nil, nil); err != nil { - log.Warn("Error determining if transfers are frozen, will proceed as if they are not", "err", err) - } else if isFrozen { - log.Info("Transfers are frozen") - if !transfer_whitelist.IsWhitelisted(to, from, nil, nil) { - log.Debug("Attempt to transfer between non-whitelisted addresses", "hash", tx.Hash(), "to", to, "from", from) - return core.ErrTransfersFrozen - } - log.Info("Transfer is whitelisted", "hash", tx.Hash(), "to", to, "from", from) - } - } - // Check the transaction doesn't exceed the current // block limit gas. header := pool.chain.GetHeaderByHash(pool.head) @@ -411,6 +396,21 @@ func (pool *TxPool) validateTx(ctx context.Context, tx *types.Transaction) error return core.ErrIntrinsicGas } + // Ensure gold transfers are whitelisted if transfers are frozen. + if tx.Value().Sign() > 0 { + to := *tx.To() + if isFrozen, err := freezer.IsFrozen(params.GoldTokenRegistryId, nil, nil); err != nil { + log.Warn("Error determining if transfers are frozen, will proceed as if they are not", "err", err) + } else if isFrozen { + log.Info("Transfers are frozen") + if !transfer_whitelist.IsWhitelisted(to, from, nil, nil) { + log.Debug("Attempt to transfer between non-whitelisted addresses", "hash", tx.Hash(), "to", to, "from", from) + return core.ErrTransfersFrozen + } + log.Info("Transfer is whitelisted", "hash", tx.Hash(), "to", to, "from", from) + } + } + // Should have a peer that will accept and broadcast our transaction if err := pool.relay.HasPeerWithEtherbase(tx.GatewayFeeRecipient()); err != nil { return err