bwc
This commit is contained in:
parent
04fb7ba032
commit
320de62f13
348 changed files with 7745 additions and 30874 deletions
164
util/build.js
164
util/build.js
|
|
@ -1,164 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var browserify = require('browserify');
|
||||
var exec = require('child_process').exec;
|
||||
var shell = require('shelljs');
|
||||
|
||||
var puts = function(error, stdout, stderr) {
|
||||
if (error) console.log(error);
|
||||
};
|
||||
|
||||
var getCommitHash = function() {
|
||||
//exec git command to get the hash of the current commit
|
||||
//git rev-parse HEAD
|
||||
|
||||
var hash = shell.exec('git rev-parse HEAD', {
|
||||
silent: true
|
||||
}).output.trim().substr(0, 7);
|
||||
return hash;
|
||||
}
|
||||
|
||||
var createVersion = function() {
|
||||
var json = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
||||
var content = 'module.exports.version="' + json.version + '";';
|
||||
|
||||
content = content + '\nmodule.exports.commitHash="' + getCommitHash() + '";';
|
||||
fs.writeFileSync("./version.js", content);
|
||||
};
|
||||
|
||||
var createBundle = function(opts) {
|
||||
opts.dir = opts.dir || 'js/';
|
||||
|
||||
var bopts = {
|
||||
debug: true,
|
||||
standalone: 'copay',
|
||||
insertGlobals: true
|
||||
};
|
||||
var b = browserify(bopts);
|
||||
|
||||
b.require('bitcore/node_modules/browserify-buffertools/buffertools.js', {
|
||||
expose: 'buffertools'
|
||||
});
|
||||
b.require('browser-request', {
|
||||
expose: 'request'
|
||||
});
|
||||
b.require('lodash');
|
||||
b.require('querystring');
|
||||
b.require('assert');
|
||||
b.require('preconditions');
|
||||
|
||||
b.require('./copay', {
|
||||
expose: 'copay'
|
||||
});
|
||||
b.require('./version');
|
||||
|
||||
// b.external('bitcore');
|
||||
b.require('./js/models/Identity', {
|
||||
expose: '../js/models/Identity'
|
||||
});
|
||||
b.require('./js/models/Wallet');
|
||||
b.require('./js/models/Wallet', {
|
||||
expose: '../../js/models/Wallet'
|
||||
});
|
||||
b.require('./js/models/Insight', {
|
||||
expose: '../js/models/Insight'
|
||||
});
|
||||
b.require('./js/models/Compatibility', {
|
||||
expose: '../js/models/Compatibility'
|
||||
});
|
||||
b.require('./js/models/PrivateKey', {
|
||||
expose: '../js/models/PrivateKey'
|
||||
});
|
||||
b.require('./js/models/PublicKeyRing', {
|
||||
expose: '../js/models/PublicKeyRing'
|
||||
});
|
||||
b.require('./js/models/HDPath', {
|
||||
expose: '../js/models/HDPath'
|
||||
});
|
||||
b.require('./js/models/PluginManager', {
|
||||
expose: '../js/models/PluginManager'
|
||||
});
|
||||
b.require('./js/util/HTTP', {
|
||||
expose: '../js/util/HTTP'
|
||||
});
|
||||
b.require('./js/util/log', {
|
||||
expose: '../js/util/log'
|
||||
});
|
||||
b.require('./js/util/csv', {
|
||||
expose: '../js/util/csv'
|
||||
});
|
||||
|
||||
if (!opts.disablePlugins) {
|
||||
b.require('./js/plugins/GoogleDrive', {
|
||||
expose: '../js/plugins/GoogleDrive'
|
||||
});
|
||||
b.require('./js/plugins/InsightStorage', {
|
||||
expose: '../js/plugins/InsightStorage'
|
||||
});
|
||||
b.require('./js/plugins/InsightStorage', {
|
||||
expose: '../js/plugins/InsightStorage'
|
||||
});
|
||||
b.require('./js/plugins/LocalStorage', {
|
||||
expose: '../js/plugins/LocalStorage'
|
||||
});
|
||||
b.require('./js/plugins/EncryptedInsightStorage', {
|
||||
expose: '../js/plugins/EncryptedInsightStorage'
|
||||
});
|
||||
b.require('./js/plugins/EncryptedLocalStorage', {
|
||||
expose: '../js/plugins/EncryptedLocalStorage'
|
||||
});
|
||||
}
|
||||
|
||||
b.require('./config', {
|
||||
expose: '../config'
|
||||
});
|
||||
|
||||
|
||||
// The following 2 lines fix karma tests
|
||||
b.require('sjcl');
|
||||
if (opts.debug) {
|
||||
//include dev dependencies
|
||||
b.require('sinon');
|
||||
b.require('blanket');
|
||||
|
||||
|
||||
b.require('./test/mocks/FakeBlockchain', {
|
||||
expose: './mocks/FakeBlockchain'
|
||||
});
|
||||
b.require('./test/mocks/FakeBlockchainSocket', {
|
||||
expose: './mocks/FakeBlockchainSocket'
|
||||
});
|
||||
b.require('./test/mocks/FakeNetwork', {
|
||||
expose: './mocks/FakeNetwork'
|
||||
});
|
||||
}
|
||||
|
||||
if (!opts.debug) {
|
||||
b.transform({
|
||||
global: true
|
||||
}, 'uglifyify');
|
||||
}
|
||||
var bundle = b.bundle();
|
||||
return bundle;
|
||||
};
|
||||
|
||||
if (require.main === module) {
|
||||
var list = function(val) {
|
||||
return val.split(',');
|
||||
};
|
||||
var program = require('commander');
|
||||
program
|
||||
.version('0.0.1')
|
||||
.option('-d, --debug', 'Development. Don\'t minify the codem and include debug packages.')
|
||||
.option('-o, --stdout', 'Specify output as stdout')
|
||||
.parse(process.argv);
|
||||
|
||||
createVersion();
|
||||
var copayBundle = createBundle(program);
|
||||
copayBundle.pipe(program.stdout ? process.stdout : fs.createWriteStream('js/copayBundle.js'));
|
||||
}
|
||||
|
||||
module.exports.createBundle = createBundle;
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
var modules = [
|
||||
'lib/Address',
|
||||
'lib/AuthMessage',
|
||||
'lib/Base58',
|
||||
'lib/HierarchicalKey',
|
||||
'lib/BIP21',
|
||||
'lib/Deserialize',
|
||||
'lib/ECIES',
|
||||
'lib/Message',
|
||||
'lib/Opcode',
|
||||
'lib/PayPro',
|
||||
'lib/PrivateKey',
|
||||
'lib/Key',
|
||||
'lib/Point',
|
||||
'lib/SIN',
|
||||
'lib/SINKey',
|
||||
'lib/Script',
|
||||
'lib/SecureRandom',
|
||||
'lib/sjcl',
|
||||
'lib/Transaction',
|
||||
'lib/TransactionBuilder',
|
||||
'lib/Wallet',
|
||||
'lib/WalletKey',
|
||||
'patches/Buffers.monkey',
|
||||
'patches/Number.monkey',
|
||||
'config',
|
||||
'const',
|
||||
'networks',
|
||||
'util/log',
|
||||
'util/util',
|
||||
'util/EncodedData',
|
||||
'util/VersionedData',
|
||||
];
|
||||
|
||||
|
||||
var cmd = 'node browser/build.js -s '
|
||||
cmd = cmd + modules.join(',');
|
||||
|
||||
console.log(cmd);
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
cd ./lib/sjcl && \
|
||||
./configure --with-sha1 &&\
|
||||
make && cp -v sjcl.js .. && echo "Done!" || echo " ## Please run $0 on copay root directory"
|
||||
|
||||
123
util/find_m_n.js
123
util/find_m_n.js
|
|
@ -1,123 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
var bitcore = require('bitcore');
|
||||
var chai = require('chai');
|
||||
var should = chai.should();
|
||||
var PublicKeyRing = require('../js/models/PublicKeyRing');
|
||||
var PrivateKey = require('../js/models/PrivateKey');
|
||||
|
||||
var FakeNetwork = require('../test/mocks/FakeNetwork');
|
||||
var Insight = require('../js/models/blockchain/Insight');
|
||||
var FakeStorage = require('../test/mocks/FakeStorage');
|
||||
|
||||
var WalletFactory = require('soop').load('../js/models/WalletFactory', {
|
||||
Network: FakeNetwork,
|
||||
Blockchain: Insight,
|
||||
Storage: FakeStorage,
|
||||
});
|
||||
var Key = bitcore.Key;
|
||||
|
||||
|
||||
var N_LIMIT = 50;
|
||||
var ITERS = 5;
|
||||
var nn = 'livenet';
|
||||
|
||||
var maxs = {};
|
||||
var valid = {};
|
||||
|
||||
for (var n = 1; n <= N_LIMIT; n++) {
|
||||
var end = false;
|
||||
for (var m = 1; m <= n; m++) {
|
||||
// case m-of-n
|
||||
console.log('case ' + m + '-of-' + n);
|
||||
var pair = [m, n];
|
||||
for (var iter = 0; iter <= ITERS * n; iter++) {
|
||||
// create full pkr
|
||||
var publicKeyRing = new PublicKeyRing({
|
||||
networkName: nn,
|
||||
requiredCopayers: m,
|
||||
totalCopayers: n,
|
||||
});
|
||||
var privateKey = null;
|
||||
var others_pks = [];
|
||||
for (var i = 0; i < n; i++) {
|
||||
var pk = new PrivateKey({
|
||||
networkName: nn
|
||||
});
|
||||
if (i === 0) {
|
||||
privateKey = pk;
|
||||
} else {
|
||||
publicKeyRing.addCopayer(pk.getExtendedPublicKeyString(), 'dummy');
|
||||
others_pks.push(pk);
|
||||
}
|
||||
}
|
||||
|
||||
others_pks.length.should.equal(n - 1);
|
||||
|
||||
var opts = {};
|
||||
opts.publicKeyRing = publicKeyRing;
|
||||
opts.privateKey = privateKey;
|
||||
opts.requiredCopayers = m;
|
||||
opts.totalCopayers = n;
|
||||
opts.spendUnconfirmed = true;
|
||||
opts.version = 'script'
|
||||
|
||||
var w = new WalletFactory(opts).create(opts);
|
||||
var addr = w.generateAddress();
|
||||
|
||||
var toAddress = 'msj42CCGruhRsFrGATiUuh25dtxYtnpbTx';
|
||||
var amount = '5000000';
|
||||
// create fake utxo
|
||||
var utxos = [{
|
||||
'address': addr,
|
||||
'txid': '82a974b72d3135152043989652e687e2966c651ba4822274926221017ea072d2',
|
||||
'vout': 1,
|
||||
'ts': 1400696213,
|
||||
'scriptPubKey': 'a914b2562c950498ff48ad3479ca1c2dfda2b0273e2287',
|
||||
'amount': 10.0,
|
||||
'confirmations': 2
|
||||
}];
|
||||
var ntxid = w.createTxSync(toAddress, amount, null, utxos);
|
||||
var txp = w.txProposals.txps[ntxid];
|
||||
|
||||
var signTx = function(pk, cb) {
|
||||
var pkr = publicKeyRing;
|
||||
var keys = pk.getAll(pkr.addressIndex, pkr.changeAddressIndex);
|
||||
|
||||
var b = txp.builder;
|
||||
var before = b.signaturesAdded;
|
||||
b.sign(keys);
|
||||
|
||||
return cb();
|
||||
}
|
||||
|
||||
async.eachSeries(others_pks, signTx, function(err) {
|
||||
if (err) {
|
||||
throw err;
|
||||
} else {
|
||||
var tx = txp.builder.build();
|
||||
var scriptSig = tx.ins[0].getScript();
|
||||
var size = scriptSig.serialize().length;
|
||||
|
||||
maxs[pair] = Math.max(maxs[pair] || 0, size)
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
var size = maxs[pair];
|
||||
console.log('\tmax size: ' + size);
|
||||
var m_valid = false;
|
||||
if (size < 500) {
|
||||
m_valid = true;
|
||||
valid[[m, n]] = size;
|
||||
}
|
||||
if (!m_valid) break;
|
||||
}
|
||||
if (!m_valid && m === 1) break;
|
||||
}
|
||||
|
||||
|
||||
console.log(valid);
|
||||
25
util/version.js
Executable file
25
util/version.js
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var shell = require('shelljs');
|
||||
|
||||
var getCommitHash = function() {
|
||||
//exec git command to get the hash of the current commit
|
||||
//git rev-parse HEAD
|
||||
|
||||
var hash = shell.exec('git rev-parse HEAD', {
|
||||
silent: true
|
||||
}).output.trim().substr(0, 7);
|
||||
return hash;
|
||||
}
|
||||
|
||||
var commitHash = getCommitHash();
|
||||
var json = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
||||
console.log('v' + json.version + ' #' + commitHash);
|
||||
|
||||
var content = 'window.version="' + json.version + '";';
|
||||
content = content + '\nwindow.commitHash="' + commitHash + '";';
|
||||
fs.writeFileSync("./src/js/version.js", content);
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue