|
@ -282,7 +282,7 @@ WalletService.prototype.replaceTemporaryRequestKey = function(opts, cb) { |
|
|
walletId: opts.walletId, |
|
|
walletId: opts.walletId, |
|
|
copayerId: self.copayerId, |
|
|
copayerId: self.copayerId, |
|
|
copayerName: opts.name, |
|
|
copayerName: opts.name, |
|
|
}, false, function() { |
|
|
}, function() { |
|
|
return cb(null, { |
|
|
return cb(null, { |
|
|
copayerId: self.copayerId, |
|
|
copayerId: self.copayerId, |
|
|
wallet: wallet |
|
|
wallet: wallet |
|
@ -308,11 +308,18 @@ WalletService.prototype._verifySignature = function(text, signature, pubKey) { |
|
|
* |
|
|
* |
|
|
* @param {String} type |
|
|
* @param {String} type |
|
|
* @param {Object} data |
|
|
* @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; |
|
|
var self = this; |
|
|
|
|
|
|
|
|
|
|
|
if (_.isFunction(opts)) { |
|
|
|
|
|
cb = opts; |
|
|
|
|
|
opts = {}; |
|
|
|
|
|
} |
|
|
|
|
|
opts = opts || {}; |
|
|
|
|
|
|
|
|
log.debug('Notification', type, data); |
|
|
log.debug('Notification', type, data); |
|
|
|
|
|
|
|
|
var walletId = self.walletId || data.walletId; |
|
|
var walletId = self.walletId || data.walletId; |
|
@ -324,7 +331,7 @@ WalletService.prototype._notify = function(type, data, isGlobal, cb) { |
|
|
type: type, |
|
|
type: type, |
|
|
data: data, |
|
|
data: data, |
|
|
ticker: this.notifyTicker++, |
|
|
ticker: this.notifyTicker++, |
|
|
creatorId: isGlobal ? null : copayerId, |
|
|
creatorId: opts.isGlobal ? null : copayerId, |
|
|
walletId: walletId, |
|
|
walletId: walletId, |
|
|
}); |
|
|
}); |
|
|
this.storage.storeNotification(walletId, n, function() { |
|
|
this.storage.storeNotification(walletId, n, function() { |
|
@ -393,7 +400,7 @@ WalletService.prototype.joinWallet = function(opts, cb) { |
|
|
walletId: opts.walletId, |
|
|
walletId: opts.walletId, |
|
|
copayerId: copayer.id, |
|
|
copayerId: copayer.id, |
|
|
copayerName: copayer.name, |
|
|
copayerName: copayer.name, |
|
|
}, false, function() { |
|
|
}, function() { |
|
|
return cb(null, { |
|
|
return cb(null, { |
|
|
copayerId: copayer.id, |
|
|
copayerId: copayer.id, |
|
|
wallet: wallet |
|
|
wallet: wallet |
|
@ -426,7 +433,7 @@ WalletService.prototype.createAddress = function(opts, cb) { |
|
|
|
|
|
|
|
|
self._notify('NewAddress', { |
|
|
self._notify('NewAddress', { |
|
|
address: address.address, |
|
|
address: address.address, |
|
|
}, false, function() { |
|
|
}, function() { |
|
|
return cb(null, address); |
|
|
return cb(null, address); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -726,7 +733,7 @@ WalletService.prototype.createTx = function(opts, cb) { |
|
|
|
|
|
|
|
|
self._notify('NewTxProposal', { |
|
|
self._notify('NewTxProposal', { |
|
|
amount: opts.amount |
|
|
amount: opts.amount |
|
|
}, false, function() { |
|
|
}, function() { |
|
|
return cb(null, txp); |
|
|
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)) |
|
|
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')); |
|
|
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); |
|
|
self.storage.removeTx(self.walletId, txp.id, cb); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -863,13 +870,13 @@ WalletService.prototype.signTx = function(opts, cb) { |
|
|
self._notify('TxProposalAcceptedBy', { |
|
|
self._notify('TxProposalAcceptedBy', { |
|
|
txProposalId: opts.txProposalId, |
|
|
txProposalId: opts.txProposalId, |
|
|
copayerId: self.copayerId, |
|
|
copayerId: self.copayerId, |
|
|
}, false, done); |
|
|
}, done); |
|
|
}, |
|
|
}, |
|
|
function(done) { |
|
|
function(done) { |
|
|
if (txp.isAccepted()) { |
|
|
if (txp.isAccepted()) { |
|
|
self._notify('TxProposalFinallyAccepted', { |
|
|
self._notify('TxProposalFinallyAccepted', { |
|
|
txProposalId: opts.txProposalId, |
|
|
txProposalId: opts.txProposalId, |
|
|
}, false, done); |
|
|
}, done); |
|
|
} else { |
|
|
} else { |
|
|
done(); |
|
|
done(); |
|
|
} |
|
|
} |
|
@ -918,7 +925,7 @@ WalletService.prototype.broadcastTx = function(opts, cb) { |
|
|
self._notify('NewOutgoingTx', { |
|
|
self._notify('NewOutgoingTx', { |
|
|
txProposalId: opts.txProposalId, |
|
|
txProposalId: opts.txProposalId, |
|
|
txid: txid |
|
|
txid: txid |
|
|
}, false, function() { |
|
|
}, function() { |
|
|
return cb(null, txp); |
|
|
return cb(null, txp); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
@ -964,13 +971,13 @@ WalletService.prototype.rejectTx = function(opts, cb) { |
|
|
self._notify('TxProposalRejectedBy', { |
|
|
self._notify('TxProposalRejectedBy', { |
|
|
txProposalId: opts.txProposalId, |
|
|
txProposalId: opts.txProposalId, |
|
|
copayerId: self.copayerId, |
|
|
copayerId: self.copayerId, |
|
|
}, false, done); |
|
|
}, done); |
|
|
}, |
|
|
}, |
|
|
function(done) { |
|
|
function(done) { |
|
|
if (txp.status == 'rejected') { |
|
|
if (txp.status == 'rejected') { |
|
|
self._notify('TxProposalFinallyRejected', { |
|
|
self._notify('TxProposalFinallyRejected', { |
|
|
txProposalId: opts.txProposalId, |
|
|
txProposalId: opts.txProposalId, |
|
|
}, false, done); |
|
|
}, done); |
|
|
} else { |
|
|
} else { |
|
|
done(); |
|
|
done(); |
|
|
} |
|
|
} |
|
@ -1319,7 +1326,9 @@ WalletService.prototype.startScan = function(opts, cb) { |
|
|
result: err ? 'error' : 'success', |
|
|
result: err ? 'error' : 'success', |
|
|
}; |
|
|
}; |
|
|
if (err) data.error = err; |
|
|
if (err) data.error = err; |
|
|
self._notify('ScanFinished', data, true); |
|
|
self._notify('ScanFinished', data, { |
|
|
|
|
|
isGlobal: true |
|
|
|
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
self.getWallet({}, function(err, wallet) { |
|
|
self.getWallet({}, function(err, wallet) { |
|
|