Commit 40b5c96c authored by hezhengjun's avatar hezhengjun

set amount after correct by different decimal

parent e80678c4
...@@ -538,7 +538,7 @@ func (ethRelayer *Relayer4Ethereum) checkPermissionWithinOneDay(withdrawTx *ebTy ...@@ -538,7 +538,7 @@ func (ethRelayer *Relayer4Ethereum) checkPermissionWithinOneDay(withdrawTx *ebTy
totalAlready.Add(totalAlready, AmountInt) totalAlready.Add(totalAlready, AmountInt)
if totalAlready.Cmp(withdrawPara.AmountPerDay) > 0 { if totalAlready.Cmp(withdrawPara.AmountPerDay) > 0 {
relayerLog.Error("checkPermissionWithinOneDay", "No withdraw parameter configured for symbol ", withdrawTx.Symbol) relayerLog.Error("checkPermissionWithinOneDay", "No withdraw parameter configured for symbol ", withdrawTx.Symbol)
return nil, errors.New("ErrWithdrawAmountTooBig") return nil, errors.New("ErrWithdrawAmountBigThanQuota")
} }
relayerLog.Info("checkPermissionWithinOneDay", "total withdraw already", totalAlready, "Chain33Sender", withdrawTx.Chain33Sender, relayerLog.Info("checkPermissionWithinOneDay", "total withdraw already", totalAlready, "Chain33Sender", withdrawTx.Chain33Sender,
"Symbol", withdrawTx.Symbol) "Symbol", withdrawTx.Symbol)
...@@ -554,7 +554,6 @@ func (ethRelayer *Relayer4Ethereum) handleLogWithdraw(chain33Msg *events.Chain33 ...@@ -554,7 +554,6 @@ func (ethRelayer *Relayer4Ethereum) handleLogWithdraw(chain33Msg *events.Chain33
Chain33Sender: chain33Msg.Chain33Sender.String(), Chain33Sender: chain33Msg.Chain33Sender.String(),
EthereumReceiver: chain33Msg.EthereumReceiver.String(), EthereumReceiver: chain33Msg.EthereumReceiver.String(),
Symbol: chain33Msg.Symbol, Symbol: chain33Msg.Symbol,
Amount: chain33Msg.Amount.String(),
TxHashOnChain33: common.Bytes2Hex(chain33Msg.TxHash), TxHashOnChain33: common.Bytes2Hex(chain33Msg.TxHash),
Nonce: chain33Msg.Nonce, Nonce: chain33Msg.Nonce,
Year: int32(year), Year: int32(year),
...@@ -589,12 +588,6 @@ func (ethRelayer *Relayer4Ethereum) handleLogWithdraw(chain33Msg *events.Chain33 ...@@ -589,12 +588,6 @@ func (ethRelayer *Relayer4Ethereum) handleLogWithdraw(chain33Msg *events.Chain33
return return
} }
//检查用户提币权限是否得到满足:比如是否超过累计提币额度
var feeAmount *big.Int
if feeAmount, err = ethRelayer.checkPermissionWithinOneDay(withdrawTx); nil != err {
return
}
tokenAddr := common.HexToAddress(withdrawFromChain33TokenInfo.Address) tokenAddr := common.HexToAddress(withdrawFromChain33TokenInfo.Address)
//从chain33进行withdraw回来的token需要根据精度进行相应的缩放 //从chain33进行withdraw回来的token需要根据精度进行相应的缩放
if 8 != withdrawFromChain33TokenInfo.Decimal { if 8 != withdrawFromChain33TokenInfo.Decimal {
...@@ -618,11 +611,17 @@ func (ethRelayer *Relayer4Ethereum) handleLogWithdraw(chain33Msg *events.Chain33 ...@@ -618,11 +611,17 @@ func (ethRelayer *Relayer4Ethereum) handleLogWithdraw(chain33Msg *events.Chain33
chain33Msg.Amount.Div(chain33Msg.Amount, big.NewInt(value)) chain33Msg.Amount.Div(chain33Msg.Amount, big.NewInt(value))
} }
} }
relayerLog.Info("handleLogWithdraw", "token address", tokenAddr.String(), "amount", chain33Msg.Amount.String(), withdrawTx.Amount = chain33Msg.Amount.String()
relayerLog.Info("handleLogWithdraw", "token address", tokenAddr.String(), "amount", withdrawTx.Amount,
"Receiver on Ethereum", chain33Msg.EthereumReceiver.String()) "Receiver on Ethereum", chain33Msg.EthereumReceiver.String())
//检查用户提币权限是否得到满足:比如是否超过累计提币额度
var feeAmount *big.Int
if feeAmount, err = ethRelayer.checkPermissionWithinOneDay(withdrawTx); nil != err {
return
}
if chain33Msg.Amount.Cmp(feeAmount) < 0 { if chain33Msg.Amount.Cmp(feeAmount) < 0 {
relayerLog.Error("handleLogWithdraw", "ErrWithdrawAmountLessThanFee feeAmount", feeAmount.String(), "Withdraw Amount", chain33Msg.Amount.String()) relayerLog.Error("handleLogWithdraw", "ErrWithdrawAmountLessThanFee feeAmount", feeAmount.String(), "Withdraw Amount", chain33Msg.Amount.String())
err = errors.New("ErrWithdrawAmountLessThanFee") err = errors.New("ErrWithdrawAmountCan'tPay4Fee")
return return
} }
amount2transfer := chain33Msg.Amount.Sub(chain33Msg.Amount, feeAmount) amount2transfer := chain33Msg.Amount.Sub(chain33Msg.Amount, feeAmount)
......
...@@ -9,9 +9,6 @@ import ( ...@@ -9,9 +9,6 @@ import (
//const ... //const ...
const ( const (
X2Eth = "x2ethereum"
BurnAction = "Chain33ToEthBurn"
LockAction = "Chain33ToEthLock"
EthNullAddr = "0x0000000000000000000000000000000000000000" EthNullAddr = "0x0000000000000000000000000000000000000000"
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment