mirror of https://github.com/BTCPrivate/copay.git
Change all logs found to use log.js
This commit is contained in:
parent
8f7d952e0f
commit
f4cdd15f04
|
@ -18,11 +18,6 @@ if (localConfig) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var log = function() {
|
|
||||||
if (config.verbose) console.log(arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var copayApp = window.copayApp = angular.module('copayApp', [
|
var copayApp = window.copayApp = angular.module('copayApp', [
|
||||||
'ngRoute',
|
'ngRoute',
|
||||||
'angularMoment',
|
'angularMoment',
|
||||||
|
|
|
@ -42,4 +42,4 @@ Logger.prototype.setLevel = function(level) {
|
||||||
var logger = new Logger('copay');
|
var logger = new Logger('copay');
|
||||||
logger.setLevel(config.logLevel);
|
logger.setLevel(config.logLevel);
|
||||||
|
|
||||||
module.exports.logger = logger;
|
module.exports = logger;
|
||||||
|
|
|
@ -15,6 +15,7 @@ var Base58Check = bitcore.Base58.base58Check;
|
||||||
var Address = bitcore.Address;
|
var Address = bitcore.Address;
|
||||||
var PayPro = bitcore.PayPro;
|
var PayPro = bitcore.PayPro;
|
||||||
var Transaction = bitcore.Transaction;
|
var Transaction = bitcore.Transaction;
|
||||||
|
var log = require('../../log');
|
||||||
|
|
||||||
var HDParams = require('./HDParams');
|
var HDParams = require('./HDParams');
|
||||||
var PublicKeyRing = require('./PublicKeyRing');
|
var PublicKeyRing = require('./PublicKeyRing');
|
||||||
|
@ -72,12 +73,6 @@ Wallet.builderOpts = {
|
||||||
feeSat: null,
|
feeSat: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype.log = function() {
|
|
||||||
if (!this.verbose) return;
|
|
||||||
if (console)
|
|
||||||
console.log.apply(console, arguments);
|
|
||||||
};
|
|
||||||
|
|
||||||
Wallet.getRandomId = function() {
|
Wallet.getRandomId = function() {
|
||||||
var r = bitcore.SecureRandom.getPseudoRandomBuffer(8).toString('hex');
|
var r = bitcore.SecureRandom.getPseudoRandomBuffer(8).toString('hex');
|
||||||
return r;
|
return r;
|
||||||
|
@ -88,7 +83,7 @@ Wallet.prototype.seedCopayer = function(pubKey) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype._onIndexes = function(senderId, data) {
|
Wallet.prototype._onIndexes = function(senderId, data) {
|
||||||
this.log('RECV INDEXES:', data);
|
log.debug('RECV INDEXES:', data);
|
||||||
var inIndexes = HDParams.fromList(data.indexes);
|
var inIndexes = HDParams.fromList(data.indexes);
|
||||||
var hasChanged = this.publicKeyRing.mergeIndexes(inIndexes);
|
var hasChanged = this.publicKeyRing.mergeIndexes(inIndexes);
|
||||||
if (hasChanged) {
|
if (hasChanged) {
|
||||||
|
@ -98,7 +93,7 @@ Wallet.prototype._onIndexes = function(senderId, data) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype._onPublicKeyRing = function(senderId, data) {
|
Wallet.prototype._onPublicKeyRing = function(senderId, data) {
|
||||||
this.log('RECV PUBLICKEYRING:', data);
|
log.debug('RECV PUBLICKEYRING:', data);
|
||||||
|
|
||||||
var inPKR = PublicKeyRing.fromObj(data.publicKeyRing);
|
var inPKR = PublicKeyRing.fromObj(data.publicKeyRing);
|
||||||
var wasIncomplete = !this.publicKeyRing.isComplete();
|
var wasIncomplete = !this.publicKeyRing.isComplete();
|
||||||
|
@ -107,7 +102,7 @@ Wallet.prototype._onPublicKeyRing = function(senderId, data) {
|
||||||
try {
|
try {
|
||||||
hasChanged = this.publicKeyRing.merge(inPKR, true);
|
hasChanged = this.publicKeyRing.merge(inPKR, true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.log('## WALLET ERROR', e);
|
log.debug('## WALLET ERROR', e);
|
||||||
this.emit('connectionError', e.message);
|
this.emit('connectionError', e.message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +200,7 @@ Wallet.prototype._checkSentTx = function(ntxid, cb) {
|
||||||
|
|
||||||
Wallet.prototype._onTxProposal = function(senderId, data) {
|
Wallet.prototype._onTxProposal = function(senderId, data) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.log('RECV TXPROPOSAL: ', data);
|
log.debug('RECV TXPROPOSAL: ', data);
|
||||||
var m;
|
var m;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -214,7 +209,7 @@ Wallet.prototype._onTxProposal = function(senderId, data) {
|
||||||
ret.newCopayer = m.txp.setCopayers(senderId, keyMap);
|
ret.newCopayer = m.txp.setCopayers(senderId, keyMap);
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.log('Corrupt TX proposal received from:', senderId, e);
|
log.debug('Corrupt TX proposal received from:', senderId, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m) {
|
if (m) {
|
||||||
|
@ -242,7 +237,7 @@ Wallet.prototype._onTxProposal = function(senderId, data) {
|
||||||
|
|
||||||
Wallet.prototype._onReject = function(senderId, data) {
|
Wallet.prototype._onReject = function(senderId, data) {
|
||||||
preconditions.checkState(data.ntxid);
|
preconditions.checkState(data.ntxid);
|
||||||
this.log('RECV REJECT:', data);
|
log.debug('RECV REJECT:', data);
|
||||||
|
|
||||||
var txp = this.txProposals.get(data.ntxid);
|
var txp = this.txProposals.get(data.ntxid);
|
||||||
|
|
||||||
|
@ -265,7 +260,7 @@ Wallet.prototype._onReject = function(senderId, data) {
|
||||||
|
|
||||||
Wallet.prototype._onSeen = function(senderId, data) {
|
Wallet.prototype._onSeen = function(senderId, data) {
|
||||||
preconditions.checkState(data.ntxid);
|
preconditions.checkState(data.ntxid);
|
||||||
this.log('RECV SEEN:', data);
|
log.debug('RECV SEEN:', data);
|
||||||
|
|
||||||
var txp = this.txProposals.get(data.ntxid);
|
var txp = this.txProposals.get(data.ntxid);
|
||||||
txp.setSeen(senderId);
|
txp.setSeen(senderId);
|
||||||
|
@ -283,7 +278,7 @@ Wallet.prototype._onSeen = function(senderId, data) {
|
||||||
|
|
||||||
Wallet.prototype._onAddressBook = function(senderId, data) {
|
Wallet.prototype._onAddressBook = function(senderId, data) {
|
||||||
preconditions.checkState(data.addressBook);
|
preconditions.checkState(data.addressBook);
|
||||||
this.log('RECV ADDRESSBOOK:', data);
|
log.debug('RECV ADDRESSBOOK:', data);
|
||||||
var rcv = data.addressBook;
|
var rcv = data.addressBook;
|
||||||
var hasChange;
|
var hasChange;
|
||||||
for (var key in rcv) {
|
for (var key in rcv) {
|
||||||
|
@ -311,7 +306,7 @@ Wallet.prototype.updateTimestamp = function(ts) {
|
||||||
|
|
||||||
|
|
||||||
Wallet.prototype._onNoMessages = function() {
|
Wallet.prototype._onNoMessages = function() {
|
||||||
console.log('No messages at the server. Requesting sync'); //TODO
|
log.debug('No messages at the server. Requesting sync'); //TODO
|
||||||
this.sendWalletReady();
|
this.sendWalletReady();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -322,7 +317,7 @@ Wallet.prototype._onData = function(senderId, data, ts) {
|
||||||
preconditions.checkArgument(ts);
|
preconditions.checkArgument(ts);
|
||||||
preconditions.checkArgument(typeof ts === 'number');
|
preconditions.checkArgument(typeof ts === 'number');
|
||||||
|
|
||||||
console.log('RECV', senderId, data);
|
log.debug('RECV', senderId, data);
|
||||||
|
|
||||||
if (data.type !== 'walletId' && this.id !== data.walletId) {
|
if (data.type !== 'walletId' && this.id !== data.walletId) {
|
||||||
this.emit('corrupt', senderId);
|
this.emit('corrupt', senderId);
|
||||||
|
@ -375,7 +370,7 @@ Wallet.prototype._onData = function(senderId, data, ts) {
|
||||||
|
|
||||||
Wallet.prototype._onConnect = function(newCopayerId) {
|
Wallet.prototype._onConnect = function(newCopayerId) {
|
||||||
if (newCopayerId) {
|
if (newCopayerId) {
|
||||||
this.log('#### Setting new COPAYER:', newCopayerId);
|
log.debug('#### Setting new COPAYER:', newCopayerId);
|
||||||
this.sendWalletId(newCopayerId);
|
this.sendWalletId(newCopayerId);
|
||||||
}
|
}
|
||||||
var peerID = this.network.peerFromCopayer(newCopayerId)
|
var peerID = this.network.peerFromCopayer(newCopayerId)
|
||||||
|
@ -515,7 +510,7 @@ Wallet.prototype.keepAlive = function() {
|
||||||
try {
|
try {
|
||||||
this.lock.keepAlive();
|
this.lock.keepAlive();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.log(e);
|
log.debug(e);
|
||||||
this.emit('locked', null, 'Wallet appears to be openned on other browser instance. Closing this one.');
|
this.emit('locked', null, 'Wallet appears to be openned on other browser instance. Closing this one.');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -525,7 +520,7 @@ Wallet.prototype.store = function() {
|
||||||
|
|
||||||
var wallet = this.toObj();
|
var wallet = this.toObj();
|
||||||
this.storage.setFromObj(this.id, wallet);
|
this.storage.setFromObj(this.id, wallet);
|
||||||
this.log('Wallet stored');
|
log.debug('Wallet stored');
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype.toObj = function() {
|
Wallet.prototype.toObj = function() {
|
||||||
|
@ -613,7 +608,7 @@ Wallet.prototype.sendAllTxProposals = function(recipients) {
|
||||||
Wallet.prototype.sendTxProposal = function(ntxid, recipients) {
|
Wallet.prototype.sendTxProposal = function(ntxid, recipients) {
|
||||||
preconditions.checkArgument(ntxid);
|
preconditions.checkArgument(ntxid);
|
||||||
|
|
||||||
this.log('### SENDING txProposal ' + ntxid + ' TO:', recipients || 'All', this.txProposals);
|
log.debug('### SENDING txProposal ' + ntxid + ' TO:', recipients || 'All', this.txProposals);
|
||||||
this.send(recipients, {
|
this.send(recipients, {
|
||||||
type: 'txProposal',
|
type: 'txProposal',
|
||||||
txProposal: this.txProposals.get(ntxid).toObjTrim(),
|
txProposal: this.txProposals.get(ntxid).toObjTrim(),
|
||||||
|
@ -623,7 +618,7 @@ Wallet.prototype.sendTxProposal = function(ntxid, recipients) {
|
||||||
|
|
||||||
Wallet.prototype.sendSeen = function(ntxid) {
|
Wallet.prototype.sendSeen = function(ntxid) {
|
||||||
preconditions.checkArgument(ntxid);
|
preconditions.checkArgument(ntxid);
|
||||||
this.log('### SENDING seen: ' + ntxid + ' TO: All');
|
log.debug('### SENDING seen: ' + ntxid + ' TO: All');
|
||||||
this.send(null, {
|
this.send(null, {
|
||||||
type: 'seen',
|
type: 'seen',
|
||||||
ntxid: ntxid,
|
ntxid: ntxid,
|
||||||
|
@ -633,7 +628,7 @@ Wallet.prototype.sendSeen = function(ntxid) {
|
||||||
|
|
||||||
Wallet.prototype.sendReject = function(ntxid) {
|
Wallet.prototype.sendReject = function(ntxid) {
|
||||||
preconditions.checkArgument(ntxid);
|
preconditions.checkArgument(ntxid);
|
||||||
this.log('### SENDING reject: ' + ntxid + ' TO: All');
|
log.debug('### SENDING reject: ' + ntxid + ' TO: All');
|
||||||
this.send(null, {
|
this.send(null, {
|
||||||
type: 'reject',
|
type: 'reject',
|
||||||
ntxid: ntxid,
|
ntxid: ntxid,
|
||||||
|
@ -643,7 +638,7 @@ Wallet.prototype.sendReject = function(ntxid) {
|
||||||
|
|
||||||
|
|
||||||
Wallet.prototype.sendWalletReady = function(recipients) {
|
Wallet.prototype.sendWalletReady = function(recipients) {
|
||||||
this.log('### SENDING WalletReady TO:', recipients || 'All');
|
log.debug('### SENDING WalletReady TO:', recipients || 'All');
|
||||||
|
|
||||||
this.send(recipients, {
|
this.send(recipients, {
|
||||||
type: 'walletReady',
|
type: 'walletReady',
|
||||||
|
@ -652,7 +647,7 @@ Wallet.prototype.sendWalletReady = function(recipients) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype.sendWalletId = function(recipients) {
|
Wallet.prototype.sendWalletId = function(recipients) {
|
||||||
this.log('### SENDING walletId TO:', recipients || 'All', this.id);
|
log.debug('### SENDING walletId TO:', recipients || 'All', this.id);
|
||||||
|
|
||||||
this.send(recipients, {
|
this.send(recipients, {
|
||||||
type: 'walletId',
|
type: 'walletId',
|
||||||
|
@ -664,7 +659,7 @@ Wallet.prototype.sendWalletId = function(recipients) {
|
||||||
|
|
||||||
|
|
||||||
Wallet.prototype.sendPublicKeyRing = function(recipients) {
|
Wallet.prototype.sendPublicKeyRing = function(recipients) {
|
||||||
this.log('### SENDING publicKeyRing TO:', recipients || 'All', this.publicKeyRing.toObj());
|
log.debug('### SENDING publicKeyRing TO:', recipients || 'All', this.publicKeyRing.toObj());
|
||||||
var publicKeyRing = this.publicKeyRing.toObj();
|
var publicKeyRing = this.publicKeyRing.toObj();
|
||||||
|
|
||||||
this.send(recipients, {
|
this.send(recipients, {
|
||||||
|
@ -675,7 +670,7 @@ Wallet.prototype.sendPublicKeyRing = function(recipients) {
|
||||||
};
|
};
|
||||||
Wallet.prototype.sendIndexes = function(recipients) {
|
Wallet.prototype.sendIndexes = function(recipients) {
|
||||||
var indexes = HDParams.serialize(this.publicKeyRing.indexes);
|
var indexes = HDParams.serialize(this.publicKeyRing.indexes);
|
||||||
this.log('### INDEXES TO:', recipients || 'All', indexes);
|
log.debug('### INDEXES TO:', recipients || 'All', indexes);
|
||||||
|
|
||||||
this.send(recipients, {
|
this.send(recipients, {
|
||||||
type: 'indexes',
|
type: 'indexes',
|
||||||
|
@ -685,7 +680,7 @@ Wallet.prototype.sendIndexes = function(recipients) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype.sendAddressBook = function(recipients) {
|
Wallet.prototype.sendAddressBook = function(recipients) {
|
||||||
this.log('### SENDING addressBook TO:', recipients || 'All', this.addressBook);
|
log.debug('### SENDING addressBook TO:', recipients || 'All', this.addressBook);
|
||||||
this.send(recipients, {
|
this.send(recipients, {
|
||||||
type: 'addressbook',
|
type: 'addressbook',
|
||||||
addressBook: this.addressBook,
|
addressBook: this.addressBook,
|
||||||
|
@ -796,23 +791,23 @@ Wallet.prototype.sendTx = function(ntxid, cb) {
|
||||||
var tx = txp.builder.build();
|
var tx = txp.builder.build();
|
||||||
if (!tx.isComplete())
|
if (!tx.isComplete())
|
||||||
throw new Error('Tx is not complete. Can not broadcast');
|
throw new Error('Tx is not complete. Can not broadcast');
|
||||||
this.log('Broadcasting Transaction');
|
log.debug('Broadcasting Transaction');
|
||||||
var scriptSig = tx.ins[0].getScript();
|
var scriptSig = tx.ins[0].getScript();
|
||||||
var size = scriptSig.serialize().length;
|
var size = scriptSig.serialize().length;
|
||||||
|
|
||||||
var txHex = tx.serialize().toString('hex');
|
var txHex = tx.serialize().toString('hex');
|
||||||
this.log('Raw transaction: ', txHex);
|
log.debug('Raw transaction: ', txHex);
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.blockchain.broadcast(txHex, function(err, txid) {
|
this.blockchain.broadcast(txHex, function(err, txid) {
|
||||||
self.log('BITCOIND txid:', txid);
|
log.debug('BITCOIND txid:', txid);
|
||||||
if (txid) {
|
if (txid) {
|
||||||
self.txProposals.get(ntxid).setSent(txid);
|
self.txProposals.get(ntxid).setSent(txid);
|
||||||
self.sendTxProposal(ntxid);
|
self.sendTxProposal(ntxid);
|
||||||
self.store();
|
self.store();
|
||||||
return cb(txid);
|
return cb(txid);
|
||||||
} else {
|
} else {
|
||||||
self.log('Sent failed. Checking if the TX was sent already');
|
log.debug('Sent failed. Checking if the TX was sent already');
|
||||||
self._checkSentTx(ntxid, function(txid) {
|
self._checkSentTx(ntxid, function(txid) {
|
||||||
if (txid)
|
if (txid)
|
||||||
self.store();
|
self.store();
|
||||||
|
@ -1003,10 +998,10 @@ Wallet.prototype.receivePaymentRequest = function(options, pr, cb) {
|
||||||
self.emit('txProposalsUpdated');
|
self.emit('txProposalsUpdated');
|
||||||
}
|
}
|
||||||
|
|
||||||
self.log('You are currently on this BTC network:');
|
log.debug('You are currently on this BTC network:');
|
||||||
self.log(network);
|
log.debug(network);
|
||||||
self.log('The server sent you a message:');
|
log.debug('The server sent you a message:');
|
||||||
self.log(memo);
|
log.debug(memo);
|
||||||
|
|
||||||
return cb(ntxid, merchantData);
|
return cb(ntxid, merchantData);
|
||||||
});
|
});
|
||||||
|
@ -1025,7 +1020,7 @@ Wallet.prototype.sendPaymentTx = function(ntxid, options, cb) {
|
||||||
|
|
||||||
var tx = txp.builder.build();
|
var tx = txp.builder.build();
|
||||||
if (!tx.isComplete()) return;
|
if (!tx.isComplete()) return;
|
||||||
this.log('Sending Transaction');
|
log.debug('Sending Transaction');
|
||||||
|
|
||||||
var refund_outputs = [];
|
var refund_outputs = [];
|
||||||
|
|
||||||
|
@ -1085,8 +1080,8 @@ Wallet.prototype.sendPaymentTx = function(ntxid, options, cb) {
|
||||||
|
|
||||||
pay = pay.serialize();
|
pay = pay.serialize();
|
||||||
|
|
||||||
this.log('Sending Payment Message:');
|
log.debug('Sending Payment Message:');
|
||||||
this.log(pay.toString('hex'));
|
log.debug(pay.toString('hex'));
|
||||||
|
|
||||||
var buf = new ArrayBuffer(pay.length);
|
var buf = new ArrayBuffer(pay.length);
|
||||||
var view = new Uint8Array(buf);
|
var view = new Uint8Array(buf);
|
||||||
|
@ -1127,8 +1122,8 @@ Wallet.prototype.receivePaymentRequestACK = function(ntxid, tx, txp, ack, cb) {
|
||||||
var payment = ack.get('payment');
|
var payment = ack.get('payment');
|
||||||
var memo = ack.get('memo');
|
var memo = ack.get('memo');
|
||||||
|
|
||||||
this.log('Our payment was acknowledged!');
|
log.debug('Our payment was acknowledged!');
|
||||||
this.log('Message from Merchant: %s', memo);
|
log.debug('Message from Merchant: %s', memo);
|
||||||
|
|
||||||
payment = PayPro.Payment.decode(payment);
|
payment = PayPro.Payment.decode(payment);
|
||||||
var pay = new PayPro();
|
var pay = new PayPro();
|
||||||
|
@ -1141,7 +1136,7 @@ Wallet.prototype.receivePaymentRequestACK = function(ntxid, tx, txp, ack, cb) {
|
||||||
var tx = payment.message.transactions[0];
|
var tx = payment.message.transactions[0];
|
||||||
|
|
||||||
if (!tx) {
|
if (!tx) {
|
||||||
this.log('Sending to server was not met with a returned tx.');
|
log.debug('Sending to server was not met with a returned tx.');
|
||||||
return this._checkSentTx(ntxid, function(txid) {
|
return this._checkSentTx(ntxid, function(txid) {
|
||||||
self.log('[Wallet.js.1048:txid:%s]', txid);
|
self.log('[Wallet.js.1048:txid:%s]', txid);
|
||||||
if (txid) self.store();
|
if (txid) self.store();
|
||||||
|
@ -1159,8 +1154,8 @@ Wallet.prototype.receivePaymentRequestACK = function(ntxid, tx, txp, ack, cb) {
|
||||||
|
|
||||||
var txid = tx.getHash().toString('hex');
|
var txid = tx.getHash().toString('hex');
|
||||||
var txHex = tx.serialize().toString('hex');
|
var txHex = tx.serialize().toString('hex');
|
||||||
this.log('Raw transaction: ', txHex);
|
log.debug('Raw transaction: ', txHex);
|
||||||
this.log('BITCOIND txid:', txid);
|
log.debug('BITCOIND txid:', txid);
|
||||||
this.txProposals.get(ntxid).setSent(txid);
|
this.txProposals.get(ntxid).setSent(txid);
|
||||||
this.sendTxProposal(ntxid);
|
this.sendTxProposal(ntxid);
|
||||||
this.store();
|
this.store();
|
||||||
|
@ -1260,10 +1255,7 @@ Wallet.prototype.createPaymentTxSync = function(options, merchantData, unspent)
|
||||||
|
|
||||||
if (options.fetch) return;
|
if (options.fetch) return;
|
||||||
|
|
||||||
this.log('');
|
log.debug('Created transaction: %s', b.tx.getStandardizedObject());
|
||||||
this.log('Created transaction:');
|
|
||||||
this.log(b.tx.getStandardizedObject());
|
|
||||||
this.log('');
|
|
||||||
|
|
||||||
var myId = this.getMyCopayerId();
|
var myId = this.getMyCopayerId();
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
|
@ -1661,7 +1653,7 @@ Wallet.prototype.createTxSync = function(toAddress, amountSatStr, comment, utxos
|
||||||
|
|
||||||
Wallet.prototype.updateIndexes = function(callback) {
|
Wallet.prototype.updateIndexes = function(callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.log('Updating indexes...');
|
log.debug('Updating indexes...');
|
||||||
|
|
||||||
var tasks = this.publicKeyRing.indexes.map(function(index) {
|
var tasks = this.publicKeyRing.indexes.map(function(index) {
|
||||||
return function(callback) {
|
return function(callback) {
|
||||||
|
@ -1671,7 +1663,7 @@ Wallet.prototype.updateIndexes = function(callback) {
|
||||||
|
|
||||||
async.parallel(tasks, function(err) {
|
async.parallel(tasks, function(err) {
|
||||||
if (err) callback(err);
|
if (err) callback(err);
|
||||||
self.log('Indexes updated');
|
log.debug('Indexes updated');
|
||||||
self.emit('publicKeyRingUpdated');
|
self.emit('publicKeyRingUpdated');
|
||||||
self.store();
|
self.store();
|
||||||
callback();
|
callback();
|
||||||
|
@ -1747,7 +1739,7 @@ Wallet.prototype.indexDiscovery = function(start, change, copayerIndex, gap, cb)
|
||||||
|
|
||||||
|
|
||||||
Wallet.prototype.close = function() {
|
Wallet.prototype.close = function() {
|
||||||
this.log('## CLOSING');
|
log.debug('## CLOSING');
|
||||||
this.lock.release();
|
this.lock.release();
|
||||||
this.network.cleanUp();
|
this.network.cleanUp();
|
||||||
this.blockchain.destroy();
|
this.blockchain.destroy();
|
||||||
|
|
|
@ -5,6 +5,8 @@ var PublicKeyRing = require('./PublicKeyRing');
|
||||||
var PrivateKey = require('./PrivateKey');
|
var PrivateKey = require('./PrivateKey');
|
||||||
var Wallet = require('./Wallet');
|
var Wallet = require('./Wallet');
|
||||||
|
|
||||||
|
var log = require('../../log');
|
||||||
|
|
||||||
var Async = module.exports.Async = require('../network/Async');
|
var Async = module.exports.Async = require('../network/Async');
|
||||||
var Insight = module.exports.Insight = require('../blockchain/Insight');
|
var Insight = module.exports.Insight = require('../blockchain/Insight');
|
||||||
var StorageLocalEncrypted = module.exports.StorageLocalEncrypted = require('../storage/LocalEncrypted');
|
var StorageLocalEncrypted = module.exports.StorageLocalEncrypted = require('../storage/LocalEncrypted');
|
||||||
|
@ -27,19 +29,10 @@ function WalletFactory(config, version) {
|
||||||
this.blockchain = new this.Blockchain(config.blockchain);
|
this.blockchain = new this.Blockchain(config.blockchain);
|
||||||
|
|
||||||
this.networkName = config.networkName;
|
this.networkName = config.networkName;
|
||||||
this.verbose = config.verbose;
|
|
||||||
this.walletDefaults = config.wallet;
|
this.walletDefaults = config.wallet;
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
WalletFactory.prototype.log = function() {
|
|
||||||
if (!this.verbose) return;
|
|
||||||
if (console) {
|
|
||||||
console.log.apply(console, arguments);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
WalletFactory.prototype._checkRead = function(walletId) {
|
WalletFactory.prototype._checkRead = function(walletId) {
|
||||||
var s = this.storage;
|
var s = this.storage;
|
||||||
var ret =
|
var ret =
|
||||||
|
@ -112,7 +105,7 @@ WalletFactory.prototype.read = function(walletId, skipFields) {
|
||||||
|
|
||||||
WalletFactory.prototype.create = function(opts) {
|
WalletFactory.prototype.create = function(opts) {
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
this.log('### CREATING NEW WALLET.' + (opts.id ? ' USING ID: ' + opts.id : ' NEW ID') + (opts.privateKey ? ' USING PrivateKey: ' + opts.privateKey.getId() : ' NEW PrivateKey'));
|
log.debug('### CREATING NEW WALLET.' + (opts.id ? ' USING ID: ' + opts.id : ' NEW ID') + (opts.privateKey ? ' USING PrivateKey: ' + opts.privateKey.getId() : ' NEW PrivateKey'));
|
||||||
|
|
||||||
var privOpts = {
|
var privOpts = {
|
||||||
networkName: this.networkName,
|
networkName: this.networkName,
|
||||||
|
@ -137,12 +130,12 @@ WalletFactory.prototype.create = function(opts) {
|
||||||
opts.privateKey.deriveBIP45Branch().extendedPublicKeyString(),
|
opts.privateKey.deriveBIP45Branch().extendedPublicKeyString(),
|
||||||
opts.nickname
|
opts.nickname
|
||||||
);
|
);
|
||||||
this.log('\t### PublicKeyRing Initialized');
|
log.debug('\t### PublicKeyRing Initialized');
|
||||||
|
|
||||||
opts.txProposals = opts.txProposals || new TxProposals({
|
opts.txProposals = opts.txProposals || new TxProposals({
|
||||||
networkName: this.networkName,
|
networkName: this.networkName,
|
||||||
});
|
});
|
||||||
this.log('\t### TxProposals Initialized');
|
log.debug('\t### TxProposals Initialized');
|
||||||
|
|
||||||
this.storage._setPassphrase(opts.passphrase);
|
this.storage._setPassphrase(opts.passphrase);
|
||||||
|
|
||||||
|
@ -236,7 +229,7 @@ WalletFactory.prototype.joinCreateSession = function(secret, nickname, passphras
|
||||||
|
|
||||||
//Create our PrivateK
|
//Create our PrivateK
|
||||||
var privateKey = new PrivateKey(privOpts);
|
var privateKey = new PrivateKey(privOpts);
|
||||||
this.log('\t### PrivateKey Initialized');
|
log.debug('\t### PrivateKey Initialized');
|
||||||
var opts = {
|
var opts = {
|
||||||
copayerId: privateKey.getId(),
|
copayerId: privateKey.getId(),
|
||||||
privkey: privateKey.getIdPriv(),
|
privkey: privateKey.getIdPriv(),
|
||||||
|
|
Loading…
Reference in New Issue