@@ -472,6 +479,15 @@
+
+
+
+
+
+
+
diff --git a/src/janin.walletmanager.js b/src/janin.walletmanager.js
new file mode 100644
index 0000000..0b5c746
--- /dev/null
+++ b/src/janin.walletmanager.js
@@ -0,0 +1,67 @@
+var janin = { currency: {
+ Address: {},
+ ECKey: {}
+ }};
+
+
+janin.currency.Address.networkVersions = [
+ 0x00, // Bitcoin
+ 0x1e // Dogecoin
+];
+
+janin.currency.ECKey.privateKeyPrefixes = [
+ 0x80, // Bitcoin
+ 0x9e // Dogecoin
+];
+
+janin.currency.WalletImportFormatRegEx = [
+ "^5[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{50}$", // Bitcoin
+ "^6[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{50}$" // Dogecoin
+];
+
+janin.currency.CompressedWalletImportRegEx = [
+ "^[LK][123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{51}$", // Bitcoin
+ "^T[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{51}$" // Dogecoin
+];
+
+
+janin.currency.changeWalletType = function (ddl) {
+
+ var netVersion = janin.currency.Address.networkVersions[ddl.selectedIndex];
+ var privKeyPrefix = janin.currency.ECKey.privateKeyPrefixes[ddl.selectedIndex];
+ var walletImportRegex = janin.currency.WalletImportFormatRegEx[ddl.selectedIndex];
+ var compressedWalletImportRegex = janin.currency.CompressedWalletImportRegEx[ddl.selectedIndex];
+
+ janin.currency.useCurrencyWallet(
+ netVersion,
+ privKeyPrefix,
+ walletImportRegex,
+ compressedWalletImportRegex
+ );
+
+
+};
+
+janin.currency.useCurrencyWallet = function(_networkVersion, _privateKeyPrefix, _walletImportFormatRegEx, _compressedWalletImportRegEx) {
+
+ Bitcoin.Address.networkVersion = _networkVersion; // mainnet
+ Bitcoin.ECKey.privateKeyPrefix = _privateKeyPrefix; // mainnet 0x80 testnet 0xEF
+
+ // 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));
+ };
+
+ // 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));
+ };
+
+ ninja.wallets.singlewallet.generateNewAddressAndKey();
+}