|
|
@ -457,6 +457,23 @@ WalletService.prototype._notify = function(type, data, opts, cb) { |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
WalletService.prototype._notifyTxProposalAction = function(type, txp, extraArgs, cb) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
if (_.isFunction(extraArgs)) { |
|
|
|
cb = extraArgs; |
|
|
|
extraArgs = {}; |
|
|
|
} |
|
|
|
|
|
|
|
var data = _.assign({ |
|
|
|
txProposalId: txp.id, |
|
|
|
creatorId: txp.creatorId, |
|
|
|
amount: txp.getTotalAmount(), |
|
|
|
message: txp.message, |
|
|
|
}, extraArgs); |
|
|
|
self._notify(type, data, {}, cb); |
|
|
|
}; |
|
|
|
|
|
|
|
WalletService.prototype._addCopayerToWallet = function(wallet, opts, cb) { |
|
|
|
var self = this; |
|
|
|
|
|
|
@ -1991,11 +2008,7 @@ WalletService.prototype.publishTx = function(opts, cb) { |
|
|
|
self.storage.storeTx(self.walletId, txp, function(err) { |
|
|
|
if (err) return cb(err); |
|
|
|
|
|
|
|
self._notify('NewTxProposal', { |
|
|
|
amount: txp.getTotalAmount(), |
|
|
|
txProposalId: txp.id, |
|
|
|
message: txp.message, |
|
|
|
}, function() { |
|
|
|
self._notifyTxProposalAction('NewTxProposal', txp, function() { |
|
|
|
return cb(null, txp); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -2144,7 +2157,7 @@ WalletService.prototype.removePendingTx = function(opts, cb) { |
|
|
|
if (deleteLockTime > 0) return cb(Errors.TX_CANNOT_REMOVE); |
|
|
|
|
|
|
|
self.storage.removeTx(self.walletId, txp.id, function() { |
|
|
|
self._notify('TxProposalRemoved', {}, cb); |
|
|
|
self._notifyTxProposalAction('TxProposalRemoved', txp, cb); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -2236,16 +2249,13 @@ WalletService.prototype.signTx = function(opts, cb) { |
|
|
|
async.series([ |
|
|
|
|
|
|
|
function(next) { |
|
|
|
self._notify('TxProposalAcceptedBy', { |
|
|
|
txProposalId: opts.txProposalId, |
|
|
|
self._notifyTxProposalAction('TxProposalAcceptedBy', txp, { |
|
|
|
copayerId: self.copayerId, |
|
|
|
}, next); |
|
|
|
}, |
|
|
|
function(next) { |
|
|
|
if (txp.isAccepted()) { |
|
|
|
self._notify('TxProposalFinallyAccepted', { |
|
|
|
txProposalId: opts.txProposalId, |
|
|
|
}, next); |
|
|
|
self._notifyTxProposalAction('TxProposalFinallyAccepted', txp, next); |
|
|
|
} else { |
|
|
|
next(); |
|
|
|
} |
|
|
@ -2267,16 +2277,13 @@ WalletService.prototype._processBroadcast = function(txp, opts, cb) { |
|
|
|
self.storage.storeTx(self.walletId, txp, function(err) { |
|
|
|
if (err) return cb(err); |
|
|
|
|
|
|
|
var args = { |
|
|
|
txProposalId: txp.id, |
|
|
|
var extraArgs = { |
|
|
|
txid: txp.txid, |
|
|
|
amount: txp.getTotalAmount(), |
|
|
|
}; |
|
|
|
|
|
|
|
if (opts.byThirdParty) { |
|
|
|
self._notify('NewOutgoingTxByThirdParty', args); |
|
|
|
self._notifyTxProposalAction('NewOutgoingTxByThirdParty', txp, extraArgs); |
|
|
|
} else { |
|
|
|
self._notify('NewOutgoingTx', args); |
|
|
|
self._notifyTxProposalAction('NewOutgoingTx', txp, extraArgs); |
|
|
|
} |
|
|
|
|
|
|
|
self.storage.softResetTxHistoryCache(self.walletId, function() { |
|
|
@ -2369,8 +2376,7 @@ WalletService.prototype.rejectTx = function(opts, cb) { |
|
|
|
async.series([ |
|
|
|
|
|
|
|
function(next) { |
|
|
|
self._notify('TxProposalRejectedBy', { |
|
|
|
txProposalId: opts.txProposalId, |
|
|
|
self._notifyTxProposalAction('TxProposalRejectedBy', txp, { |
|
|
|
copayerId: self.copayerId, |
|
|
|
}, next); |
|
|
|
}, |
|
|
@ -2380,8 +2386,7 @@ WalletService.prototype.rejectTx = function(opts, cb) { |
|
|
|
type: 'reject' |
|
|
|
}), 'copayerId'); |
|
|
|
|
|
|
|
self._notify('TxProposalFinallyRejected', { |
|
|
|
txProposalId: opts.txProposalId, |
|
|
|
self._notifyTxProposalAction('TxProposalFinallyRejected', txp, { |
|
|
|
rejectedBy: rejectedBy, |
|
|
|
}, next); |
|
|
|
} else { |
|
|
|