Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
breaking: remove reference to symbol_local and symbol_btc
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjors committed Nov 21, 2016
1 parent 2c599f1 commit 78d28c5
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 82 deletions.
7 changes: 0 additions & 7 deletions src/blockchain-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ var Address = require('./address');
var Helpers = require('./helpers');
var MyWallet = require('./wallet'); // This cyclic import should be avoided once the refactor is complete
var API = require('./api');
var shared = require('./shared');
var BlockchainSettingsAPI = require('./blockchain-settings-api');
var KeyRing = require('./keyring');
var TxList = require('./transaction-list');
Expand Down Expand Up @@ -321,12 +320,6 @@ Object.defineProperties(Wallet.prototype, {
// update-wallet-balances after multiaddr call
Wallet.prototype._updateWalletInfo = function (obj) {
if (obj.info) {
if (obj.info.symbol_local) {
shared.setLocalSymbol(obj.info.symbol_local);
}
if (obj.info.symbol_btc) {
shared.setBTCSymbol(obj.info.symbol_btc);
}
if (obj.info.notice) {
WalletStore.sendEvent('msg', {type: 'error', message: obj.info.notice});
}
Expand Down
24 changes: 0 additions & 24 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ var BigInteger = require('bigi');
var Buffer = require('buffer').Buffer;
var Base58 = require('bs58');
var BIP39 = require('bip39');
var shared = require('./shared');
var ImportExport = require('./import-export');
var constants = require('./constants');

Expand Down Expand Up @@ -434,29 +433,6 @@ Helpers.privateKeyCorrespondsToAddress = function (address, priv, bipPass) {
return new Promise(asyncParse).then(predicate);
};

function parseValueBitcoin (valueString) {
valueString = valueString.toString();
// TODO: Detect other number formats (e.g. comma as decimal separator)
var valueComp = valueString.split('.');
var integralPart = valueComp[0];
var fractionalPart = valueComp[1] || '0';
while (fractionalPart.length < 8) fractionalPart += '0';
fractionalPart = fractionalPart.replace(/^0+/g, '');
var value = BigInteger.valueOf(parseInt(integralPart, 10));
value = value.multiply(BigInteger.valueOf(100000000));
value = value.add(BigInteger.valueOf(parseInt(fractionalPart, 10)));
return value;
}

// The current 'shift' value - BTC = 1, mBTC = 3, uBTC = 6
function sShift (symbol) {
return (shared.satoshi / symbol.conversion).toString().length - 1;
}

Helpers.precisionToSatoshiBN = function (x) {
return parseValueBitcoin(x).divide(BigInteger.valueOf(Math.pow(10, sShift(shared.getBTCSymbol())).toString()));
};

Helpers.verifyMessage = function (address, signature, message) {
return Bitcoin.message.verify(address, signature, message, constants.getNetwork());
};
Expand Down
42 changes: 0 additions & 42 deletions src/shared.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,12 @@
/* eslint-disable camelcase */
var satoshi = 100000000; // One satoshi
var symbol_btc = {code: 'BTC', symbol: 'BTC', name: 'Bitcoin', conversion: satoshi, symbolAppearsAfter: true, local: false}; // Default BTC Currency Symbol object
var symbol_local = {'conversion': 0, 'symbol': '$', 'name': 'U.S. dollar', 'symbolAppearsAfter': false, 'local': true, 'code': 'USD'}; // Users local currency object
var symbol = symbol_btc; // Active currency object
var resource = 'Resources/';

module.exports = {
APP_NAME: 'javascript_web',
APP_VERSION: '3.0',
getBTCSymbol: getBTCSymbol,
getLocalSymbol: getLocalSymbol,
satoshi: satoshi,
setLocalSymbol: setLocalSymbol,
setBTCSymbol: setBTCSymbol,
playSound: playSound
};

function setLocalSymbol (new_symbol) {
if (!new_symbol) {
return;
}

if (symbol === symbol_local) {
symbol_local = new_symbol;
symbol = symbol_local;
} else {
symbol_local = new_symbol;
}
}

function getLocalSymbol () {
return symbol_local;
}

function setBTCSymbol (new_symbol) {
if (!new_symbol) {
return;
}

if (symbol === symbol_btc) {
symbol_btc = new_symbol;
symbol = symbol_btc;
} else {
symbol_btc = new_symbol;
}
}

function getBTCSymbol () {
return symbol_btc;
}
// used iOS
var _sounds = {};
function playSound (id) {
Expand Down
9 changes: 0 additions & 9 deletions tests/helpers_spec.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,3 @@ describe "Helpers", ->

it "should not verify invalid messages", ->
expect(Helpers.verifyMessage("12cbQLTFMXRnSzktFkuoG3eHoMeFtpTu3S", "IH+xpXCKouEcd0E8Hv3NkrYWbhq0P7pAQpI1GcQ2hF2AAsqL2o4agDE8V81i071/bTMz00YKw2YRMoyFMzThZwM=", "Wright, it is not the same as if I sign Craig Wright, Satoshi.")).toBeFalsy()


describe "precisionToSatoshiBN", ->

it "should parse valid strings with fractional values", ->
expect(Helpers.precisionToSatoshiBN("21.0349756").intValue()).toEqual(new BigInteger("2103497560").intValue())

it "should parse valid strings with fractional values", ->
expect(Helpers.precisionToSatoshiBN("1").intValue()).toEqual(new BigInteger("100000000").intValue())

0 comments on commit 78d28c5

Please sign in to comment.