RegEx update depending on currency chosen. Looks like it works, yey!

This commit is contained in:
Lucas Legname 2014-03-05 21:30:30 +01:00
parent 90e86a56b6
commit 2ab9acc3fc

View file

@ -50,17 +50,19 @@ janin.currency.useCurrencyWallet = function(_networkVersion, _privateKeyPrefix,
// 51 characters base58, always starts with a '5' // 51 characters base58, always starts with a '5'
Bitcoin.ECKey.isWalletImportFormat = function (key) { Bitcoin.ECKey.isWalletImportFormat = function (key) {
key = key.toString(); key = key.toString();
return (ECKey.privateKeyPrefix == _privateKeyPrefix) ? var currencyRegEx = new RegExp(_walletImportFormatRegEx);
(/^5[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{50}$/.test(key)) : var testnetRegEx = new RegExp("^9[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{50}$");
(/^9[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{50}$/.test(key));
return (ECKey.privateKeyPrefix == _privateKeyPrefix) ? (currencyRegEx.test(key)) : (testnetRegEx.test(key));
}; };
// 52 characters base58 // 52 characters base58
Bitcoin.ECKey.isCompressedWalletImportFormat = function (key) { Bitcoin.ECKey.isCompressedWalletImportFormat = function (key) {
key = key.toString(); key = key.toString();
return (ECKey.privateKeyPrefix == _privateKeyPrefix) ? var currencyRegEx = new RegExp(_compressedWalletImportRegEx);
(/^[LK][123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{51}$/.test(key)) : var testnetRegEx = new RegExp("^c[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{51}$");
(/^c[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{51}$/.test(key));
return (ECKey.privateKeyPrefix == _privateKeyPrefix) ? (currencyRegEx.test(key)) : (testnetRegEx.test(key));
}; };
ninja.wallets.singlewallet.generateNewAddressAndKey(); ninja.wallets.singlewallet.generateNewAddressAndKey();