From ca9dad93871ea915fc182d4ba6f1d2087daff6ef Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Thu, 20 Jun 2024 14:09:11 -0500 Subject: [PATCH] allow 1000 satoshis to be withdrawn --- x/crosschain/keeper/evm_hooks.go | 2 +- x/crosschain/keeper/evm_hooks_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/x/crosschain/keeper/evm_hooks.go b/x/crosschain/keeper/evm_hooks.go index fc472652f4..ac2a5165fc 100644 --- a/x/crosschain/keeper/evm_hooks.go +++ b/x/crosschain/keeper/evm_hooks.go @@ -328,7 +328,7 @@ func ValidateZrc20WithdrawEvent(event *zrc20.ZRC20Withdrawal, chainID int64) err // The event was parsed; that means the user has deposited tokens to the contract. if chains.IsBitcoinChain(chainID) { - if event.Value.Cmp(big.NewInt(constant.BTCWithdrawalDustAmount)) <= 0 { + if event.Value.Cmp(big.NewInt(constant.BTCWithdrawalDustAmount)) < 0 { return fmt.Errorf("ParseZRC20WithdrawalEvent: invalid amount %s", event.Value.String()) } addr, err := chains.DecodeBtcAddress(string(event.To), chainID) diff --git a/x/crosschain/keeper/evm_hooks_test.go b/x/crosschain/keeper/evm_hooks_test.go index b2e9ef1abe..5518595a36 100644 --- a/x/crosschain/keeper/evm_hooks_test.go +++ b/x/crosschain/keeper/evm_hooks_test.go @@ -172,6 +172,11 @@ func TestValidateZrc20WithdrawEvent(t *testing.T) { require.NoError(t, err) // 1000 satoshis is the minimum amount that can be withdrawn + btcMainNetWithdrawalEvent.Value = big.NewInt(constant.BTCWithdrawalDustAmount) + err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BitcoinMainnet.ChainId) + require.NoError(t, err) + + // 999 satoshis cannot be withdrawn btcMainNetWithdrawalEvent.Value = big.NewInt(constant.BTCWithdrawalDustAmount - 1) err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BitcoinMainnet.ChainId) require.ErrorContains(t, err, "ParseZRC20WithdrawalEvent: invalid amount")