Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/LICENSE b/LICENSE
- index f236bf6..0c7c545 100644
- --- a/LICENSE
- +++ b/LICENSE
- @@ -1,6 +1,6 @@
- -The MIT License (MIT)
- +MIT License
- -Copyright (c) 2016 Byteball developers
- +Copyright (c) 2018 TravelFlex
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- @@ -9,14 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- -The above copyright notice and this permission notice shall be included in
- -all copies or substantial portions of the Software.
- +The above copyright notice and this permission notice shall be included in all
- +copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- -THE SOFTWARE.
- -
- +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- +SOFTWARE.
- diff --git a/README.md b/README.md
- index a91191e..5961930 100644
- --- a/README.md
- +++ b/README.md
- @@ -1,109 +1 @@
- -# Byteball core
- -
- -This is a library used in [Byteball](https://byteball.org) clients. Never used directly. Some of the clients that require the library:
- -
- -* [Byteball](../../../byteball) - GUI wallet for Mac, Windows, Linux, iOS, and Android.
- -* [Headless Byteball](../../../headless-byteball) - headless wallet, primarily for server side use.
- -* [Byteball Relay](../../../byteball-relay) - relay node for Byteball network. It doesn't hold any private keys.
- -* [Byteball Hub](../../../byteball-hub) - hub for Byteball network. Includes the relay, plus can store and forward end-to-end encrypted messages among devices on the Byteball network.
- -
- -## Developer guides
- -
- -See the [wiki](https://github.com/byteball/byteballcore/wiki/Byteball-Developer-Guides). Many of the features are not documented yet, see other [byteball repositories](https://github.com/byteball) as samples, for APIs see the `exports` of node.js modules.
- -
- -## Configuring
- -
- -The default settings are in the library's [conf.js](conf.js), they can be overridden in your project root's conf.js (see the clients above as examples), then in conf.json in the app data folder. The app data folder is:
- -
- -* macOS: `~/Library/Application Support/<appname>`
- -* Linux: `~/.config/<appname>`
- -* Windows: `%LOCALAPPDATA%\<appname>`
- -
- -`<appname>` is `name` in your `package.json`.
- -
- -### Settings
- -
- -This is the list of some of the settings that the library understands (your app can add more settings that only your app understands):
- -
- -#### conf.port
- -
- -The port to listen on. If you don't want to accept incoming connections at all, set port to `null`, which is the default. If you do want to listen, you will usually have a proxy, such as nginx, accept websocket connections on standard port 443 and forward them to your byteball daemon that listens on port 6611 on the local interface.
- -
- -#### conf.storage
- -
- -Storage backend -- mysql or sqlite, the default is sqlite. If sqlite, the database files are stored in the app data folder. If mysql, you need to also initialize the database with [byteball.sql](byteball.sql) and set connection params, e.g. in conf.json in the app data folder:
- -
- -```json
- -{
- - "port": 6611,
- - "storage": "mysql",
- - "database": {
- - "max_connections": 30,
- - "host" : "localhost",
- - "user" : "byteball",
- - "password" : "yourmysqlpassword",
- - "name" : "byteball"
- - }
- -}
- -```
- -#### conf.bLight
- -
- -Work as light client (`true`) or full node (`false`). The default is full client.
- -
- -#### conf.bServeAsHub
- -
- -Whether to serve as hub on the Byteball network (store and forward e2e-encrypted messages for devices that connect to your hub). The default is `false`.
- -
- -#### conf.myUrl
- -
- -If your node accepts incoming connections, this is its URL. The node will share this URL with all its outgoing peers so that they can reconnect in any direction in the future. By default the node doesn't share its URL even if it accepts connections.
- -
- -#### conf.bWantNewPeers
- -
- -Whether your node wants to learn about new peers from its current peers (`true`, the default) or not (`false`). Set it to `false` to run your node in stealth mode so that only trusted peers can see its IP address (e.g. if you have online wallets on your server and don't want potential attackers to learn its IP).
- -
- -#### conf.socksHost, conf.socksPort, and conf.socksLocalDNS
- -
- -Settings for connecting through optional SOCKS5 proxy. Use them to connect through TOR and hide your IP address from peers even when making outgoing connections. This is useful and highly recommended when you are running an online wallet on your server and want to make it harder for potential attackers to learn the IP address of the target to attack. Set `socksLocalDNS` to `false` to route DNS queries through TOR as well.
- -
- -#### MySQL conf for faster syncing
- -
- -To lower disk load and increase sync speed, you can optionally disable flushing to disk every transaction, instead doing it once a second. This can be done by setting `innodb_flush_log_at_trx_commit=0` in your MySQL server config file (my.ini)
- -
- -## Accepting incoming connections
- -
- -Byteball network works over secure WebSocket protocol wss://. To accept incoming connections, you'll need a valid TLS certificate (you can get a free one from [letsencrypt.org](https://letsencrypt.org)) and a domain name (you can get a free domain from [Freenom](http://www.freenom.com/)). Then you accept connections on standard port 443 and proxy them to your locally running byteball daemon.
- -
- -This is an example configuration for nginx to accept websocket connections at wss://byteball.one/bb and forward them to locally running daemon that listens on port 6611:
- -
- -```nginx
- -server {
- - listen 80 default_server;
- - listen [::]:80 default_server;
- - listen 443 ssl;
- - listen [::]:443 ssl;
- - ssl_certificate "/etc/letsencrypt/live/byteball.one/fullchain.pem";
- - ssl_certificate_key "/etc/letsencrypt/live/byteball.one/privkey.pem";
- -
- - if ($host != "byteball.one") {
- - rewrite ^(.*)$ https://byteball.one$1 permanent;
- - }
- - if ($https != "on") {
- - rewrite ^(.*)$ https://byteball.one$1 permanent;
- - }
- -
- - location = /bb {
- - proxy_pass http://localhost:6611;
- - proxy_http_version 1.1;
- - proxy_set_header X-Real-IP $remote_addr;
- - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- - proxy_set_header Upgrade $http_upgrade;
- - proxy_set_header Connection "upgrade";
- - }
- -
- - root /var/www/html;
- - server_name _;
- -}
- -```
- -
- -
- +TravelFlex
- diff --git a/byteball-sqlite-light.sql b/byteball-sqlite-light.sql
- index f1c3726..f70daba 100644
- --- a/byteball-sqlite-light.sql
- +++ b/byteball-sqlite-light.sql
- @@ -310,7 +310,6 @@ CREATE INDEX dobyAddressSpent ON outputs(address, is_spent);
- CREATE INDEX outputsIndexByAsset ON outputs(asset);
- CREATE INDEX outputsIsSerial ON outputs(is_serial);
- -
- -- ------------
- -- Commissions
- @@ -723,7 +722,6 @@ CREATE TABLE private_profile_fields (
- );
- CREATE INDEX ppfByField ON private_profile_fields(`field`);
- -
- CREATE TABLE attested_fields (
- unit CHAR(44) NOT NULL,
- message_index TINYINT NOT NULL,
- diff --git a/byteball-sqlite.sql b/byteball-sqlite.sql
- index 64faa58..e832750 100644
- --- a/byteball-sqlite.sql
- +++ b/byteball-sqlite.sql
- @@ -750,7 +750,6 @@ CREATE TABLE attested_fields (
- `field` VARCHAR(50) NOT NULL,
- `value` VARCHAR(100) NOT NULL,
- PRIMARY KEY (unit, message_index, `field`),
- - CONSTRAINT attestationsByAttestorAddress FOREIGN KEY (attestor_address) REFERENCES addresses(address),
- FOREIGN KEY (unit) REFERENCES units(unit)
- );
- CREATE INDEX attestedFieldsByAttestorFieldValue ON attested_fields(attestor_address, `field`, `value`);
- diff --git a/composer.js b/composer.js
- index 298753a..f57a0a9 100644
- --- a/composer.js
- +++ b/composer.js
- @@ -357,10 +357,6 @@ function composeAttestationJoint(from_address, attested_address, profile_data, s
- composeContentJoint(from_address, "attestation", {address: attested_address, profile: profile_data}, signer, callbacks);
- }
- -function composeAssetDefinitionJoint(from_address, asset_definition, signer, callbacks){
- - composeContentJoint(from_address, "asset", asset_definition, signer, callbacks);
- -}
- -
- function composeAssetAttestorsJoint(from_address, asset, arrNewAttestors, signer, callbacks){
- composeContentJoint(from_address, "asset_attestors", {asset: asset, attestors: arrNewAttestors}, signer, callbacks);
- }
- @@ -380,7 +376,7 @@ function composeJoint(params){
- return;
- }
- - if (conf.bLight && !params.lightProps){
- + /*if (conf.bLight && !params.lightProps){
- var network = require('./network.js');
- network.requestFromLightVendor(
- 'light/get_parents_and_last_ball_and_witness_list_unit',
- @@ -395,7 +391,7 @@ function composeJoint(params){
- }
- );
- return;
- - }
- + }*/
- // try to use as few paying_addresses as possible. Assuming paying_addresses are sorted such that the most well-funded addresses come first
- if (params.minimal && !params.send_all){
- @@ -429,12 +425,12 @@ function composeJoint(params){
- var arrMessages = _.clone(params.messages || []);
- var assocPrivatePayloads = params.private_payloads || {}; // those that correspond to a subset of params.messages
- var fnRetrieveMessages = params.retrieveMessages;
- - var lightProps = params.lightProps;
- + //var lightProps = params.lightProps;
- var signer = params.signer;
- var callbacks = params.callbacks;
- - if (conf.bLight && !lightProps)
- - throw Error("no parent props for light");
- + //if (conf.bLight && !lightProps)
- + // throw Error("no parent props for light");
- //profiler.start();
- @@ -488,6 +484,7 @@ function composeJoint(params){
- var assocSigningPaths = {};
- var unlock_callback;
- var conn;
- + var lightProps;
- var handleError = function(err){
- //profiler.stop('compose');
- @@ -507,6 +504,23 @@ function composeJoint(params){
- cb();
- });
- },
- + function(cb){ // lightProps
- + if (!conf.bLight)
- + return cb();
- + var network = require('./network.js');
- + network.requestFromLightVendor(
- + 'light/get_parents_and_last_ball_and_witness_list_unit',
- + {witnesses: arrWitnesses},
- + function(ws, request, response){
- + if (response.error)
- + return handleError(response.error); // cb is not called
- + if (!response.parent_units || !response.last_stable_mc_ball || !response.last_stable_mc_ball_unit || typeof response.last_stable_mc_ball_mci !== 'number')
- + return handleError("invalid parents from light vendor"); // cb is not called
- + lightProps = response;
- + cb();
- + }
- + );
- + },
- function(cb){ // start transaction
- db.takeConnectionFromPool(function(new_conn){
- conn = new_conn;
- @@ -947,7 +961,6 @@ exports.composePollJoint = composePollJoint;
- exports.composeVoteJoint = composeVoteJoint;
- exports.composeProfileJoint = composeProfileJoint;
- exports.composeAttestationJoint = composeAttestationJoint;
- -exports.composeAssetDefinitionJoint = composeAssetDefinitionJoint;
- exports.composeAssetAttestorsJoint = composeAssetAttestorsJoint;
- exports.composeJoint = composeJoint;
- diff --git a/constants.js b/constants.js
- index 878dfb8..225af59 100644
- --- a/constants.js
- +++ b/constants.js
- @@ -1,17 +1,16 @@
- /*jslint node: true */
- "use strict";
- -exports.COUNT_WITNESSES = 12;
- +exports.COUNT_WITNESSES = 7;
- exports.MAX_WITNESS_LIST_MUTATIONS = 1;
- -exports.TOTAL_WHITEBYTES = 1e15;
- +exports.TOTAL_WHITEBYTES = 1315e11;
- exports.MAJORITY_OF_WITNESSES = (exports.COUNT_WITNESSES%2===0) ? (exports.COUNT_WITNESSES/2+1) : Math.ceil(exports.COUNT_WITNESSES/2);
- exports.COUNT_MC_BALLS_FOR_PAID_WITNESSING = 100;
- exports.version = '1.0';
- exports.alt = '1';
- -exports.GENESIS_UNIT = (exports.alt === '2' && exports.version === '1.0t') ? 'TvqutGPz3T4Cs6oiChxFlclY92M2MvCvfXR5/FETato=' : 'oj8yEksX9Ubq7lLc+p6F2uyHUuynugeVq4+ikT67X6E=';
- -exports.BLACKBYTES_ASSET = (exports.alt === '2' && exports.version === '1.0t') ? 'LUQu5ik4WLfCrr8OwXezqBa+i3IlZLqxj2itQZQm8WY=' : 'qO2JsiuDMh/j+pqJYZw3u82O71WjCDf0vTNvsnntr8o=';
- +exports.GENESIS_UNIT = 'q0vnHPuI3Sd3lkTyX8Jv7qOARayGN9weHW0uj5mlSBA=';
- exports.HASH_LENGTH = 44;
- exports.PUBKEY_LENGTH = 44;
- @@ -30,14 +29,8 @@ exports.MAX_ATTESTORS_PER_ASSET = 64;
- exports.MAX_DATA_FEED_NAME_LENGTH = 64;
- exports.MAX_DATA_FEED_VALUE_LENGTH = 64;
- exports.MAX_AUTHENTIFIER_LENGTH = 4096;
- -exports.MAX_CAP = 9e15;
- +exports.MAX_CAP = 1315e11;
- exports.MAX_COMPLEXITY = 100;
- exports.MAX_PROFILE_FIELD_LENGTH = 50;
- exports.MAX_PROFILE_VALUE_LENGTH = 100;
- -
- -exports.TEXTCOIN_CLAIM_FEE = 548;
- -exports.TEXTCOIN_ASSET_CLAIM_FEE = 750;
- -exports.TEXTCOIN_ASSET_CLAIM_HEADER_FEE = 391;
- -exports.TEXTCOIN_ASSET_CLAIM_MESSAGE_FEE = 209;
- -exports.TEXTCOIN_ASSET_CLAIM_BASE_MSG_FEE = 158;
- \ No newline at end of file
- diff --git a/device.js b/device.js
- index 44487ee..89e0030 100644
- --- a/device.js
- +++ b/device.js
- @@ -159,10 +159,14 @@ function loginToHub(){
- setInterval(loginToHub, RECONNECT_TO_HUB_PERIOD);
- eventBus.on('connected', loginToHub);
- +function loginMessage(challenge, priv, pubkey) {
- + var objLogin = {challenge: challenge, pubkey: pubkey};
- + objLogin.signature = ecdsaSig.sign(objectHash.getDeviceMessageHashToSign(objLogin), priv);
- + return objLogin;
- +}
- +
- function sendLoginCommand(ws, challenge){
- - var objLogin = {challenge: challenge, pubkey: objMyPermanentDeviceKey.pub_b64};
- - objLogin.signature = ecdsaSig.sign(objectHash.getDeviceMessageHashToSign(objLogin), objMyPermanentDeviceKey.priv);
- - network.sendJustsaying(ws, 'hub/login', objLogin);
- + network.sendJustsaying(ws, 'hub/login', loginMessage(challenge, objMyPermanentDeviceKey.priv, objMyPermanentDeviceKey.pub_b64));
- ws.bLoggedIn = true;
- sendTempPubkey(ws, objMyTempDeviceKey.pub_b64);
- network.initWitnessesIfNecessary(ws);
- @@ -734,6 +738,7 @@ function requestFromHub(command, params, responseHandler){
- exports.getMyDevicePubKey = getMyDevicePubKey;
- exports.getMyDeviceAddress = getMyDeviceAddress;
- exports.isValidPubKey = isValidPubKey;
- +exports.loginMessage = loginMessage;
- exports.genPrivKey = genPrivKey;
- diff --git a/initial.byteball-light.sqlite b/initial.byteball-light.sqlite
- index 1ace473..9a953db 100644
- Binary files a/initial.byteball-light.sqlite and b/initial.byteball-light.sqlite differ
- diff --git a/light.js b/light.js
- index 2e730cd..672f1b6 100644
- --- a/light.js
- +++ b/light.js
- @@ -302,9 +302,11 @@ function processHistory(objResponse, callbacks){
- return callbacks.ifError("wrong ball hash: unit "+objBall.unit+", ball "+objBall.ball);
- if (!assocKnownBalls[objBall.ball])
- return callbacks.ifError("ball not known: "+objBall.ball);
- + if (objBall.parent_balls != null) {
- objBall.parent_balls.forEach(function (parent_ball) {
- assocKnownBalls[parent_ball] = true;
- });
- + }
- if (objBall.skiplist_balls)
- objBall.skiplist_balls.forEach(function(skiplist_ball){
- assocKnownBalls[skiplist_ball] = true;
- diff --git a/mysql_pool.js b/mysql_pool.js
- index 276f9f5..ce545c9 100644
- --- a/mysql_pool.js
- +++ b/mysql_pool.js
- @@ -8,7 +8,6 @@ module.exports = function(connection_or_pool){
- var safe_connection = connection_or_pool;
- safe_connection.original_query = safe_connection.query;
- safe_connection.original_release = safe_connection.release;
- - safe_connection.original_escape = safe_connection.escape;
- // this is a hack to make all errors throw exception that would kill the program
- safe_connection.query = function () {
- @@ -49,9 +48,7 @@ module.exports = function(connection_or_pool){
- return q;
- };
- - safe_connection.escape = function(str){
- - return connection_or_pool.original_escape(str);
- - };
- + //safe_connection.escape = connection_or_pool.escape;
- safe_connection.release = function(){
- //console.log("releasing connection");
- diff --git a/network.js b/network.js
- index 627752d..5d61654 100644
- --- a/network.js
- +++ b/network.js
- @@ -1356,6 +1356,8 @@ function flushEvents(forceFlushing) {
- }
- function writeEvent(event, host){
- + if (conf.bLight)
- + return;
- if (event === 'invalid' || event === 'nonserial'){
- var column = "count_"+event+"_joints";
- db.query("UPDATE peer_hosts SET "+column+"="+column+"+1 WHERE peer_host=?", [host]);
- @@ -1367,6 +1369,7 @@ function writeEvent(event, host){
- flushEvents();
- }
- +if (!conf.bLight)
- setInterval(function(){flushEvents(true)}, 1000 * 60);
- @@ -1937,7 +1940,7 @@ function handleJustsaying(ws, subject, body){
- return;
- }
- ws.library_version = body.library_version;
- - if (typeof ws.library_version === 'string' && version2int(ws.library_version) < version2int('0.2.70') && constants.version === '1.0')
- + if (typeof ws.library_version === 'string' && version2int(ws.library_version) < version2int('0.1.0') && constants.version === '1.0')
- ws.old_core = true;
- eventBus.emit('peer_version', ws, body); // handled elsewhere
- break;
- diff --git a/package.json b/package.json
- index f1b0c14..1a59fe5 100644
- --- a/package.json
- +++ b/package.json
- @@ -1,20 +1,20 @@
- {
- - "name": "byteballcore",
- - "description": "Byteball Core",
- - "author": "Byteball",
- - "version": "0.2.88",
- + "name": "core",
- + "description": "TravelFlexCore Core",
- + "author": "TravelFlexCore",
- + "version": "0.1.0",
- "keywords": [
- - "byteball",
- + "TravelFlex",
- "multisignature"
- ],
- - "homepage": "https://github.com/byteball/byteballcore",
- + "homepage": "https://github.com/TravelFlex/TravelFlexCore",
- "license": "MIT",
- "repository": {
- - "url": "git://github.com/byteball/byteballcore.git",
- + "url": "git://github.com/TravelFlex/TravelFlexCore.git",
- "type": "git"
- },
- "bugs": {
- - "url": "https://github.com/byteball/byteballcore/issues"
- + "url": "https://github.com/TravelFlex/TravelFlexCore/issues"
- },
- "browser": {
- "request": "browser-request",
- @@ -34,10 +34,11 @@
- "ws": "^1.0.1"
- },
- "scripts": {
- - "test": "yarn ava"
- + "test": "ava"
- },
- "devDependencies": {
- - "ava": "^0.22.0",
- + "ava": "^1.0.0-beta.1",
- + "ava-config": "^1.1.0",
- "testcheck": "^1.0.0-rc.2"
- }
- }
- diff --git a/storage.js b/storage.js
- index e88762e..b265bb6 100644
- --- a/storage.js
- +++ b/storage.js
- @@ -71,7 +71,7 @@ function readJointDirectly(conn, unit, callbacks, bRetrying) {
- var bVoided = (objUnit.content_hash && main_chain_index < min_retrievable_mci);
- var bRetrievable = (main_chain_index >= min_retrievable_mci || main_chain_index === null);
- - if (!conf.bLight && !objUnit.last_ball)
- + if (!conf.bLight && !objUnit.last_ball && !isGenesisUnit(unit))
- throw Error("no last ball in unit "+JSON.stringify(objUnit));
- // unit hash verification below will fail if:
- diff --git a/test/string_utils.test.js b/test/string_utils.test.js
- index bba9001..ca47e87 100644
- --- a/test/string_utils.test.js
- +++ b/test/string_utils.test.js
- @@ -13,24 +13,35 @@ const simpleString = 'simple test string';
- const simpleStringResult = ['s', simpleString].join(STRING_JOIN_CHAR);
- test('Test a simple string', t => {
- t.true(getSourceString(simpleString) === simpleStringResult);
- + t.true(20 === getSourceString(simpleString).length);
- });
- const integer = 27090;
- const simpleIntResult = ['n', integer].join(STRING_JOIN_CHAR);
- test('Test an integer', t => {
- t.true(getSourceString(integer) === simpleIntResult);
- + t.true(7 === getSourceString(integer).length);
- });
- const float = 8.103;
- const simpleFloatResult = ['n', float].join(STRING_JOIN_CHAR);
- test('Test a float', t => {
- t.true(getSourceString(float) === simpleFloatResult);
- + t.true(7 === getSourceString(float).length);
- +});
- +
- +const floatInt = 1.0;
- +const simpleFloatIntResult = ['n', floatInt].join(STRING_JOIN_CHAR);
- +test('Test a float int, 1.0 => n1', t => {
- + t.true(getSourceString(floatInt) === simpleFloatIntResult);
- + t.true(3 === getSourceString(floatInt).length);
- });
- const boolean = false;
- const simpleBooleanResult = ['b', boolean].join(STRING_JOIN_CHAR);
- test('Test a boolean', t => {
- t.true(getSourceString(boolean) === simpleBooleanResult);
- + t.true(7 === getSourceString(boolean).length);
- });
- const arrayInput = ['a', 81, 'b', 'c', 3.6903690369, true];
- @@ -40,6 +51,7 @@ const arrayInputResultPairs = ['s', 'n', 's', 's', 'n', 'b'].map(function(typ, i
- const arrayInputResult = ['[', arrayInputResultPairs, ']'].join(STRING_JOIN_CHAR);
- test('Test an array', t => {
- t.true(getSourceString(arrayInput) === arrayInputResult);
- + t.true(42 === getSourceString(arrayInput).length);
- });
- // Just hard-coding this...
- @@ -48,6 +60,5 @@ const objectPairs = ['bunch', getSourceString(9), 'unit', getSourceString('clust
- const objectResult = objectPairs.join(STRING_JOIN_CHAR);
- test('Test an object', t => {
- t.true(getSourceString(object) === objectResult);
- + t.true(54 === getSourceString(object).length);
- });
- \ No newline at end of file
- -
- -
- diff --git a/wallet.js b/wallet.js
- index d99040d..c508399 100644
- --- a/wallet.js
- +++ b/wallet.js
- @@ -122,12 +122,14 @@ eventBus.on("message_from_hub", handleJustsaying);
- eventBus.on("message_for_light", handleJustsaying);
- -
- -
- -
- // called from UI after user confirms signing request initiated from another device, initiator device being the recipient of this message
- function sendSignature(device_address, signed_text, signature, signing_path, address) {
- - device.sendMessageToDevice(device_address, "signature", {signed_text: signed_text, signature: signature, signing_path: signing_path, address: address});
- + device.sendMessageToDevice(device_address, "signature", {
- + signed_text: signed_text,
- + signature: signature,
- + signing_path: signing_path,
- + address: address
- + });
- }
- // one of callbacks MUST be called, otherwise the mutex will stay locked
- @@ -310,7 +312,9 @@ function handleMessageFromHub(ws, json, device_pubkey, bIndirectCorrespondent, c
- return callbacks.ifError("private payload hash does not match");
- if (!ValidationUtils.isNonemptyArray(objUnit.messages))
- return callbacks.ifError("no messages in unsigned unit");
- - if (objUnit.messages.filter(function(objMessage){ return (objMessage.payload_hash === payload_hash); }).length !== 1)
- + if (objUnit.messages.filter(function (objMessage) {
- + return (objMessage.payload_hash === payload_hash);
- + }).length !== 1)
- return callbacks.ifError("no such payload hash in the messages");
- }
- }
- @@ -362,7 +366,11 @@ function handleMessageFromHub(ws, json, device_pubkey, bIndirectCorrespondent, c
- callbacks.ifError("not aware of address " + body.address + " but will see if I learn about it later");
- eventBus.once("new_address-" + body.address, function () {
- // rewrite callbacks to avoid duplicate unlocking of mutex
- - handleMessageFromHub(ws, json, device_pubkey, bIndirectCorrespondent, { ifOk: function(){}, ifError: function(){} });
- + handleMessageFromHub(ws, json, device_pubkey, bIndirectCorrespondent, {
- + ifOk: function () {
- + }, ifError: function () {
- + }
- + });
- });
- }
- });
- @@ -410,9 +418,13 @@ function handleMessageFromHub(ws, json, device_pubkey, bIndirectCorrespondent, c
- if (!body.forwarded) {
- emitNewPrivatePaymentReceived(from_address, arrChains, current_message_counter);
- // note, this forwarding won't work if the user closes the wallet before validation of the private chains
- - var arrUnits = arrChains.map(function(arrPrivateElements){ return arrPrivateElements[0].unit; });
- + var arrUnits = arrChains.map(function (arrPrivateElements) {
- + return arrPrivateElements[0].unit;
- + });
- db.query("SELECT address FROM unit_authors WHERE unit IN(?)", [arrUnits], function (rows) {
- - var arrAuthorAddresses = rows.map(function(row){ return row.address; });
- + var arrAuthorAddresses = rows.map(function (row) {
- + return row.address;
- + });
- // if the addresses are not shared, it doesn't forward anything
- forwardPrivateChainsToOtherMembersOfSharedAddresses(arrChains, arrAuthorAddresses, from_address, true);
- });
- @@ -527,7 +539,8 @@ function forwardPrivateChainsToOtherMembersOfOutputAddresses(arrChains, conn, on
- console.log("output addresses", arrOutputAddresses);
- conn = conn || db;
- if (!onSaved)
- - onSaved = function(){};
- + onSaved = function () {
- + };
- readWalletsByAddresses(conn, arrOutputAddresses, function (arrWallets) {
- if (arrWallets.length === 0) {
- // breadcrumbs.add("forwardPrivateChainsToOtherMembersOfOutputAddresses: " + JSON.stringify(arrChains)); // remove in livenet
- @@ -548,11 +561,15 @@ function forwardPrivateChainsToOtherMembersOfOutputAddresses(arrChains, conn, on
- function readWalletsByAddresses(conn, arrAddresses, handleWallets) {
- conn.query("SELECT DISTINCT wallet FROM my_addresses WHERE address IN(?)", [arrAddresses], function (rows) {
- - var arrWallets = rows.map(function(row){ return row.wallet; });
- + var arrWallets = rows.map(function (row) {
- + return row.wallet;
- + });
- conn.query("SELECT DISTINCT address FROM shared_address_signing_paths WHERE shared_address IN(?)", [arrAddresses], function (rows) {
- if (rows.length === 0)
- return handleWallets(arrWallets);
- - var arrNewAddresses = rows.map(function(row){ return row.address; });
- + var arrNewAddresses = rows.map(function (row) {
- + return row.address;
- + });
- readWalletsByAddresses(conn, arrNewAddresses, function (arrNewWallets) {
- handleWallets(_.union(arrWallets, arrNewWallets));
- });
- @@ -688,10 +705,14 @@ function findAddress(address, signing_path, callbacks, fallback_remote_device_ad
- function readSharedBalance(wallet, handleBalance) {
- balances.readSharedBalance(wallet, function (assocBalances) {
- if (conf.bLight) { // make sure we have all asset definitions available
- - var arrAssets = Object.keys(assocBalances).filter(function(asset){ return (asset !== 'base'); });
- + var arrAssets = Object.keys(assocBalances).filter(function (asset) {
- + return (asset !== 'base');
- + });
- if (arrAssets.length === 0)
- return handleBalance(assocBalances);
- - network.requestProofsOfJointsIfNewOrUnstable(arrAssets, function(){handleBalance(assocBalances)});
- + network.requestProofsOfJointsIfNewOrUnstable(arrAssets, function () {
- + handleBalance(assocBalances)
- + });
- } else {
- handleBalance(assocBalances);
- }
- @@ -701,10 +722,14 @@ function readSharedBalance(wallet, handleBalance){
- function readBalance(wallet, handleBalance) {
- balances.readBalance(wallet, function (assocBalances) {
- if (conf.bLight) { // make sure we have all asset definitions available
- - var arrAssets = Object.keys(assocBalances).filter(function(asset){ return (asset !== 'base'); });
- + var arrAssets = Object.keys(assocBalances).filter(function (asset) {
- + return (asset !== 'base');
- + });
- if (arrAssets.length === 0)
- return handleBalance(assocBalances);
- - network.requestProofsOfJointsIfNewOrUnstable(arrAssets, function(){handleBalance(assocBalances)});
- + network.requestProofsOfJointsIfNewOrUnstable(arrAssets, function () {
- + handleBalance(assocBalances)
- + });
- } else {
- handleBalance(assocBalances);
- }
- @@ -740,7 +765,8 @@ function readAssetMetadata(arrAssets, handleMetadata){
- // after calling the callback, try to fetch missing data about assets
- if (!arrAssets)
- return;
- - network.requestProofsOfJointsIfNewOrUnstable(arrAssets, function(){ // make sure we have assets itself
- + var updateAssets = conf.bLight ? network.requestProofsOfJointsIfNewOrUnstable : function(arrAssets, onDone){ onDone(); };
- + updateAssets(arrAssets, function(){ // make sure we have assets itself
- arrAssets.forEach(function (asset) {
- if (assocAssetMetadata[asset] || asset === 'base' && asset === constants.BLACKBYTES_ASSET)
- return;
- @@ -861,7 +887,14 @@ function readTransactionHistory(opts, handleHistory){
- // row.fee = null;
- if (!assocMovements[row.unit])
- assocMovements[row.unit] = {
- - plus:0, has_minus:false, ts: row.ts, level: row.level, is_stable: row.is_stable, sequence: row.sequence, fee: row.fee, mci: row.mci
- + plus: 0,
- + has_minus: false,
- + ts: row.ts,
- + level: row.level,
- + is_stable: row.is_stable,
- + sequence: row.sequence,
- + fee: row.fee,
- + mci: row.mci
- };
- if (row.to_address) {
- assocMovements[row.unit].plus += row.amount;
- @@ -897,7 +930,9 @@ function readTransactionHistory(opts, handleHistory){
- "SELECT DISTINCT address FROM inputs WHERE unit=? AND " + asset_condition + " ORDER BY address",
- [unit],
- function (address_rows) {
- - var arrPayerAddresses = address_rows.map(function(address_row){ return address_row.address; });
- + var arrPayerAddresses = address_rows.map(function (address_row) {
- + return address_row.address;
- + });
- movement.arrMyRecipients.forEach(function (objRecipient) {
- var transaction = {
- action: 'received',
- @@ -933,12 +968,16 @@ function readTransactionHistory(opts, handleHistory){
- parameters = [wallet, unit];
- db.query(queryString, parameters,
- function (payee_rows) {
- - var action = payee_rows.some(function(payee){ return payee.is_external; }) ? 'sent' : 'moved';
- + var action = payee_rows.some(function (payee) {
- + return payee.is_external;
- + }) ? 'sent' : 'moved';
- if (payee_rows.length == 0) {
- cb();
- return;
- }
- - var has_asset = payee_rows.some(function(payee){ return payee.asset; });
- + var has_asset = payee_rows.some(function (payee) {
- + return payee.asset;
- + });
- if (has_asset && !asset) { // filter out "fees" txs from history
- cb();
- return;
- @@ -1009,7 +1048,9 @@ function readTransactionHistory(opts, handleHistory){
- return -1;
- return 0;
- });
- - arrTransactions.forEach(function(transaction){ transaction.asset = opts.asset; });
- + arrTransactions.forEach(function (transaction) {
- + transaction.asset = opts.asset;
- + });
- handleHistory(arrTransactions);
- }
- );
- @@ -1097,7 +1138,7 @@ function readFundedAddresses(asset, wallet, estimated_amount, handleFundedAddres
- SELECT * FROM unit_authors JOIN units USING(unit) \n\
- WHERE is_stable=0 AND unit_authors.address=outputs.address AND definition_chash IS NOT NULL \n\
- ) \n\
- - GROUP BY address ORDER BY "+order_by,
- + GROUP BY address ORDER BY " + order_by + " LIMIT "+constants.MAX_AUTHORS_PER_UNIT,
- asset ? [wallet, asset] : [wallet],
- function (rows) {
- determineIfFixedDenominations(asset, function (bFixedDenominations) {
- @@ -1147,7 +1188,9 @@ function readAdditionalSigningAddresses(arrPayingAddresses, arrSigningAddresses,
- sql,
- arrParams,
- function (rows) {
- - var arrAdditionalAddresses = rows.map(function(row){ return row.address; });
- + var arrAdditionalAddresses = rows.map(function (row) {
- + return row.address;
- + });
- if (arrAdditionalAddresses.length === 0)
- return handleAdditionalSigningAddresses([]);
- readAdditionalSigningAddresses([], arrSigningAddresses.concat(arrAdditionalAddresses), arrSigningDeviceAddresses, function (arrMoreAddresses) {
- @@ -1160,9 +1203,7 @@ function readAdditionalSigningAddresses(arrPayingAddresses, arrSigningAddresses,
- var TYPICAL_FEE = 1000;
- // fee_paying_wallet is used only if there are no bytes on the asset wallet, it is a sort of fallback wallet for fees
- -function readFundedAndSigningAddresses(
- - asset, wallet, estimated_amount, fee_paying_wallet, arrSigningAddresses, arrSigningDeviceAddresses, handleFundedAndSigningAddresses)
- -{
- +function readFundedAndSigningAddresses(asset, wallet, estimated_amount, fee_paying_wallet, arrSigningAddresses, arrSigningDeviceAddresses, handleFundedAndSigningAddresses) {
- readFundedAddresses(asset, wallet, estimated_amount, function (arrFundedAddresses) {
- if (arrFundedAddresses.length === 0)
- return handleFundedAndSigningAddresses([], [], []);
- @@ -1189,9 +1230,7 @@ function readFundedAndSigningAddresses(
- });
- }
- -function sendPaymentFromWallet(
- - asset, wallet, to_address, amount, change_address, arrSigningDeviceAddresses, recipient_device_address, signWithLocalPrivateKey, handleResult)
- -{
- +function sendPaymentFromWallet(asset, wallet, to_address, amount, change_address, arrSigningDeviceAddresses, recipient_device_address, signWithLocalPrivateKey, handleResult) {
- sendMultiPayment({
- asset: asset,
- wallet: wallet,
- @@ -1204,8 +1243,7 @@ function sendPaymentFromWallet(
- }, handleResult);
- }
- -function sendMultiPayment(opts, handleResult)
- -{
- +function sendMultiPayment(opts, handleResult) {
- var asset = opts.asset;
- if (asset === 'base')
- asset = null;
- @@ -1246,7 +1284,9 @@ function sendMultiPayment(opts, handleResult)
- var estimated_amount = amount;
- if (!estimated_amount && asset_outputs)
- - estimated_amount = asset_outputs.reduce(function(acc, output){ return acc+output.amount; }, 0);
- + estimated_amount = asset_outputs.reduce(function (acc, output) {
- + return acc + output.amount;
- + }, 0);
- if (estimated_amount && !asset)
- estimated_amount += TYPICAL_FEE;
- @@ -1332,6 +1372,7 @@ function sendMultiPayment(opts, handleResult)
- var assocPaymentsByEmail = {}; // wallet mnemonics to send by emails
- var assocAddresses = {};
- var prefix = "textcoin:";
- +
- function generateNewMnemonicIfNoAddress(output_asset, outputs) {
- var generated = 0;
- outputs.forEach(function (output) {
- @@ -1357,6 +1398,7 @@ function sendMultiPayment(opts, handleResult)
- });
- return generated;
- }
- +
- if (to_address) {
- var to_address_output = {address: to_address, amount: amount};
- var cnt = generateNewMnemonicIfNoAddress(asset, [to_address_output]);
- @@ -1422,7 +1464,9 @@ function sendMultiPayment(opts, handleResult)
- var _addAssetFees = function () {
- var asset_fees = objAsset && objAsset.fixed_denominations ? indivisibleAssetFeesByAddress[new_address] : constants.TEXTCOIN_ASSET_CLAIM_FEE;
- if (!params.base_outputs) params.base_outputs = [];
- - var base_output = _.find(params.base_outputs, function(output) {return output.address == new_address});
- + var base_output = _.find(params.base_outputs, function (output) {
- + return output.address == new_address
- + });
- if (base_output)
- base_output.amount += asset_fees;
- else
- @@ -1430,19 +1474,25 @@ function sendMultiPayment(opts, handleResult)
- }
- // first calculate fees for textcoins in (bytes) outputs
- - var output = _.find(params.outputs, function(output) {return output.address == new_address});
- + var output = _.find(params.outputs, function (output) {
- + return output.address == new_address
- + });
- if (output) {
- output.amount += constants.TEXTCOIN_CLAIM_FEE;
- }
- // second calculate fees for textcoins in base_outputs
- - output = _.find(params.base_outputs, function(output) {return output.address == new_address});
- + output = _.find(params.base_outputs, function (output) {
- + return output.address == new_address
- + });
- if (output) {
- output.amount += constants.TEXTCOIN_CLAIM_FEE;
- }
- // then check for textcoins in asset_outputs
- - output = _.find(params.asset_outputs, function(output) {return output.address == new_address});
- + output = _.find(params.asset_outputs, function (output) {
- + return output.address == new_address
- + });
- if (output) {
- _addAssetFees();
- }
- @@ -1594,7 +1644,12 @@ function sendTextcoinEmail(email, subject, amount, asset, mnemonic){
- amount = (amount / 1e9).toLocaleString([], {maximumFractionDigits: 9});
- asset = 'GB';
- }
- - replaceInTextcoinTemplate({amount: amount, asset: asset, mnemonic: mnemonic, usd_amount_str: usd_amount_str}, function(html, text){
- + replaceInTextcoinTemplate({
- + amount: amount,
- + asset: asset,
- + mnemonic: mnemonic,
- + usd_amount_str: usd_amount_str
- + }, function (html, text) {
- mail.sendmail({
- to: email,
- from: conf.from_email || "noreply@byteball.org",
- @@ -1759,7 +1814,8 @@ function eraseTextcoin(unit, address) {
- "UPDATE sent_mnemonics \n\
- SET mnemonic='' WHERE unit=? AND address=?",
- [unit, address],
- - function(){}
- + function () {
- + }
- );
- }
- @@ -1773,7 +1829,9 @@ function readDeviceAddressesUsedInSigningPaths(onDone){
- sql,
- function (rows) {
- - var arrDeviceAddress = rows.map(function(r) { return r.device_address; });
- + var arrDeviceAddress = rows.map(function (r) {
- + return r.device_address;
- + });
- onDone(arrDeviceAddress);
- }
- @@ -1804,7 +1862,6 @@ walletGeneral.readMyAddresses(function(arrAddresses){
- */
- -
- exports.sendSignature = sendSignature;
- exports.readSharedBalance = readSharedBalance;
- exports.readBalance = readBalance;
- diff --git a/wallet_defined_by_keys.js b/wallet_defined_by_keys.js
- index c522427..370d288 100644
- --- a/wallet_defined_by_keys.js
- +++ b/wallet_defined_by_keys.js
- @@ -40,7 +40,13 @@ function loadBitcoreFromNearestParent(mod){
- }
- function sendOfferToCreateNewWallet(device_address, wallet, arrWalletDefinitionTemplate, walletName, arrOtherCosigners, isSingleAddress, callbacks) {
- - var body = {wallet: wallet, wallet_definition_template: arrWalletDefinitionTemplate, wallet_name: walletName, other_cosigners: arrOtherCosigners, is_single_address: isSingleAddress};
- + var body = {
- + wallet: wallet,
- + wallet_definition_template: arrWalletDefinitionTemplate,
- + wallet_name: walletName,
- + other_cosigners: arrOtherCosigners,
- + is_single_address: isSingleAddress
- + };
- device.sendMessageToDevice(device_address, "create_new_wallet", body, callbacks);
- }
- @@ -63,7 +69,6 @@ function sendNewWalletAddress(device_address, wallet, is_change, address_index,
- }
- -
- // {wallet: "base64", wallet_definition_template: [...]}
- function handleOfferToCreateNewWallet(body, from_address, callbacks) {
- if (!ValidationUtils.isNonemptyString(body.wallet))
- @@ -85,7 +90,9 @@ function handleOfferToCreateNewWallet(body, from_address, callbacks){
- return callbacks.ifError(err);
- if (body.other_cosigners.length !== arrDeviceAddresses.length - 1)
- return callbacks.ifError("wrong length of other_cosigners");
- - var arrOtherDeviceAddresses = _.uniq(body.other_cosigners.map(function(cosigner){ return cosigner.device_address; }));
- + var arrOtherDeviceAddresses = _.uniq(body.other_cosigners.map(function (cosigner) {
- + return cosigner.device_address;
- + }));
- arrOtherDeviceAddresses.push(from_address);
- if (!_.isEqual(arrDeviceAddresses.sort(), arrOtherDeviceAddresses.sort()))
- return callbacks.ifError("wrong other_cosigners");
- @@ -110,7 +117,6 @@ function handleOfferToCreateNewWallet(body, from_address, callbacks){
- }
- -
- function readNextAccount(handleAccount) {
- db.query("SELECT MAX(account) AS max_account FROM wallets", function (rows) {
- var account = (rows.length === 0) ? 0 : (rows[0].max_account + 1);
- @@ -126,7 +132,9 @@ function checkAndFinalizeWallet(wallet, onDone){
- console.log("no wallet in checkAndFinalizeWallet");
- return onDone ? onDone() : null;
- }
- - if (rows.some(function(row){ return !row.member_ready_date; }))
- + if (rows.some(function (row) {
- + return !row.member_ready_date;
- + }))
- return onDone ? onDone() : null;
- db.query("UPDATE wallets SET ready_date=" + db.getNow() + " WHERE wallet=? AND ready_date IS NULL", [wallet], function () {
- if (onDone)
- @@ -140,7 +148,9 @@ function checkAndFullyApproveWallet(wallet, onDone){
- db.query("SELECT approval_date FROM wallets LEFT JOIN extended_pubkeys USING(wallet) WHERE wallets.wallet=?", [wallet], function (rows) {
- if (rows.length === 0) // wallet not created yet
- return onDone ? onDone() : null;
- - if (rows.some(function(row){ return !row.approval_date; }))
- + if (rows.some(function (row) {
- + return !row.approval_date;
- + }))
- return onDone ? onDone() : null;
- db.query("UPDATE wallets SET full_approval_date=" + db.getNow() + " WHERE wallet=? AND full_approval_date IS NULL", [wallet], function () {
- db.query(
- @@ -259,7 +269,9 @@ function createWallet(xPubKey, account, arrWalletDefinitionTemplate, walletName,
- function createMultisigWallet(xPubKey, account, count_required_signatures, arrDeviceAddresses, walletName, isSingleAddress, handleWallet) {
- if (count_required_signatures > arrDeviceAddresses.length)
- throw Error("required > length");
- - var set = arrDeviceAddresses.map(function(device_address){ return ["sig", {pubkey: '$pubkey@'+device_address}]; });
- + var set = arrDeviceAddresses.map(function (device_address) {
- + return ["sig", {pubkey: '$pubkey@' + device_address}];
- + });
- var arrDefinitionTemplate = ["r of set", {required: count_required_signatures, set: set}];
- createWallet(xPubKey, account, arrDefinitionTemplate, walletName, isSingleAddress, handleWallet);
- }
- @@ -309,7 +321,9 @@ function cancelWallet(wallet, arrDeviceAddresses, arrOtherCosigners){
- if (device_address !== device.getMyDeviceAddress())
- sendCommandToCancelNewWallet(device_address, wallet);
- });*/
- - var arrOtherDeviceAddresses = _.uniq(arrOtherCosigners.map(function(cosigner){ return cosigner.device_address; }));
- + var arrOtherDeviceAddresses = _.uniq(arrOtherCosigners.map(function (cosigner) {
- + return cosigner.device_address;
- + }));
- var arrInitiatorDeviceAddresses = _.difference(arrDeviceAddresses, arrOtherDeviceAddresses);
- if (arrInitiatorDeviceAddresses.length !== 1)
- throw Error("not one initiator?");
- @@ -322,7 +336,8 @@ function cancelWallet(wallet, arrDeviceAddresses, arrOtherCosigners){
- device.sendMessageToHub(cosigner.hub, cosigner.pubkey, "cancel_new_wallet", {wallet: wallet});
- });
- db.query("DELETE FROM extended_pubkeys WHERE wallet=?", [wallet], function () {
- - db.query("DELETE FROM wallet_signing_paths WHERE wallet=?", [wallet], function(){});
- + db.query("DELETE FROM wallet_signing_paths WHERE wallet=?", [wallet], function () {
- + });
- });
- }
- @@ -335,7 +350,9 @@ function deleteWallet(wallet, rejector_device_address, onDone){
- if (rows[0].approval_date) // you've already approved this wallet, you can't change your mind
- return onDone();
- db.query("SELECT device_address FROM extended_pubkeys WHERE wallet=?", [wallet], function (rows) {
- - var arrMemberAddresses = rows.map(function(row){ return row.device_address; });
- + var arrMemberAddresses = rows.map(function (row) {
- + return row.device_address;
- + });
- var arrQueries = [];
- db.addQuery(arrQueries, "DELETE FROM extended_pubkeys WHERE wallet=?", [wallet]);
- db.addQuery(arrQueries, "DELETE FROM wallet_signing_paths WHERE wallet=?", [wallet]);
- @@ -475,6 +492,7 @@ function getDeviceAddressesBySigningPaths(arrWalletDefinitionTemplate){
- // all other ops cannot reference device address
- }
- }
- +
- var assocDeviceAddressesBySigningPaths = {};
- evaluate(arrWalletDefinitionTemplate, 'r');
- return assocDeviceAddressesBySigningPaths;
- @@ -508,8 +526,6 @@ function validateWalletDefinitionTemplate(arrWalletDefinitionTemplate, from_addr
- }
- -
- -
- function readNextAddressIndex(wallet, is_change, handleNextAddressIndex) {
- db.query("SELECT MAX(address_index) AS last_used_index FROM my_addresses WHERE wallet=? AND is_change=?", [wallet, is_change], function (rows) {
- var last_used_index = rows[0].last_used_index;
- @@ -597,7 +613,12 @@ function issueAddress(wallet, is_change, address_index, handleNewAddress){
- if (row.device_address !== device.getMyDeviceAddress())
- sendNewWalletAddress(row.device_address, wallet, is_change, address_index, address);
- });
- - handleNewAddress({address: address, is_change: is_change, address_index: address_index, creation_ts: parseInt(Date.now()/1000)});
- + handleNewAddress({
- + address: address,
- + is_change: is_change,
- + address_index: address_index,
- + creation_ts: parseInt(Date.now() / 1000)
- + });
- });
- });
- setTimeout(function () {
- @@ -750,17 +771,14 @@ function readAllAddresses(wallet, handleAddresses){
- "SELECT address FROM my_addresses WHERE wallet=?",
- [wallet],
- function (rows) {
- - handleAddresses(rows.map(function(row){ return row.address; }));
- + handleAddresses(rows.map(function (row) {
- + return row.address;
- + }));
- }
- );
- }
- -
- -
- -
- -
- -
- function forwardPrivateChainsToOtherMembersOfWallets(arrChains, arrWallets, conn, onSaved) {
- console.log("forwardPrivateChainsToOtherMembersOfWallets", arrWallets);
- conn = conn || db;
- @@ -768,7 +786,9 @@ function forwardPrivateChainsToOtherMembersOfWallets(arrChains, arrWallets, conn
- "SELECT device_address FROM extended_pubkeys WHERE wallet IN(?) AND device_address!=?",
- [arrWallets, device.getMyDeviceAddress()],
- function (rows) {
- - var arrDeviceAddresses = rows.map(function(row){ return row.device_address; });
- + var arrDeviceAddresses = rows.map(function (row) {
- + return row.device_address;
- + });
- walletGeneral.forwardPrivateChainsToDevices(arrDeviceAddresses, arrChains, true, conn, onSaved);
- }
- );
- @@ -782,7 +802,9 @@ function readDeviceAddressesControllingPaymentAddresses(conn, arrAddresses, hand
- "SELECT DISTINCT device_address FROM my_addresses JOIN extended_pubkeys USING(wallet) WHERE address IN(?) AND device_address!=?",
- [arrAddresses, device.getMyDeviceAddress()],
- function (rows) {
- - var arrDeviceAddresses = rows.map(function(row){ return row.device_address; });
- + var arrDeviceAddresses = rows.map(function (row) {
- + return row.device_address;
- + });
- handleDeviceAddresses(arrDeviceAddresses);
- }
- );
- @@ -797,7 +819,6 @@ function forwardPrivateChainsToOtherMembersOfAddresses(arrChains, arrAddresses,
- }
- -
- exports.readNextAccount = readNextAccount;
- exports.createWalletByDevices = createWalletByDevices;
- exports.createSinglesigWalletWithExternalPrivateKey = createSinglesigWalletWithExternalPrivateKey;
- diff --git a/writer.js b/writer.js
- index bed1415..3605144 100644
- --- a/writer.js
- +++ b/writer.js
- @@ -292,7 +292,9 @@ function saveJoint(objJoint, objValidationState, preCommitCallback, onDone) {
- determineInputAddress(function (address) {
- var is_unique =
- - objValidationState.arrDoubleSpendInputs.some(function(ds){ return (ds.message_index === i && ds.input_index === j); })
- + objValidationState.arrDoubleSpendInputs.some(function (ds) {
- + return (ds.message_index === i && ds.input_index === j);
- + })
- ? null : 1;
- conn.addQuery(arrQueries, "INSERT INTO inputs \n\
- (unit, message_index, input_index, type, \n\
- @@ -366,7 +368,9 @@ function saveJoint(objJoint, objValidationState, preCommitCallback, onDone) {
- my_best_parent_unit = rows[0].unit;
- if (my_best_parent_unit !== objValidationState.best_parent_unit)
- throwError("different best parents, validation: " + objValidationState.best_parent_unit + ", writer: " + my_best_parent_unit);
- - conn.query("UPDATE units SET best_parent_unit=? WHERE unit=?", [my_best_parent_unit, objUnit.unit], function(){ cb(); });
- + conn.query("UPDATE units SET best_parent_unit=? WHERE unit=?", [my_best_parent_unit, objUnit.unit], function () {
- + cb();
- + });
- }
- );
- }
Add Comment
Please, Sign In to add comment