|
|
@ -282,7 +282,7 @@ WalletService.prototype.replaceTemporaryRequestKey = function(opts, cb) { |
|
|
|
walletId: opts.walletId, |
|
|
|
copayerId: self.copayerId, |
|
|
|
copayerName: opts.name, |
|
|
|
}, false, function() { |
|
|
|
}, function() { |
|
|
|
return cb(null, { |
|
|
|
copayerId: self.copayerId, |
|
|
|
wallet: wallet |
|
|
@ -308,11 +308,18 @@ WalletService.prototype._verifySignature = function(text, signature, pubKey) { |
|
|
|
* |
|
|
|
* @param {String} type |
|
|
|
* @param {Object} data |
|
|
|
* @param {Boolean} isGlobal - If true, the notification is not issued on behalf of any particular copayer (defaults to false) |
|
|
|
* @param {Object} opts |
|
|
|
* @param {Boolean} opts.isGlobal - If true, the notification is not issued on behalf of any particular copayer (defaults to false) |
|
|
|
*/ |
|
|
|
WalletService.prototype._notify = function(type, data, isGlobal, cb) { |
|
|
|
WalletService.prototype._notify = function(type, data, opts, cb) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
if (_.isFunction(opts)) { |
|
|
|
cb = opts; |
|
|
|
opts = {}; |
|
|
|
} |
|
|
|
opts = opts || {}; |
|
|
|
|
|
|
|
log.debug('Notification', type, data); |
|
|
|
|
|
|
|
var walletId = self.walletId || data.walletId; |
|
|
@ -324,7 +331,7 @@ WalletService.prototype._notify = function(type, data, isGlobal, cb) { |
|
|
|
type: type, |
|
|
|
data: data, |
|
|
|
ticker: this.notifyTicker++, |
|
|
|
creatorId: isGlobal ? null : copayerId, |
|
|
|
creatorId: opts.isGlobal ? null : copayerId, |
|
|
|
walletId: walletId, |
|
|
|
}); |
|
|
|
this.storage.storeNotification(walletId, n, function() { |
|
|
@ -393,7 +400,7 @@ WalletService.prototype.joinWallet = function(opts, cb) { |
|
|
|
walletId: opts.walletId, |
|
|
|
copayerId: copayer.id, |
|
|
|
copayerName: copayer.name, |
|
|
|
}, false, function() { |
|
|
|
}, function() { |
|
|
|
return cb(null, { |
|
|
|
copayerId: copayer.id, |
|
|
|
wallet: wallet |
|
|
@ -426,7 +433,7 @@ WalletService.prototype.createAddress = function(opts, cb) { |
|
|
|
|
|
|
|
self._notify('NewAddress', { |
|
|
|
address: address.address, |
|
|
|
}, false, function() { |
|
|
|
}, function() { |
|
|
|
return cb(null, address); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -726,7 +733,7 @@ WalletService.prototype.createTx = function(opts, cb) { |
|
|
|
|
|
|
|
self._notify('NewTxProposal', { |
|
|
|
amount: opts.amount |
|
|
|
}, false, function() { |
|
|
|
}, function() { |
|
|
|
return cb(null, txp); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -800,7 +807,7 @@ WalletService.prototype.removePendingTx = function(opts, cb) { |
|
|
|
if (actors.length > 1 || (actors.length == 1 && actors[0] !== self.copayerId)) |
|
|
|
return cb(new ClientError('TXACTIONED', 'Cannot remove a proposal signed/rejected by other copayers')); |
|
|
|
|
|
|
|
self._notify('TxProposalRemoved', {}, false, function() { |
|
|
|
self._notify('TxProposalRemoved', {}, function() { |
|
|
|
self.storage.removeTx(self.walletId, txp.id, cb); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -863,13 +870,13 @@ WalletService.prototype.signTx = function(opts, cb) { |
|
|
|
self._notify('TxProposalAcceptedBy', { |
|
|
|
txProposalId: opts.txProposalId, |
|
|
|
copayerId: self.copayerId, |
|
|
|
}, false, done); |
|
|
|
}, done); |
|
|
|
}, |
|
|
|
function(done) { |
|
|
|
if (txp.isAccepted()) { |
|
|
|
self._notify('TxProposalFinallyAccepted', { |
|
|
|
txProposalId: opts.txProposalId, |
|
|
|
}, false, done); |
|
|
|
}, done); |
|
|
|
} else { |
|
|
|
done(); |
|
|
|
} |
|
|
@ -918,7 +925,7 @@ WalletService.prototype.broadcastTx = function(opts, cb) { |
|
|
|
self._notify('NewOutgoingTx', { |
|
|
|
txProposalId: opts.txProposalId, |
|
|
|
txid: txid |
|
|
|
}, false, function() { |
|
|
|
}, function() { |
|
|
|
return cb(null, txp); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -964,13 +971,13 @@ WalletService.prototype.rejectTx = function(opts, cb) { |
|
|
|
self._notify('TxProposalRejectedBy', { |
|
|
|
txProposalId: opts.txProposalId, |
|
|
|
copayerId: self.copayerId, |
|
|
|
}, false, done); |
|
|
|
}, done); |
|
|
|
}, |
|
|
|
function(done) { |
|
|
|
if (txp.status == 'rejected') { |
|
|
|
self._notify('TxProposalFinallyRejected', { |
|
|
|
txProposalId: opts.txProposalId, |
|
|
|
}, false, done); |
|
|
|
}, done); |
|
|
|
} else { |
|
|
|
done(); |
|
|
|
} |
|
|
@ -1319,7 +1326,9 @@ WalletService.prototype.startScan = function(opts, cb) { |
|
|
|
result: err ? 'error' : 'success', |
|
|
|
}; |
|
|
|
if (err) data.error = err; |
|
|
|
self._notify('ScanFinished', data, true); |
|
|
|
self._notify('ScanFinished', data, { |
|
|
|
isGlobal: true |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
self.getWallet({}, function(err, wallet) { |
|
|
|