diff --git a/src/app/context/wallet/BTCWalletProvider.tsx b/src/app/context/wallet/BTCWalletProvider.tsx index 87022199..dbf29ef3 100644 --- a/src/app/context/wallet/BTCWalletProvider.tsx +++ b/src/app/context/wallet/BTCWalletProvider.tsx @@ -18,11 +18,7 @@ import { import { useError } from "@/app/context/Error/ErrorContext"; import { ErrorState } from "@/app/types/errors"; -import { - getPublicKeyNoCoord, - isSupportedAddressType, - toNetwork, -} from "@/utils/wallet"; +import { getPublicKeyNoCoord, toNetwork } from "@/utils/wallet"; import { Fees, InscriptionIdentifier, @@ -96,15 +92,8 @@ export const BTCWalletProvider = ({ children }: PropsWithChildren) => { async (walletProvider: IBTCProvider | null) => { if (!walletProvider) return; - const supportedNetworkMessage = - "Only Native SegWit and Taproot addresses are supported. Please switch the address type in your wallet and try again."; - try { const address = await walletProvider.getAddress(); - const supported = isSupportedAddressType(address); - if (!supported) { - throw new Error(supportedNetworkMessage); - } const publicKeyNoCoord = getPublicKeyNoCoord( await walletProvider.getPublicKeyHex(), diff --git a/src/config/network.config.ts b/src/config/network.config.ts index 3ebd883c..81571b40 100644 --- a/src/config/network.config.ts +++ b/src/config/network.config.ts @@ -53,24 +53,3 @@ export function getNetworkConfig(): NetworkConfig { return config.signet; } } - -export function validateAddress(network: Network, address: string): void { - if (network === Network.MAINNET && !address.startsWith("bc1")) { - throw new Error( - "Incorrect address prefix for Mainnet. Expected address to start with 'bc1'.", - ); - } else if ( - [Network.SIGNET, Network.TESTNET].includes(network) && - !address.startsWith("tb1") - ) { - throw new Error( - "Incorrect address prefix for Testnet / Signet. Expected address to start with 'tb1'.", - ); - } else if ( - ![Network.MAINNET, Network.SIGNET, Network.TESTNET].includes(network) - ) { - throw new Error( - `Unsupported network: ${network}. Please provide a valid network.`, - ); - } -} diff --git a/src/utils/wallet/index.ts b/src/utils/wallet/index.ts index 6c58a93d..0484db5f 100644 --- a/src/utils/wallet/index.ts +++ b/src/utils/wallet/index.ts @@ -2,7 +2,6 @@ import { networks } from "bitcoinjs-lib"; import { Network, UTXO } from "./btc_wallet_provider"; -const nativeSegwitAddressLength = 42; const taprootAddressLength = 62; export const LOW_VALUE_UTXO_THRESHOLD = 10000; @@ -18,13 +17,6 @@ export const toNetwork = (network: Network): networks.Network => { } }; -export const isSupportedAddressType = (address: string): boolean => { - return ( - address.length === nativeSegwitAddressLength || - address.length === taprootAddressLength - ); -}; - export const isTaproot = (address: string): boolean => { return address.length === taprootAddressLength; }; diff --git a/tests/utils/wallet/index.test.ts b/tests/utils/wallet/index.test.ts index 6383d93a..f8564c85 100644 --- a/tests/utils/wallet/index.test.ts +++ b/tests/utils/wallet/index.test.ts @@ -1,11 +1,6 @@ import { networks } from "bitcoinjs-lib"; -import { - getPublicKeyNoCoord, - isSupportedAddressType, - isTaproot, - toNetwork, -} from "@/utils/wallet"; +import { getPublicKeyNoCoord, isTaproot, toNetwork } from "@/utils/wallet"; import { Network } from "@/utils/wallet/btc_wallet_provider"; import { testingNetworks } from "../../helper"; @@ -36,22 +31,6 @@ describe("toNetwork", () => { }); }); -describe("isSupportedAddressType", () => { - it("should return true for native SegWit address length", () => { - expect(isSupportedAddressType(nativeSegWitAddress)).toBe(true); - }); - - it("should return true for Taproot address length", () => { - expect(isSupportedAddressType(taprootAddress)).toBe(true); - }); - - it("should return false for unsupported address length", () => { - expect(isSupportedAddressType(legacyAddress)).toBe(false); - expect(isSupportedAddressType(nestedSegWitAddress)).toBe(false); - expect(isSupportedAddressType("a".repeat(40))).toBe(false); - }); -}); - describe("isTaproot", () => { it("should return true for Taproot address length", () => { expect(isTaproot(taprootAddress)).toBe(true);