Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/bitcore-wallet-service/bws.example.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ module.exports = {
// https: true,
// privateKeyFile: 'private.pem',
// certificateFile: 'cert.pem',
////// The following is only for certs which are not
////// trusted by nodejs 'https' by default
////// CAs like Verisign do not require this
// //// The following is only for certs which are not
// //// trusted by nodejs 'https' by default
// //// CAs like Verisign do not require this
// CAinter1: '', // ex. 'COMODORSADomainValidationSecureServerCA.crt'
// CAinter2: '', // ex. 'COMODORSAAddTrustCA.crt'
// CAroot: '', // ex. 'AddTrustExternalCARoot.crt'
Expand Down Expand Up @@ -56,7 +56,7 @@ module.exports = {
url: 'https://api.bitcore.io',
regtestEnabled: false
},
testnet3:{
testnet3: {
url: 'https://api.bitcore.io'
},
testnet4: {
Expand Down
5 changes: 3 additions & 2 deletions packages/bitcore-wallet-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
"clean": "rm -rf ./ts_build",
"compile": "npm run clean && npm run build",
"pub": "npm run build && npm publish",
"precommit": "echo 'TODO: npm run fix && npm run lint'",
"precommit": "npm run lint; npm run fix:errors",
"lint": "eslint .",
"fix": "eslint --fix --quiet .",
"fix:errors": "eslint --fix --quiet .",
"fix:all": "eslint --fix .",
"update:stats": "npm run clean && npm run build && chmod +x ./ts_build/updatestats/updatestats.js && ./ts_build/updatestats/updatestats.js",
"clean:fiatrates": "npm run clean && npm run build && chmod +x ./ts_build/cleanfiatrates/cleanfiatrates.js && ./ts_build/cleanfiatrates/cleanfiatrates.js",
"cp:templates": "cp -r ./templates ./ts_build/templates"
Expand Down
20 changes: 10 additions & 10 deletions packages/bitcore-wallet-service/scripts/checkCopayerIds.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env node

const config = require('../../ts_build/src/config').default;
const { Storage } = require('../../ts_build/src').default;
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
const fs = require('fs');
const os = require('os');
const CWC = require('crypto-wallet-core');
import fs from 'fs';
import os from 'os';
import readline from 'readline';
import CWC from 'crypto-wallet-core';
import pkg from '../../ts_build/src';
import config from '../../ts_build/src/config';

const startDate = new Date('2011-01-01T00:00:00.000Z');
const endDate = new Date();
const { Storage } = pkg;
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });

function usage(errMsg) {
console.log('USAGE: ./checkCopayerIds.js [options]');
Expand Down Expand Up @@ -55,7 +55,7 @@ storage.connect(config.storageOpts, async (err) => {
}

function done(err) {
if (err) { console.log(err) }
if (err) { console.log(err); }
rl.close();
storage.disconnect(() => { console.log('done'); });
}
Expand Down Expand Up @@ -99,7 +99,7 @@ storage.connect(config.storageOpts, async (err) => {
const str = chain === 'btc' ? xpub : (chain + xpub);

const hash = CWC.BitcoreLib.crypto.Hash.sha256(Buffer.from(str));
const computed = hash.toString('hex');
const computed = hash.toString('hex');
if (copayerId !== computed) {
mismatches++;
fs.appendFileSync(outFile, `${wallet.id}:${copayerId} -> expected: ${computed}\n`);
Expand Down
8 changes: 4 additions & 4 deletions packages/bitcore-wallet-service/scripts/fixAddressType.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
const config = require('../../ts_build/src/config').default;
const { Storage } = require('../../ts_build/src').default;
const { ObjectId } = require('mongodb');
import { ObjectId } from 'mongodb';
import { Storage } from '../../ts_build/src';
import config from '../../ts_build/src/config';

if (!process.argv[2]) {
console.log('Usage: fixAddressType.js <chain> [--doit]');
Expand Down Expand Up @@ -38,7 +38,7 @@ storage.connect(config.storageOpts, async (err) => {
}

function done(err) {
if (err) { console.log(err) }
if (err) { console.log(err); }
storage.disconnect(() => { console.log('done'); });
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env node
const config = require('../../ts_build/src/config').default;
const { Storage } = require('../../ts_build/src').default;
import pkg from '../../ts_build/src';
import config from '../../ts_build/src/config';

const { Storage } = pkg;

const startDate = new Date('2011-01-01T00:00:00.000Z');
const endDate = new Date();
Expand Down Expand Up @@ -52,7 +54,7 @@ storage.connect(config.storageOpts, async (err) => {
}

function done(err) {
if (err) { console.log(err) }
if (err) { console.log(err); }
storage.disconnect(() => { console.log('done'); });
}

Expand Down Expand Up @@ -100,7 +102,7 @@ storage.connect(config.storageOpts, async (err) => {
if (resWallet?.result?.nModified > 0) {
fixWalletsCount++;
} else if (!resWallet?.result?.ok) {
console.log(JSON.stringify(res));
console.log(JSON.stringify(resWallet));
}

// Update Addresses collection
Expand All @@ -115,7 +117,7 @@ storage.connect(config.storageOpts, async (err) => {
if (resAddress?.result?.nModified > 0) {
fixAddressCount++;
} else if (!resAddress?.result?.ok) {
console.log(JSON.stringify(res));
console.log(JSON.stringify(resAddress));
}

// Update Wallets collection
Expand Down Expand Up @@ -146,7 +148,7 @@ storage.connect(config.storageOpts, async (err) => {
if (resTxs?.result?.nModified > 0) {
fixTxsCount++;
} else if (!resTxs?.result?.ok) {
console.log(JSON.stringify(res));
console.log(JSON.stringify(resTxs));
}
} else {
// Update Wallets collection
Expand Down
26 changes: 9 additions & 17 deletions packages/bitcore-wallet-service/scripts/migrateWalletsNetwork.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/usr/bin/env node

const config = require('../../ts_build/src/config').default;
const { Storage } = require('../../ts_build/src').default;
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
const fs = require('fs');
const os = require('os');
import fs from 'fs';
import os from 'os';
import readline from 'readline';
import config from '../ts_build/src/config';
import { Storage } from '../ts_build/src/lib/storage';

const rl = readline.createInterface({ input: process.stdin, output: process.stdout });

const startDate = new Date('2011-01-01T00:00:00.000Z');
const endDate = new Date();
Expand Down Expand Up @@ -76,7 +78,7 @@ storage.connect(config.storageOpts, async (err) => {
}

function done(err) {
if (err) { console.log(err) }
if (err) { console.log(err); }
rl.close();
storage.disconnect(() => { console.log('done'); });
}
Expand All @@ -89,7 +91,6 @@ storage.connect(config.storageOpts, async (err) => {
let fixAddressCount = 0;
let fixWalletsCount = 0;
let fixTxsCount = 0;
let fixCacheCount = 0;
let count = 0;

console.log(` ${doit ? 'REAL:' : 'DRY RUN:'} Found ${Intl.NumberFormat().format(walletCnt)} total wallets to scan`);
Expand Down Expand Up @@ -159,9 +160,7 @@ storage.connect(config.storageOpts, async (err) => {
const resCache = await storage.db.collection(Storage.collections.CACHE).deleteMany({
walletId: wallet.id
});
if (resCache?.result?.n > 0) {
fixCacheCount++;
} else if (!resCache?.result?.ok) {
if (!resCache?.result?.ok) {
console.log(JSON.stringify(resTxs));
}
} else {
Expand Down Expand Up @@ -190,13 +189,6 @@ storage.connect(config.storageOpts, async (err) => {
});

fixTxsCount += txsCount;

// Delete Cache collection
const cacheCount = await storage.db.collection(Storage.collections.CACHE).countDocuments({
walletId: wallet.id
});

fixCacheCount += cacheCount;
}
}
process.stdout.write('\n');
Expand Down
29 changes: 15 additions & 14 deletions packages/bitcore-wallet-service/scripts/preview-email.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env node

require('ts-node/register');
const config = require('../src/config');
const fs = require('fs');
const path = require('path');
const Mustache = require('mustache');
const os = require('os');
const { exec } = require('child_process');
const sgMail = require('@sendgrid/mail');
const juice = require('juice');
import 'ts-node/register';
import { exec } from 'child_process';
import fs from 'fs';
import os from 'os';
import path from 'path';
import sgMail from '@sendgrid/mail';
import juice from 'juice';
import Mustache from 'mustache';
import config from '../src/config';


const iconMap = {
Expand All @@ -34,7 +34,7 @@ function getIconHtml (templateName) {
const staticUrl = config.baseUrl || 'https://bws.bitpay.com';
const iconUrl = `${staticUrl}/bws/static/images/${iconFile}`;

return `<img src="${iconUrl}" alt="${templateName} icon" style="width: 50px; height: 50px;" />`
return `<img src="${iconUrl}" alt="${templateName} icon" style="width: 50px; height: 50px;" />`;
};

// Parse command line arguments
Expand Down Expand Up @@ -75,7 +75,9 @@ if (!templateName || !TEMPLATE_TYPES.includes(templateName)) {
console.log(' - send: Set to "send" to send an actual email');
console.log(' - recipientEmail: Email address to send to (required if send=true)');
console.log('\nAvailable templates:');
TEMPLATE_TYPES.forEach(type => console.log(`- ${type}`));
for (const type of TEMPLATE_TYPES) {
console.log(`- ${type}`);
}
process.exit(1);
}

Expand Down Expand Up @@ -110,8 +112,7 @@ const createSampleData = (templateName) => {
if (firstLine && firstLine.startsWith('{{subjectPrefix}}')) {
commonData.title = firstLine.replace('{{subjectPrefix}}', '');
}
} catch (err) {
}
} catch { /* ignore error */ }

switch (templateName) {
case 'new_copayer':
Expand Down Expand Up @@ -227,7 +228,7 @@ function createBasicHtmlFromPlain(templateName) {
.slice(2) // Skip the subject line and empty line
.join('\n')
.trim();
} catch (err) {
} catch {
plainContent = `This is a sample email template for ${templateName}`;
}

Expand Down
12 changes: 7 additions & 5 deletions packages/bitcore-wallet-service/scripts/purgeNotifications.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env node

const config = require('../../ts_build/src/config').default;
const { Storage } = require('../../ts_build/src').default;
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
import readline from 'readline';
import { Storage } from '../../ts_build/src';
import config from '../../ts_build/src/config';

const rl = readline.createInterface({ input: process.stdin, output: process.stdout });


let stop = false;
Expand Down Expand Up @@ -58,7 +60,7 @@ storage.connect(config.storageOpts, async (err) => {
}

function done(err) {
if (err) { console.log(err) }
if (err) { console.log(err); }
rl.close();
storage.disconnect(() => { console.log('done'); });
}
Expand Down Expand Up @@ -96,7 +98,7 @@ storage.connect(config.storageOpts, async (err) => {
process.stdout.write('\n');

console.log(`\u2713 Purged ${Intl.NumberFormat().format(count)} notifications`);
stop && console.log('Stopped prematurely by user');
if (stop) console.log('Stopped prematurely by user');

return done();
} catch (err) {
Expand Down
18 changes: 8 additions & 10 deletions packages/bitcore-wallet-service/scripts/v8tool-list.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import _ from 'lodash';
import { BitcoreLib } from 'crypto-wallet-core';
import _ from 'lodash';
import requestStream from 'request';
import { Client } from '../src/lib//blockchainexplorers/v8/client';

Expand All @@ -24,7 +24,7 @@ if (!authKey) throw new Error('provide authKey');
//
const authKeyObj = BitcoreLib.PrivateKey(authKey);

let tmp = authKeyObj.toObject();
const tmp = authKeyObj.toObject();
tmp.compressed = false;
const pubKey = BitcoreLib.PrivateKey(tmp).toPublicKey();

Expand All @@ -41,9 +41,9 @@ const BASE = {
LTC: `https://api.bitcore.io/api/${coin}/${network}`
};

let baseUrl = BASE[coin];
const baseUrl = BASE[coin];

let client = new Client({
const client = new Client({
baseUrl,
authKey: authKeyObj
});
Expand All @@ -59,10 +59,9 @@ if (extra) {

console.log('[v8tool.37:url:]', url);
const signature = client.sign({ method: 'GET', url });
const payload = {};
var acum = '';
let acum = '';

let r = requestStream.get(url, {
const r = requestStream.get(url, {
headers: { 'x-signature': signature },
json: true
});
Expand All @@ -72,9 +71,8 @@ r.on('data', raw => {
});

r.on('end', () => {
let txs = [],
unconf = [],
err;
const txs = [],
unconf = [];
_.each(acum.split(/\r?\n/), rawTx => {
if (!rawTx) return;

Expand Down
8 changes: 4 additions & 4 deletions packages/bitcore-wallet-service/scripts/v8tool.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import request from 'request';
import { BitcoreLib } from 'crypto-wallet-core';
import request from 'request';
import { Client } from '../src/lib//blockchainexplorers/v8/client';

const coin = process.argv[2];
Expand All @@ -24,7 +24,7 @@ if (!authKey) throw new Error('provide authKey');
//
const authKeyObj = BitcoreLib.PrivateKey(authKey);

let tmp = authKeyObj.toObject();
const tmp = authKeyObj.toObject();
tmp.compressed = false;
const pubKey = BitcoreLib.PrivateKey(tmp).toPublicKey();

Expand All @@ -40,10 +40,10 @@ const BASE = {
DOGE: `https://api.bitcore.io/api/${coin}/${network}`,
LTC: `https://api.bitcore.io/api/${coin}/${network}`
};
let baseUrl = BASE[coin];
const baseUrl = BASE[coin];
console.log('[v8tool.ts.37:baseUrl:]', baseUrl); // TODO

let client = new Client({
const client = new Client({
baseUrl,
authKey: authKeyObj
});
Expand Down
6 changes: 3 additions & 3 deletions packages/bitcore-wallet-service/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env node

var spawn = require('child_process').spawn;
var async = require('async');
import { spawn } from 'child_process';
import async from 'async';

var scripts = [
const scripts = [
'locker/locker.js',
'messagebroker/messagebroker.js',
'bcmonitor/bcmonitor.js',
Expand Down
Loading