Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow 1000 satoshis to be withdrawn
Browse files Browse the repository at this point in the history
ws4charlie committed Jun 20, 2024
1 parent 78d0382 commit ca9dad9
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion x/crosschain/keeper/evm_hooks.go
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions x/crosschain/keeper/evm_hooks_test.go
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit ca9dad9

Please sign in to comment.