mirror of https://github.com/BTCPrivate/copay.git
update to master
This commit is contained in:
parent
d8b10f6629
commit
4fe58ec446
|
@ -18,7 +18,7 @@
|
|||
"sjcl": "1.0.0",
|
||||
"file-saver": "*",
|
||||
"qrcode-decoder-js": "*",
|
||||
"bitcore": "git://github.com/bitpay/bitcore.git#772b12e471a76c092f73271449edc1890078e49e",
|
||||
"bitcore": "git://github.com/bitpay/bitcore.git#c94d2789582a481db19955f9e5df0129ffcc9e92",
|
||||
"angular-moment": "~0.7.1",
|
||||
"socket.io-client": ">=1.0.0",
|
||||
"mousetrap": "1.4.6"
|
||||
|
|
|
@ -89,9 +89,9 @@ Wallet.prototype._handlePublicKeyRing = function(senderId, data, isInbound) {
|
|||
var wasIncomplete = !this.publicKeyRing.isComplete();
|
||||
var hasChanged;
|
||||
|
||||
try{
|
||||
try {
|
||||
hasChanged = this.publicKeyRing.merge(inPKR, true);
|
||||
} catch (e){
|
||||
} catch (e) {
|
||||
this.log('## WALLET ERROR', e); //TODO
|
||||
this.emit('connectionError', e.message);
|
||||
return;
|
||||
|
@ -140,7 +140,7 @@ Wallet.prototype._handleTxProposals = function(senderId, data, isInbound) {
|
|||
Wallet.prototype._handleData = function(senderId, data, isInbound) {
|
||||
|
||||
// TODO check message signature
|
||||
|
||||
|
||||
if (data.type !== 'walletId' && this.id !== data.walletId) {
|
||||
this.emit('badMessage', senderId);
|
||||
this.log('badMessage FROM:', senderId); //TODO
|
||||
|
@ -281,7 +281,7 @@ Wallet.prototype.scheduleConnect = function() {
|
|||
var self = this;
|
||||
if (self.network.isOnline()) {
|
||||
self.connectToAll();
|
||||
self.currentDelay = self.currentDelay*2 || self.reconnectDelay;
|
||||
self.currentDelay = self.currentDelay * 2 || self.reconnectDelay;
|
||||
setTimeout(self.scheduleConnect.bind(self), self.currentDelay);
|
||||
}
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ Wallet.prototype.toObj = function() {
|
|||
opts: optsObj,
|
||||
publicKeyRing: this.publicKeyRing.toObj(),
|
||||
txProposals: this.txProposals.toObj(),
|
||||
privateKey: this.privateKey?this.privateKey.toObj():undefined
|
||||
privateKey: this.privateKey ? this.privateKey.toObj() : undefined
|
||||
};
|
||||
|
||||
return walletObj;
|
||||
|
@ -454,7 +454,7 @@ Wallet.prototype.reject = function(ntxid) {
|
|||
var myId = this.getMyCopayerId();
|
||||
var txp = this.txProposals.txps[ntxid];
|
||||
if (!txp || txp.rejectedBy[myId] || txp.signedBy[myId]) {
|
||||
throw new Error('Invalid transaction to reject: '+ntxid);
|
||||
throw new Error('Invalid transaction to reject: ' + ntxid);
|
||||
}
|
||||
|
||||
txp.rejectedBy[myId] = Date.now();
|
||||
|
@ -569,6 +569,9 @@ Wallet.prototype.getBalance = function(cb) {
|
|||
var BIT = coinUtil.BIT;
|
||||
var COIN = coinUtil.COIN;
|
||||
|
||||
if (!BIT)
|
||||
throw new Error('BIT not defined. A newer version of bitcore is needed');
|
||||
|
||||
this.getUnspent(function(err, safeUnspent, unspent) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
|
@ -593,7 +596,7 @@ Wallet.prototype.getBalance = function(cb) {
|
|||
safeBalance += amt;
|
||||
}
|
||||
|
||||
safeBalance = safeBalance.toFixed(0) /BIT ;
|
||||
safeBalance = safeBalance.toFixed(0) / BIT;
|
||||
return cb(null, balance, balanceByAddr, safeBalance);
|
||||
});
|
||||
};
|
||||
|
@ -611,8 +614,8 @@ Wallet.prototype.getUnspent = function(cb) {
|
|||
var uu = self.txProposals.getUsedUnspent(maxRejectCount);
|
||||
|
||||
for (var i in unspentList) {
|
||||
var u=unspentList[i];
|
||||
if (! uu[u.txid +','+u.vout])
|
||||
var u = unspentList[i];
|
||||
if (!uu[u.txid + ',' + u.vout])
|
||||
safeUnspendList.push(u);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
"homepage": "https://github.com/bitpay/copay",
|
||||
"devDependencies": {
|
||||
"async": "0.9.0",
|
||||
"bitcore": "git://github.com/bitpay/bitcore.git#772b12e471a76c092f73271449edc1890078e49e",
|
||||
"bitcore": "git://github.com/bitpay/bitcore.git#c94d2789582a481db19955f9e5df0129ffcc9e92",
|
||||
"blanket": "1.1.6",
|
||||
"browser-pack": "2.0.1",
|
||||
"browserify": "3.32.1",
|
||||
|
|
|
@ -31,7 +31,7 @@ describe('Wallet model', function() {
|
|||
(function() {
|
||||
new Wallet(config)
|
||||
}).should.
|
||||
throw ();
|
||||
throw();
|
||||
});
|
||||
|
||||
var createW = function(netKey, N) {
|
||||
|
@ -111,7 +111,7 @@ describe('Wallet model', function() {
|
|||
|
||||
var pkr = w.publicKeyRing;
|
||||
|
||||
for (var i = 0; i < N-1; i++) {
|
||||
for (var i = 0; i < N - 1; i++) {
|
||||
if (privateKeys) {
|
||||
var k = privateKeys[i];
|
||||
pkr.addCopayer(k ? k.deriveBIP45Branch().extendedPublicKeyString() : null);
|
||||
|
@ -246,7 +246,7 @@ describe('Wallet model', function() {
|
|||
o = JSON.parse(JSON.stringify(o));
|
||||
|
||||
// non stored options
|
||||
o.opts.reconnectDelay=100;
|
||||
o.opts.reconnectDelay = 100;
|
||||
|
||||
var w2 = Wallet.fromObj(o,
|
||||
new Storage(config.storage),
|
||||
|
@ -275,15 +275,15 @@ describe('Wallet model', function() {
|
|||
(function() {
|
||||
Wallet.decodeSecret('4fp61K187CsYmjoRQC5iAdC5eGmbCRsAAXfwEwetSQgHvZs27eWKaLaNHRoKM');
|
||||
}).should.not.
|
||||
throw ();
|
||||
throw();
|
||||
(function() {
|
||||
Wallet.decodeSecret('4fp61K187CsYmjoRQC5iAdC5eGmbCRsAAXfwEwetSQgHvZs27eWKaLaNHRoK');
|
||||
}).should.
|
||||
throw ();
|
||||
throw();
|
||||
(function() {
|
||||
Wallet.decodeSecret('12345');
|
||||
}).should.
|
||||
throw ();
|
||||
throw();
|
||||
});
|
||||
|
||||
it('call reconnect after interval', function(done) {
|
||||
|
@ -462,30 +462,34 @@ describe('Wallet model', function() {
|
|||
});
|
||||
});
|
||||
|
||||
var roundErrorChecks=[
|
||||
{ unspent: [ 1.0001 ],
|
||||
var roundErrorChecks = [{
|
||||
unspent: [1.0001],
|
||||
balance: 1000100
|
||||
},
|
||||
{ unspent: [ 1.0002 , 1.0003 , 1.0004 ],
|
||||
}, {
|
||||
unspent: [1.0002, 1.0003, 1.0004],
|
||||
balance: 3000900
|
||||
},
|
||||
{ unspent: [ 0.000002 , 1.000003 , 2.000004 ],
|
||||
}, {
|
||||
unspent: [0.000002, 1.000003, 2.000004],
|
||||
balance: 3000009
|
||||
}, {
|
||||
unspent: [0.0001, 0.0003],
|
||||
balance: 400
|
||||
}, {
|
||||
unspent: [0.0001, 0.0003, 0.0001, 0.0001, 0.0001, 0.0001, 0.0001, 0.0002],
|
||||
balance: 1100
|
||||
},
|
||||
{ unspent: [ 0.0001 , 0.0003 ],
|
||||
balance: 400
|
||||
},
|
||||
{ unspent: [ 0.0001 , 0.0003, 0.0001, 0.0001, 0.0001, 0.0001, 0.0001, 0.0002 ],
|
||||
balance: 1100
|
||||
},
|
||||
|
||||
|
||||
];
|
||||
|
||||
roundErrorChecks.forEach(function(c){
|
||||
it('check rounding errors '+ c.unspent[0], function(done) {
|
||||
roundErrorChecks.forEach(function(c) {
|
||||
it('check rounding errors ' + c.unspent[0], function(done) {
|
||||
var w = createW2();
|
||||
w.generateAddress();
|
||||
w.blockchain.fixUnspent(c.unspent.map(function(u){return {amount:u}}));
|
||||
w.blockchain.fixUnspent(c.unspent.map(function(u) {
|
||||
return {
|
||||
amount: u
|
||||
}
|
||||
}));
|
||||
w.getBalance(function(err, balance, balanceByAddr, safeBalance) {
|
||||
balance.should.equal(c.balance);
|
||||
done();
|
||||
|
@ -582,5 +586,5 @@ describe('Wallet model', function() {
|
|||
var w = createW();
|
||||
w.getNetworkName().should.equal('testnet');
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
'use strict';
|
||||
|
||||
if (typeof process === 'undefined' || !process.version) {
|
||||
if (typeof process === 'undefined' || !process.version) {
|
||||
// browser
|
||||
var chai = chai || require('chai');
|
||||
var should = chai.should();
|
||||
var copay = copay || require('../copay');
|
||||
var LocalPlain = copay.StorageLocalPlain;
|
||||
var chai = chai || require('chai');
|
||||
var should = chai.should();
|
||||
var copay = copay || require('../copay');
|
||||
var LocalPlain = copay.StorageLocalPlain;
|
||||
|
||||
describe('Storage/LocalPlain model', function() {
|
||||
describe.skip('Storage/LocalPlain model', function() {
|
||||
|
||||
it('should create an instance', function () {
|
||||
it('should create an instance', function() {
|
||||
var s = new LocalPlain();
|
||||
should.exist(s);
|
||||
});
|
||||
|
@ -17,7 +17,12 @@ if (typeof process === 'undefined' || !process.version) {
|
|||
describe('#setFromObj', function() {
|
||||
it('should set keys from an object', function() {
|
||||
localStorage.clear();
|
||||
var obj = {test:'testval', opts: {name: 'testname'}};
|
||||
var obj = {
|
||||
test: 'testval',
|
||||
opts: {
|
||||
name: 'testname'
|
||||
}
|
||||
};
|
||||
var storage = new LocalPlain();
|
||||
storage.setFromObj('walletId', obj);
|
||||
storage.get('walletId', 'test').should.equal('testval');
|
||||
|
|
Loading…
Reference in New Issue