From f145974548e5a1bf65c97c3264a35697b799cd02 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 5 Sep 2024 19:59:47 -0400 Subject: [PATCH] resolve comments --- pkg/address/validate_address.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pkg/address/validate_address.go b/pkg/address/validate_address.go index 2278ee0fcd..d24e887a76 100644 --- a/pkg/address/validate_address.go +++ b/pkg/address/validate_address.go @@ -26,16 +26,7 @@ func ValidateAddressForChain(address string, chainID int64, additionalChains []c case chains.Network_zeta: return nil case chains.Network_btc: - { - addr, err := chains.DecodeBtcAddress(address, chainID) - if err != nil { - return fmt.Errorf("invalid address %s , chain %d: %s", address, chainID, err) - } - if !chains.IsBtcAddressSupported(addr) { - return fmt.Errorf("unsupported address %s", address) - } - return nil - } + return ValidateBTCAddress(address, chainID) case chains.Network_polygon: return ValidateEthereumAddress(address) case chains.Network_bsc: @@ -57,3 +48,14 @@ func ValidateEthereumAddress(address string) error { } return nil } + +func ValidateBTCAddress(address string, chainID int64) error { + addr, err := chains.DecodeBtcAddress(address, chainID) + if err != nil { + return fmt.Errorf("invalid address %s , chain %d: %s", address, chainID, err) + } + if !chains.IsBtcAddressSupported(addr) { + return fmt.Errorf("unsupported address %s", address) + } + return nil +}