From 2ab9acc3fce278575e1f7479115399781ef0b9da Mon Sep 17 00:00:00 2001 From: Lucas Legname Date: Wed, 5 Mar 2014 21:30:30 +0100 Subject: [PATCH] RegEx update depending on currency chosen. Looks like it works, yey! --- src/janin.walletmanager.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/janin.walletmanager.js b/src/janin.walletmanager.js index 0b5c746..82ee96b 100644 --- a/src/janin.walletmanager.js +++ b/src/janin.walletmanager.js @@ -50,17 +50,19 @@ janin.currency.useCurrencyWallet = function(_networkVersion, _privateKeyPrefix, // 51 characters base58, always starts with a '5' Bitcoin.ECKey.isWalletImportFormat = function (key) { key = key.toString(); - return (ECKey.privateKeyPrefix == _privateKeyPrefix) ? - (/^5[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{50}$/.test(key)) : - (/^9[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{50}$/.test(key)); + var currencyRegEx = new RegExp(_walletImportFormatRegEx); + var testnetRegEx = new RegExp("^9[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{50}$"); + + return (ECKey.privateKeyPrefix == _privateKeyPrefix) ? (currencyRegEx.test(key)) : (testnetRegEx.test(key)); }; // 52 characters base58 Bitcoin.ECKey.isCompressedWalletImportFormat = function (key) { key = key.toString(); - return (ECKey.privateKeyPrefix == _privateKeyPrefix) ? - (/^[LK][123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{51}$/.test(key)) : - (/^c[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{51}$/.test(key)); + var currencyRegEx = new RegExp(_compressedWalletImportRegEx); + var testnetRegEx = new RegExp("^c[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{51}$"); + + return (ECKey.privateKeyPrefix == _privateKeyPrefix) ? (currencyRegEx.test(key)) : (testnetRegEx.test(key)); }; ninja.wallets.singlewallet.generateNewAddressAndKey();