diff --git a/index.js b/index.js index 193c21824..203a042a2 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,7 @@ require('es6-promise').polyfill(); require('isomorphic-fetch'); -var Buffer = require('buffer').Buffer +var Buffer = require('buffer').Buffer; // This fixes a bug with Safari < 8 and the Browserify Buffer shim used in Crypto-browserify/randombytes // See: https://github.com/feross/buffer/issues/63 diff --git a/src/address.js b/src/address.js index da2b9af57..495c1c2b8 100644 --- a/src/address.js +++ b/src/address.js @@ -121,7 +121,7 @@ Object.defineProperties(Address.prototype, { MyWallet.syncWallet(); } else - { throw 'Error: address.archived must be a boolean';}; + { throw 'Error: address.archived must be a boolean';} } }, "active": { @@ -137,7 +137,7 @@ Address.factory = function(o,a){ } else { o[a.addr] = a; - }; + } return o; }; @@ -160,13 +160,13 @@ Address.import = function(key, label){ object.priv = Base58.encode(key.d.toBuffer(32)); break; case Helpers.isBitcoinPrivateKey(key): - key = Bitcoin.ECKey.fromWIF(key) + key = Bitcoin.ECKey.fromWIF(key); object.addr = key.pub.getAddress().toString(); object.priv = Base58.encode(key.d.toBuffer(32)); break; default: throw 'Error: address import format not supported'; - }; + } //initialization var address = new Address(object); @@ -200,9 +200,9 @@ Address.fromString = function(keyOrAddr, label, bipPass){ } else { reject('unknown key format'); } } - } + }; return new Promise(asyncParse); -} +}; Address.new = function(label){ var key = Bitcoin.ECKey.makeRandom(true, RNG.run.bind(RNG)); @@ -230,7 +230,7 @@ Address.prototype.toJSON = function(){ Address.prototype.encrypt = function(cipher){ if (!this._priv) return this; var priv = cipher ? cipher(this._priv) : this._priv; - if (!priv) { throw 'Error Encoding key'; }; + if (!priv) { throw 'Error Encoding key'; } this._temporal_priv = priv; return this; }; @@ -238,7 +238,7 @@ Address.prototype.encrypt = function(cipher){ Address.prototype.decrypt = function(cipher){ if (!this._priv) return this; var priv = cipher ? cipher(this._priv) : this._priv; - if (!priv) { throw 'Error Decoding key'; }; + if (!priv) { throw 'Error Decoding key'; } this._temporal_priv = priv; return this; }; diff --git a/src/api.js b/src/api.js index 4a10f0725..dc10646d4 100644 --- a/src/api.js +++ b/src/api.js @@ -23,7 +23,7 @@ function API(){ API.prototype.encodeFormData = function (data) { if (!data) return ""; var encoded = Object.keys(data).map(function(k) { - return encodeURIComponent(k) + '=' + encodeURIComponent(data[k]) + return encodeURIComponent(k) + '=' + encodeURIComponent(data[k]); }).join('&'); return encoded; }; @@ -55,7 +55,7 @@ API.prototype.request = function(action, method, data, withCred) { ) { return response.json(); } else if (data.format === 'json') { - return response.json() + return response.json(); } else { return response.text(); @@ -74,7 +74,7 @@ API.prototype.request = function(action, method, data, withCred) { .catch(handleNetworkError) .then(checkStatus) .then(handleResponse); -} +}; //////////////////////////////////////////////////////////////////////////////// API.prototype.retry = function(f, n) { @@ -87,7 +87,7 @@ API.prototype.retry = function(f, n) { ); } else { return f(); - }; + } }; //////////////////////////////////////////////////////////////////////////////// @@ -179,7 +179,7 @@ API.prototype.securePost = function (url, data){ if (!Helpers.isValidGUID(data.guid)) { clone.guid = MyWallet.wallet.guid; } if (!data.sharedKey) { var sharedKey = MyWallet.wallet ? MyWallet.wallet.sharedKey : undefined; - if (!Helpers.isValidSharedKey(sharedKey)) throw 'Shared key is invalid' + if (!Helpers.isValidSharedKey(sharedKey)) throw 'Shared key is invalid'; //Rather than sending the shared key plain text //send a hash using a totp scheme var now = new Date().getTime(); @@ -199,7 +199,7 @@ API.prototype.securePost = function (url, data){ clone.sKDebugOriginalClientTime = now; clone.sKDebugOriginalSharedKey = sharedKey; } - clone.api_code = this.API_CODE + clone.api_code = this.API_CODE; clone.format = data.format ? data.format : 'plain'; return this.retry(this.request.bind(this, "POST", url, clone, true)); @@ -224,7 +224,7 @@ API.prototype.pushTx = function (tx, note){ { return tx_hash;} else { return responseText;} - } + }; return this.request("POST", "pushtx", data).then(responseTXHASH); }; diff --git a/src/blockchain-settings-api.js b/src/blockchain-settings-api.js index 4972ef4f5..93cdf5c57 100644 --- a/src/blockchain-settings-api.js +++ b/src/blockchain-settings-api.js @@ -18,7 +18,7 @@ function get_account_info(success, error) { typeof(error) === "function" && error(); }); -}; +} function updateKV(txt, method, value, success, error, extra) { if(typeof value == "string") { @@ -40,7 +40,7 @@ function updateKV(txt, method, value, success, error, extra) { function update_API_access(enabled, success, error) { updateKV('Updating Api Access', 'update-api-access-enabled', enabled ? 1 : 0, success, error); -}; +} /** * @param {string} ips Multiple ip addresses should be comma separated. Use % as a wildcard. For example 127.0.0.% to whitelist 127.0.0.1-127.0.0.254. @@ -49,27 +49,27 @@ function update_API_access(enabled, success, error) { */ function update_IP_lock(ips, success, error) { updateKV('Updating Locked Ip Addresses', 'update-ip-lock', ips, success, error); -}; +} function update_IP_lock_on(enabled, success, error) { updateKV('Updating IP Lock', 'update-ip-lock-on', enabled ? true : false, success, error); -}; +} function change_language(language, success, error) { updateKV('Updating Language', 'update-language', language, success, error); -}; +} function change_local_currency(code, success, error) { updateKV('Updating Local Currency', 'update-currency', code, success, error); -}; +} function change_btc_currency(code, success, error) { updateKV('Updating BTC Currency', 'update-btc-currency', code, success, error); -}; +} function update_tor_ip_block(enabled, success, error) { updateKV('Updating TOR ip block', 'update-block-tor-ips', enabled, success, error); -}; +} function update_password_hint1(value, success, error) { switch (true) { @@ -84,8 +84,8 @@ function update_password_hint1(value, success, error) { break; default: updateKV('Updating Main Password Hint', 'update-password-hint1', value, success, error); - }; -}; + } +} function update_password_hint2(value, success, error) { switch (true) { @@ -100,16 +100,16 @@ function update_password_hint2(value, success, error) { break; default: updateKV('Updating Logging Level', 'update-password-hint2', value, success, error); - }; -}; + } +} function change_email(email, success, error) { updateKV('Updating Email', 'update-email', email, success, error); -}; +} function changeMobileNumber(val, success, error) { updateKV('Updating Cell Number', 'update-sms', val, success, error); -}; +} // Logging levels: // 0 - Logging disabled @@ -117,11 +117,11 @@ function changeMobileNumber(val, success, error) { // 2 - Log actions with IP addresses and user agents function updateLoggingLevel(val, success, error) { updateKV('Updating Logging Level', 'update-logging-level', val, success, error); -}; +} function toggleSave2FA(val, success, error) { updateKV('Updating Save 2FA', 'update-never-save-auth-type', val ? true : false, success, error); -}; +} function updateAuthType(val, success, error) { updateKV('Updating Two Factor Authentication', 'update-auth-type', val, function() { @@ -132,11 +132,11 @@ function updateAuthType(val, success, error) { function unsetTwoFactor(success, error) { updateAuthType(0, success, error); -}; +} function setTwoFactorSMS(success, error) { updateAuthType(5, success, error); -}; +} function setTwoFactorYubiKey(code, success, error) { assert(code, "Activation code required"); @@ -155,11 +155,11 @@ function setTwoFactorYubiKey(code, success, error) { error("Failed to configure Yubikey"); } ); -}; +} function setTwoFactorEmail(success, error) { updateAuthType(2, success, error); -}; +} function setTwoFactorGoogleAuthenticator(success, error) { MyWallet.securePost("wallet", { method : 'generate-google-secret' }, function(google_secret_url) { @@ -168,14 +168,14 @@ function setTwoFactorGoogleAuthenticator(success, error) { WalletStore.sendEvent("msg", {type: "error", message: data.responseText}); typeof(error) === "function" && error(data.responseText); }); -}; +} function confirmTwoFactorGoogleAuthenticator(code, success, error) { updateKV('Updating Two Factor Authentication', 'update-auth-type', 4, function() { WalletStore.setRealAuthType(4); typeof(success) === "function" && success(); }, error, '?code='+code); -}; +} /** * Resend email with verfication code. @@ -185,7 +185,7 @@ function confirmTwoFactorGoogleAuthenticator(code, success, error) { */ function resendEmailConfirmation(email, success, error) { updateKV('Resend Email Confirmation', 'update-email', email, success, error); -}; +} /** * Verify email with code. @@ -200,7 +200,7 @@ function verifyEmail(code, success, error) { }, function(data) { typeof(error) === "function" && error(); }); -}; +} /** * Verify mobile with code. @@ -216,7 +216,7 @@ function verifyMobile(code, success, error) { WalletStore.sendEvent("msg", {type: "error", message: data}); typeof(error) === "function" && error(); }); -}; +} function getActivityLogs(success, error) { MyWallet.securePost("wallet", {method : 'list-logs', format : 'json'}, function(data) { @@ -226,7 +226,7 @@ function getActivityLogs(success, error) { WalletStore.sendEvent("msg", {type: "error", message: response}); typeof(error) === "function" && error(); }); -}; +} function enableEmailNotifications(success, error) { API.securePost("wallet", { diff --git a/src/blockchain-wallet.js b/src/blockchain-wallet.js index 1b9c161e9..152eeab90 100644 --- a/src/blockchain-wallet.js +++ b/src/blockchain-wallet.js @@ -51,7 +51,7 @@ function Wallet(object) { if (this.isUpgradedToHD){ Helpers.merge(this._paidTo, this.hdwallet._paidTo); // move paidTo from the wrong place delete this.hdwallet._paidTo; - }; + } // address book list // address book in json is [{address: "address1", label: "label1"} , ... ] @@ -119,7 +119,7 @@ Object.defineProperties(Wallet.prototype, { default: this._fee_per_kb = value; MyWallet.syncWallet(); - }; + } } }, "pbkdf2_iterations": { @@ -337,7 +337,7 @@ Wallet.prototype._updateWalletInfo = function(obj) { this.numberTxTotal = 0; this.numberTxFetched = 0; return true; - }; + } this.totalSent = obj.wallet.total_sent; this.totalReceived = obj.wallet.total_received; @@ -357,15 +357,15 @@ Wallet.prototype._updateWalletInfo = function(obj) { if (account.getLabelForReceivingAddress(account.receiveIndex)) { account.incrementReceiveIndex(); - }; - }; + } + } } var address = this.activeKey(e.address); if (address){ address.balance = e.final_balance; address.totalReceived = e.total_received; address.totalSent = e.total_sent; - }; + } }; obj.addresses.forEach(updateAccountAndAddressesInfo.bind(this)); @@ -406,7 +406,7 @@ Wallet.prototype.fetchMoreTransactions = function(didFetchOldestTransaction) { this.numberTxFetched += pTx.length; if (pTx.length < this.txPerScroll) { didFetchOldestTransaction(); } return pTx; - }; + } return txListP.then(processTxs.bind(this)); }; @@ -440,7 +440,7 @@ Wallet.prototype.toJSON = function(){ function addressBookToJSON (addressBook) { return Object.keys(addressBook) .map(function(a){ return {addr: a, label: addressBook[a]};}); - }; + } var wallet = { guid : this.guid, @@ -470,7 +470,7 @@ Wallet.prototype.addKeyToLegacyAddress = function (privateKey, addr, secPass, bi var watchOnlyKey = this._addresses[addr]; if (newKey.address !== watchOnlyKey.address) { if (!this.containsLegacyAddress(newKey.address)) { - console.log(newKey) + console.log(newKey); return this.importLegacyAddress(privateKey, null, secPass, bipPass); } else { if (this.key(newKey.address).isWatchOnly) { @@ -525,7 +525,7 @@ Wallet.prototype.importLegacyAddress = function (addr, label, secPass, bipPass) Wallet.prototype.containsLegacyAddress = function(address) { if(Helpers.isInstanceOf(address, Address)) address = address.address; return this._addresses.hasOwnProperty(address); -} +}; Wallet.prototype.newLegacyAddress = function(label, pw, success, error){ try { @@ -539,7 +539,7 @@ Wallet.prototype.newLegacyAddress = function(label, pw, success, error){ assert(pw, "Error: second password needed"); var cipher = WalletCrypto.cipherFunction(pw, this._sharedKey, this._pbkdf2_iterations, "enc"); ad.encrypt(cipher).persist(); - }; + } this._addresses[ad.address] = ad; MyWallet.syncWallet(success, error); return ad; @@ -581,13 +581,13 @@ Wallet.prototype.encrypt = function(pw, success, error, encrypting, syncing){ else { // already encrypted return this; - }; + } } catch (e){ console.log("wallet encryption failure"); error && error(e); return false; - }; + } // if encryption finished well, then save this._dpasswordhash = WalletCrypto.hashNTimes(this._sharedKey + pw, this._pbkdf2_iterations); this._double_encryption = true; @@ -612,13 +612,13 @@ Wallet.prototype.decrypt = function(pw, success, error, decrypting, syncing){ else { // already decrypted return this; - }; + } } catch (e){ console.log("wallet decryption failure"); error && error(e); return false; - }; + } // if encryption finished well, then save this._dpasswordhash = undefined; this._double_encryption = false; @@ -627,14 +627,14 @@ Wallet.prototype.decrypt = function(pw, success, error, decrypting, syncing){ this._hd_wallets.forEach(p); syncing && syncing(); if (success) { MyWallet.syncWallet(success.bind(undefined, this));} - else {MyWallet.syncWallet();}; + else {MyWallet.syncWallet();} return this; }; Wallet.reviver = function(k,v){ if (k === '') return new Wallet(v); return v; -} +}; function isAccountNonUsed (account, progress) { var isNonUsed = function(obj){ @@ -642,7 +642,7 @@ function isAccountNonUsed (account, progress) { return obj.addresses[0].account_index === 0 && obj.addresses[0].change_index === 0; }; return API.getHistory([account.extendedPublicKey], 0, 0, 50).then(isNonUsed); -}; +} Wallet.prototype.restoreHDWallet = function(mnemonic, bip39Password, pw, startedRestoreHDWallet, progress){ // wallet restoration @@ -661,7 +661,7 @@ Wallet.prototype.restoreHDWallet = function(mnemonic, bip39Password, pw, started var untilNEmptyAccounts = function(n){ var go = function(nonused) { if (nonused) { return untilNEmptyAccounts(n-1);} - else { return untilNEmptyAccounts(AccountsGap);}; + else { return untilNEmptyAccounts(AccountsGap);} }; if (n === 0) { self.hdwallet._accounts.splice(-AccountsGap); @@ -670,7 +670,7 @@ Wallet.prototype.restoreHDWallet = function(mnemonic, bip39Password, pw, started accountIndex++; account = self.newAccount("My Bitcoin Wallet " + accountIndex.toString(), pw, 0, undefined, true); return isAccountNonUsed(account, progress).then(go); - }; + } }; var saveAndReturn = function (){ @@ -698,7 +698,7 @@ Wallet.prototype.enableNotifications = function(success, error) { error(); } ) -} +}; Wallet.prototype.disableNotifications = function(success, error) { assert(success, "Success callback required"); @@ -715,7 +715,7 @@ Wallet.prototype.disableNotifications = function(success, error) { } ); -} +}; // creating a new wallet object Wallet.new = function(guid, sharedKey, firstAccountLabel, success, error, isHD){ @@ -744,7 +744,7 @@ Wallet.new = function(guid, sharedKey, firstAccountLabel, success, error, isHD){ // legacy wallet (generate address) var ad = Address.new(label); MyWallet.wallet._addresses[ad.address] = ad; - }; + } } catch (e) { error(e); return; } success(MyWallet.wallet); }; @@ -772,7 +772,7 @@ Wallet.prototype.newAccount = function(label, pw, hdwalletIndex, success, nosave var cipher = undefined; if (this.isDoubleEncrypted) { cipher = WalletCrypto.cipherFunction.bind(undefined, pw, this._sharedKey, this._pbkdf2_iterations); - }; + } var newAccount = this._hd_wallets[index].newAccount(label, cipher).lastAccount; MyWallet.listenToHDWalletAccount(newAccount.extendedPublicKey); if(!(nosave === true)) MyWallet.syncWallet(); @@ -833,8 +833,8 @@ Wallet.prototype.changePbkdf2Iterations = function(newIterations, password){ this._pbkdf2_iterations = newIterations; // sec pass iterations WalletStore.setPbkdf2Iterations(newIterations); // main pass iterations MyWallet.syncWallet(); - }; - }; + } + } return true; }; @@ -845,7 +845,7 @@ Wallet.prototype.getPrivateKeyForAddress = function(address, secondPassword) { pk = this.isDoubleEncrypted ? WalletCrypto.decryptSecretWithSecondPassword( address.priv, secondPassword, this.sharedKey, this.pbkdf2_iterations) : address.priv; - }; + } return pk; }; diff --git a/src/hd-account.js b/src/hd-account.js index 11bd819d5..7d19fe931 100644 --- a/src/hd-account.js +++ b/src/hd-account.js @@ -51,7 +51,7 @@ Object.defineProperties(HDAccount.prototype, { MyWallet.syncWallet(); }else{ throw 'Error: account.label must be an alphanumeric string'; - }; + } } }, "balance": { @@ -243,7 +243,7 @@ HDAccount.factory = function(o){ if (o instanceof Object && !(o instanceof HDAccount)) { return new HDAccount(o); } - else { return o; }; + else { return o; } }; //////////////////////////////////////////////////////////////////////////////// // JSON SERIALIZER @@ -266,7 +266,7 @@ HDAccount.prototype.toJSON = function(){ HDAccount.reviver = function(k,v){ if (k === '') return new HDAccount(v); return v; -} +}; //////////////////////////////////////////////////////////////////////////////// @@ -277,7 +277,7 @@ HDAccount.prototype.incrementReceiveIndex = function() { HDAccount.prototype.incrementReceiveIndexIfLast = function(index) { if (this._receiveIndex === index){ this.incrementReceiveIndex(); - }; + } return this; }; //////////////////////////////////////////////////////////////////////////////// @@ -319,7 +319,7 @@ HDAccount.prototype.receiveAddressAtIndex = function(index) { HDAccount.prototype.encrypt = function(cipher){ if(!this._xpriv) return this; var xpriv = cipher? cipher(this._xpriv) : this._xpriv; - if (!xpriv) { throw 'Error Encoding account extended private key'; }; + if (!xpriv) { throw 'Error Encoding account extended private key'; } this._temporal_xpriv = xpriv; return this; }; @@ -327,7 +327,7 @@ HDAccount.prototype.encrypt = function(cipher){ HDAccount.prototype.decrypt = function(cipher){ if(!this._xpriv) return this; var xpriv = cipher? cipher(this._xpriv) : this._xpriv; - if (!xpriv) { throw 'Error Decoding account extended private key'; }; + if (!xpriv) { throw 'Error Decoding account extended private key'; } this._temporal_xpriv = xpriv; return this; }; diff --git a/src/hd-wallet.js b/src/hd-wallet.js index 7dae18b9d..49f118569 100644 --- a/src/hd-wallet.js +++ b/src/hd-wallet.js @@ -16,7 +16,7 @@ function HDWallet(object){ function addAccount (o, index){ o.index = index; return HDAccount.factory(o); - }; + } // private members var obj = object || {}; @@ -54,7 +54,7 @@ Object.defineProperties(HDWallet.prototype, { } else{ throw 'Error: unvalid default index account'; - }; + } } }, "defaultAccount": { @@ -88,7 +88,7 @@ Object.defineProperties(HDWallet.prototype, { "balanceActiveAccounts":{ configurable: false, get: function() { - var balances = this.activeAccounts.map(function(k){return k.balance;}) + var balances = this.activeAccounts.map(function(k){return k.balance;}); if (balances.some(Helpers.isNotNumber)) return null; return balances.reduce(Helpers.add, 0); } @@ -126,24 +126,24 @@ function decryptMnemonic (seedHex, cipher){ return BIP39.entropyToMnemonic(seedHex); } else { throw "Decryption function needed to get the mnemonic"; - }; - }; -}; + } + } +} function decryptPassphrase (bip39Password, cipher){ - if (bip39Password === "") {return bip39Password}; + if (bip39Password === "") {return bip39Password} if (cipher) { return cipher(bip39Password); } else { return bip39Password; - }; -}; + } +} function getMasterHex (seedHex, bip39Password, cipher){ var mnemonic = decryptMnemonic(seedHex, cipher); var passphrase = decryptPassphrase(bip39Password, cipher); return BIP39.mnemonicToSeed(mnemonic, passphrase); -}; +} //////////////////////////////////////////////////////////////////////////////// // Constructors @@ -172,7 +172,7 @@ HDWallet.restore = function(seedHex, bip39Password, cipher){ var newHDwallet = new HDWallet(hdwallet); if (cipher) { newHDwallet.encrypt(cipher).persist(); - }; + } return newHDwallet; }; @@ -180,7 +180,7 @@ HDWallet.factory = function(o){ if (o instanceof Object && !(o instanceof HDWallet)) { return new HDWallet(o); } - else { return o; }; + else { return o; } }; HDWallet.prototype.newAccount = function(label, cipher){ @@ -192,7 +192,7 @@ HDWallet.prototype.newAccount = function(label, cipher){ if (cipher) { dec = cipher("dec"); enc = cipher("enc"); - }; + } var masterhex = getMasterHex(this._seedHex, this._bip39Password, dec); var network = Bitcoin.networks.bitcoin; @@ -234,7 +234,7 @@ HDWallet.prototype.verifyMnemonic = function(){ HDWallet.prototype.account = function(xpub){ var f = this._accounts - .filter(function(a){return a.extendedPublicKey === xpub}) + .filter(function(a){return a.extendedPublicKey === xpub}); var r = f.length === 0 ? null : f[0]; return r; }; @@ -249,7 +249,7 @@ HDWallet.prototype.activeAccount = function(xpub){ // account managment HDWallet.prototype.encrypt = function(cipher){ - function f(acc) {acc.encrypt(cipher);}; + function f(acc) {acc.encrypt(cipher);} this._accounts.forEach(f); this._temporal_seedHex = cipher(this._seedHex); this._temporal_bip39Password = this._bip39Password === "" @@ -259,7 +259,7 @@ HDWallet.prototype.encrypt = function(cipher){ }; HDWallet.prototype.decrypt = function(cipher){ - function f(acc) {acc.decrypt(cipher);}; + function f(acc) {acc.decrypt(cipher);} this._accounts.forEach(f); this._temporal_seedHex = cipher(this._seedHex); this._temporal_bip39Password = this._bip39Password === "" @@ -270,12 +270,12 @@ HDWallet.prototype.decrypt = function(cipher){ HDWallet.prototype.persist = function(){ if (this._temporal_seedHex === undefined || this._temporal_bip39Password === undefined) - {return this;}; + {return this;} this._seedHex = this._temporal_seedHex; this._bip39Password = this._temporal_bip39Password; delete this._temporal_seedHex; delete this._temporal_bip39Password; - function f(acc) {acc.persist();}; + function f(acc) {acc.persist();} this._accounts.forEach(f); return this; }; @@ -295,7 +295,7 @@ HDWallet.prototype.forEachPaidTo = function(f) { // f is a function taking (txHash, paidToElement) for (var txHash in this._paidTo) { f(txHash, this._paidTo[txHash]); - }; + } return this; }; //////////////////////////////////////////////////////////////////////////////// diff --git a/src/helpers.js b/src/helpers.js index 83b342d12..6ac3f3b12 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -269,7 +269,7 @@ Helpers.getHostName = function() { } return window.location.hostname; -} +}; Helpers.tor = function () { var hostname = Helpers.getHostName() @@ -278,7 +278,7 @@ Helpers.tor = function () { if(hostname === null) return null return hostname.indexOf(".onion") > -1 -} +}; //////////////////////////////////////////////////////////////////////////////// diff --git a/src/keychain.js b/src/keychain.js index ca71ef125..289308ce1 100644 --- a/src/keychain.js +++ b/src/keychain.js @@ -15,10 +15,10 @@ function KeyChain(extendedKey, index, cache) { // this function should be part of the instance because it is memoized this._getKey = Helpers.memoize(function(index) { assert(typeof(index) === "number" && index >= 0, "Key index must be integer >= 0"); - assert(this._chainRoot, "KeyChain is not initialized.") + assert(this._chainRoot, "KeyChain is not initialized."); return this._chainRoot.derive(index); }); -}; +} Object.defineProperties(KeyChain.prototype, { "xpub": { @@ -38,7 +38,7 @@ KeyChain.prototype.init = function(extendedKey, index, cache) { else { this._chainRoot = extendedKey && Helpers.isNumber(index) && index >= 0 ? Bitcoin.HDNode.fromBase58(extendedKey).derive(index) : undefined; - }; + } return this; }; diff --git a/src/keyring.js b/src/keyring.js index 64f2eb2fd..1543a5344 100644 --- a/src/keyring.js +++ b/src/keyring.js @@ -12,7 +12,7 @@ function KeyRing(extendedKey, cache) { this._receiveChain = null; this._changeChain = null; this.init(extendedKey, cache); -}; +} Object.defineProperties(KeyRing.prototype, { "receive": { @@ -55,6 +55,6 @@ KeyRing.prototype.toJSON = function (){ var cacheJSON = { receiveAccount : this._receiveChain.xpub, changeAccount : this._changeChain.xpub - } + }; return cacheJSON; }; diff --git a/src/rng.js b/src/rng.js index 3bd7d327b..aceaef5fb 100644 --- a/src/rng.js +++ b/src/rng.js @@ -105,4 +105,4 @@ RNG.prototype.getServerEntropy = function (nBytes) { else { throw 'Received not ok status: ' + request.status; } -} +}; diff --git a/src/shared.js b/src/shared.js index 521a54fc1..fc1609be0 100644 --- a/src/shared.js +++ b/src/shared.js @@ -25,7 +25,7 @@ module.exports = { BlockFromJSON: BlockFromJSON }; -function myprint (x) {console.log(x);}; +function myprint (x) {console.log(x);} function setLocalSymbol(new_symbol) { if (!new_symbol) return; @@ -65,7 +65,7 @@ function playSound(id) { _sounds[id].play(); } catch (e) { } -}; +} //Ignore Console try { diff --git a/src/sharedcoin.js b/src/sharedcoin.js index bbbf27288..e4fdf0dc0 100644 --- a/src/sharedcoin.js +++ b/src/sharedcoin.js @@ -68,7 +68,7 @@ var SharedCoin = new function() { var scriptLength = readVarInt(buffer).intValue(); var script = new Bitcoin.Script(buffer.splice(0, scriptLength)); - var out = new Bitcoin.TransactionOut({script : script, value : valueBytes}) + var out = new Bitcoin.TransactionOut({script : script, value : valueBytes}); tx.outs.push(out); } @@ -143,7 +143,7 @@ var SharedCoin = new function() { this.modal.find('.btn.btn-secondary').prop('disabled', false); } } - } + }; this.newProposal = function() { return { _pollForCompleted : function(success, error) { @@ -179,7 +179,7 @@ var SharedCoin = new function() { } else { error('Unknown status ' + obj.status) } - } + }; self._pollForCompleted(handleObj, error) } @@ -265,7 +265,7 @@ var SharedCoin = new function() { } else { error('Unknown status ' + obj.status) } - } + }; self._pollForProposalID(handleObj, error) }, @@ -581,7 +581,7 @@ var SharedCoin = new function() { extra_private_keys[address.toString()] = Bitcoin.Base58.encode(key.priv); return address; - } + }; this.newPlan = function() { return { @@ -927,47 +927,47 @@ var SharedCoin = new function() { this.getMaximumOfferNumberOfInputs = function() { return options.maximum_offer_number_of_inputs; - } + }; this.getMaximumOfferNumberOfOutputs = function() { return options.maximum_offer_number_of_outputs; - } + }; this.getMinimumOutputValue = function() { return options.minimum_output_value; - } + }; this.getMinimumOutputValueExcludingFee = function() { return options.minimum_output_value_exclude_fee; - } + }; this.getToken = function() { return options.token; - } + }; this.getMinimumInputValue = function() { return options.minimum_input_value; - } + }; this.getMinimumSupportedVersion = function() { return options.min_supported_version; - } + }; this.getIsEnabled = function() { return options.enabled; - } + }; this.getMaximumOutputValue = function() { return options.maximum_output_value; - } + }; this.getFee = function() { return options.fee_percent; - } + }; this.getMinimumFee = function() { return options.minimum_fee ? options.minimum_fee : 0; - } + }; this.constructPlan = function(el, success, error) { try { @@ -1025,7 +1025,7 @@ var SharedCoin = new function() { throw 'You must enter a value greater than zero'; } catch (e) { throw 'Invalid send amount'; - }; + } //Trim and remove non-printable characters var send_to_address = (send_to_input.val()).replace(/[\u200B-\u200D\uFEFF]/g, '').trim(); @@ -1174,7 +1174,7 @@ var SharedCoin = new function() { } catch (e) { _error(e); } - } + }; this.calculateFeeForValue = function(fee_percent, input_value) { var minFee = BigInteger.valueOf(SharedCoin.getMinimumFee()); @@ -1192,7 +1192,7 @@ var SharedCoin = new function() { } else { return minFee; } - } + }; this.recoverSeeds = function(shared_coin_seeds, success, error) { var key = 0; @@ -1351,7 +1351,7 @@ var SharedCoin = new function() { console.log('Recover Error'); }); } - }, 2000) + }, 2000); progressModal.enableCancel(); }; @@ -1366,7 +1366,7 @@ var SharedCoin = new function() { progressModal.hide(); enableSendButton(); - } + }; if (input_value.compareTo(BigInteger.valueOf(SharedCoin.getMinimumOutputValue())) < 0) { WalletStore.sendEvent("msg", {type: "error", message: 'The Minimum Send Value is ' + formatPrecision(SharedCoin.getMinimumOutputValue())}); @@ -1462,4 +1462,4 @@ var SharedCoin = new function() { enableSendButton(); } -} +}; diff --git a/src/transaction.js b/src/transaction.js index d25eadf67..d408519fc 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -81,7 +81,7 @@ var Transaction = function (unspentOutputs, toAddresses, amounts, fee, changeAdd if (accum < subTotal) { throw { error: 500, message: 'Insufficient funds. Value Needed ' + subTotal / 100000000 + 'BTC' +'. Available amount ' + accum / 100000000 + 'BTC'}; - }; + } this.transaction = transaction; }; @@ -113,7 +113,7 @@ Transaction.prototype.randomizeOutputs = function () { function shuffle(o){ for(var j, x, i = o.length; i > 1; j = randomNumberBetweenZeroAnd(i), x = o[--i], o[i] = o[j], o[j] = x); return o; - }; + } shuffle(this.transaction.outs); }; @@ -126,8 +126,8 @@ Transaction.prototype.sortBIP69 = function (){ var compareInputs = function(a, b) { var hasha = new Buffer(a[0].hash); var hashb = new Buffer(b[0].hash); - var x = [].reverse.call(hasha) - var y = [].reverse.call(hashb) + var x = [].reverse.call(hasha); + var y = [].reverse.call(hashb); return x.compare(y) || a[0].index - b[0].index }; var compareOutputs = function(a, b) { diff --git a/src/wallet-network.js b/src/wallet-network.js index ec708d8bc..9a369398f 100644 --- a/src/wallet-network.js +++ b/src/wallet-network.js @@ -18,7 +18,7 @@ function generateUUIDs(count) { return API.retry(API.request.bind(API, 'GET', 'uuid-generator', data)) .then(extractUUIDs); -}; +} /** * Fetch information on wallet identfier with resend code set to true @@ -42,7 +42,7 @@ function resendTwoFactorSms(user_guid) { return API.request('GET', 'wallet/' + user_guid, data, true, false) .catch(handleError); -}; +} /** * Trigger an email with the users wallet guid(s) @@ -73,7 +73,7 @@ function recoverGuid(user_email, captcha) { return API.request('POST', 'wallet', data, true) .then(handleResponse).catch(handleError); -}; +} /** * Trigger the 2FA reset process @@ -112,7 +112,7 @@ function requestTwoFactorReset( return API.request('POST', 'wallet', data, true) .then(handleResponse); -}; +} module.exports = { generateUUIDs: generateUUIDs, diff --git a/src/wallet-signup.js b/src/wallet-signup.js index fe7de1e17..d19734ab1 100644 --- a/src/wallet-signup.js +++ b/src/wallet-signup.js @@ -104,7 +104,7 @@ function generateNewWallet(password, email, firstAccountName, success, error, is Wallet.new(guid, sharedKey, firstAccountName, saveWallet, error, isHD); }).catch(error); -}; +} module.exports = { generateNewWallet: generateNewWallet diff --git a/src/wallet-token-endpoints.js b/src/wallet-token-endpoints.js index e5c56b1e0..3f09486b2 100644 --- a/src/wallet-token-endpoints.js +++ b/src/wallet-token-endpoints.js @@ -52,7 +52,7 @@ function authorizeApprove(token, differentBrowserCallback, differentBrowserAppro } }; - var extraParams = {} + var extraParams = {}; if (differentBrowserApproved !== null) { extraParams.confirm_approval = differentBrowserApproved; } diff --git a/src/wallet-transaction.js b/src/wallet-transaction.js index f7f2f1241..a6724da27 100644 --- a/src/wallet-transaction.js +++ b/src/wallet-transaction.js @@ -130,13 +130,13 @@ Object.defineProperties(Tx.prototype, { var impactNoFee = this.result + this.fee; switch (true) { case impactNoFee === 0: - v = "transfer" + v = "transfer"; break; case impactNoFee < 0: - v = "sent" + v = "sent"; break; case impactNoFee > 0: - v = "received" + v = "received"; break; default: v = "complex" @@ -162,37 +162,37 @@ Object.defineProperties(Tx.prototype, { get: function() { return this._processed_outs.some(function (o) { return o.isWatchOnly; }); } - }, + } }); function isAccount(x) { if (x.xpub) { return true;} else {return false;} -}; +} function isLegacy(x) { return MyWallet.wallet.containsLegacyAddress(x.addr); -}; +} function isInternal(x) { return (isAccount(x) || isLegacy(x)); -}; +} function isAccountChange(x) { return (isAccount(x) && x.xpub.path.split('/')[1] === '1'); -}; +} function accountPath(x){ return account(x).index + x.xpub.path.substr(1); -}; +} function account(x) { return MyWallet.wallet.hdwallet.account(x.xpub.m); -}; +} function address(x) { return MyWallet.wallet.key(x.addr); -}; +} function tagCoin(x) { var ad = x.addr; @@ -229,15 +229,15 @@ function tagCoin(x) { identity: id, isWatchOnly: isWatchOnly }; -}; +} function unpackInput(input) { return input.prev_out; -}; +} Tx.factory = function(o){ if (o instanceof Object && !(o instanceof Tx)) { return new Tx(o); } - else { return o; }; + else { return o; } }; diff --git a/src/wallet.js b/src/wallet.js index aae44577f..ef3e73036 100644 --- a/src/wallet.js +++ b/src/wallet.js @@ -214,7 +214,7 @@ function socketConnect() { } if (addresses.some(function(a){return a === account.receiveAddress})){ account.incrementReceiveIndex(); - }; + } } } @@ -240,7 +240,7 @@ function socketConnect() { WalletStore.setLatestBlock(shared.BlockFromJSON(obj.x)); WalletStore.sendEvent('on_block'); } - }; + } function onOpen() { WalletStore.sendEvent('ws_on_open'); @@ -263,11 +263,11 @@ function socketConnect() { } MyWallet.ws.send(msg); - }; + } function onClose() { WalletStore.sendEvent('ws_on_close'); - }; + } } // used in walletstore and locally wallet.js @@ -382,7 +382,7 @@ MyWallet.processTransaction = function(tx) { transaction.to.email = { email: paidToItem.email, redeemedAt: paidToItem.redeemedAt }; } else if (paidToItem.mobile) { transaction.to.mobile = { number: paidToItem.mobile, redeemedAt: paidToItem.redeemedAt }; - }; + } transaction.intraWallet = false; }else { var toAccountSet = false; @@ -572,7 +572,7 @@ MyWallet.getBalanceForRedeemCode = function(privatekey, successCallback, errorCa return Object.keys(data) .map(function(a){ return data[a].final_balance;}) .reduce(Helpers.add, 0); - }; + } API.getBalances([from_address_compressed, from_address_uncompressed]) .then(totalBalance) @@ -757,7 +757,7 @@ function decryptAndInitializeWallet(success, error, decrypt_success, build_hd_su } if (MyWallet.wallet.isUpgradedToHD === false) { WalletStore.sendEvent('hd_wallets_does_not_exist'); - }; + } setIsInitialized(); success(); }, @@ -829,7 +829,7 @@ MyWallet.login = function ( user_guid return; } successCallback(obj) - } + }; var error = function(e) { console.log(e); @@ -849,9 +849,9 @@ MyWallet.login = function ( user_guid if (obj.initial_error) { WalletStore.sendEvent("msg", {type: "error", message: obj.initial_error}); } - } + }; API.request("GET", 'wallet/' + guid, data, true, false).then(success).catch(error); - } + }; var tryToFetchWalletWith2FA = function (guid, two_factor_auth_key, successCallback) { @@ -870,15 +870,15 @@ MyWallet.login = function ( user_guid } if (data != 'Not modified') { WalletStore.setEncryptedWalletData(data); } successCallback(data); - } + }; var error = function (response) { WalletStore.setRestoringWallet(false); wrong_two_factor_code(response); - } + }; var myData = { guid: guid, payload: two_factor_auth_key, length : two_factor_auth_key.length, method : 'get-wallet', format : 'plain', api_code : API.API_CODE}; API.request("POST", 'wallet', myData, true, false).then(success).catch(error); - } + }; var didFetchWalletJSON = function(obj) { @@ -979,7 +979,7 @@ function setIsInitialized() { if (isInitialized) return; socketConnect(); isInitialized = true; -}; +} // used on iOS MyWallet.connectWebSocket = function() { @@ -1093,7 +1093,7 @@ function syncWallet (successcallback, errorcallback) { } catch (e) { _errorcallback(e); WalletStore.enableLogout(); - }; + } }, function(e) { console.log(e); @@ -1104,10 +1104,10 @@ function syncWallet (successcallback, errorcallback) { WalletStore.enableLogout(); } -}; +} MyWallet.syncWallet = Helpers.asyncOnce(syncWallet, 1500, function(){ console.log("SAVE CALLED..."); - WalletStore.setIsSynchronizedWithServer(false) + WalletStore.setIsSynchronizedWithServer(false); }); //////////////////////////////////////////////////////////////////////////////// // used mainly on blockchain API @@ -1186,13 +1186,13 @@ function nKeys(obj) { size++; } return size; -}; +} // used on frontend MyWallet.recoverFromMnemonic = function(inputedEmail, inputedPassword, recoveryMnemonic, bip39Password, success, error, startedRestoreHDWallet, accountProgress, generateUUIDProgress, decryptWalletProgress) { var walletSuccess = function(guid, sharedKey, password) { WalletStore.unsafeSetPassword(password); - var runSuccess = function () {success({ guid: guid, sharedKey: sharedKey, password: password});} + var runSuccess = function () {success({ guid: guid, sharedKey: sharedKey, password: password});}; MyWallet.wallet.restoreHDWallet(recoveryMnemonic, bip39Password, undefined, startedRestoreHDWallet, accountProgress).then(runSuccess).catch(error); }; WalletSignup.generateNewWallet(inputedPassword, inputedEmail, null, walletSuccess, error, true, generateUUIDProgress, decryptWalletProgress); @@ -1207,7 +1207,7 @@ MyWallet.logout = function(force) { console.log(e); } }; - var data = {format : 'plain', api_code : API.API_CODE} + var data = {format : 'plain', api_code : API.API_CODE}; WalletStore.sendEvent('logging_out'); API.request("GET", 'wallet/logout', data, true, false).then(reload).catch(reload); };