From 3b547c07b392d69fccf419592d61c39057aaaa3b Mon Sep 17 00:00:00 2001 From: sproxet <17163658+sproxet@users.noreply.github.com> Date: Tue, 17 Oct 2023 15:37:23 +0700 Subject: [PATCH] Special case new style LTC addresses for validation. --- .../components/CoinSwapPage/CoinSwapDetail.vue | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/renderer/components/CoinSwapPage/CoinSwapDetail.vue b/src/renderer/components/CoinSwapPage/CoinSwapDetail.vue index 2664f268..119bec56 100644 --- a/src/renderer/components/CoinSwapPage/CoinSwapDetail.vue +++ b/src/renderer/components/CoinSwapPage/CoinSwapDetail.vue @@ -216,6 +216,15 @@ const CoinNames = { const ChainOptions = PROVIDERS.map(p => ({id: p, name: p})); const DEFAULT_PROVIDER = PROVIDERS[0]; +function isValidLTCAddress(address) { + if (CryptoAddressValidator.validate(address, 'LTC')) + return true; + + // This is actually a really terrible validation, but their addresses use custom stuff that no one supports and it's + // not really worth it to make a custom decoder just to parse their addresses. + return !!address.match(/^ltc[a-zA-Z0-9]{38,42}$/); +} + export default { name: 'CoinSwapDetail', @@ -350,6 +359,9 @@ export default { else return 'Unknown coin (this is a bug)'; + if (this.selectedCoin == 'LTC') + return isValidLTCAddress(value) || 'Invalid address'; + try { return !!CryptoAddressValidator.validate(value, coin, 'prod') || 'Invalid address'; } catch(e) {