got receive bitcoin event working
This commit is contained in:
parent
0678e58ab7
commit
6e425dd815
2 changed files with 47 additions and 1 deletions
|
|
@ -622,5 +622,17 @@ angular.module('copayApp.services')
|
|||
storage.remove('MercadoLibreGiftCards-' + network, cb);
|
||||
};
|
||||
|
||||
root.setReceivedTransactions = function(walletId, txIds, cb) {
|
||||
storage.set('receivedTxs-' + walletId, txIds, cb);
|
||||
}
|
||||
|
||||
root.getReceivedTransactions = function(walletId, cb) {
|
||||
storage.get('receivedTxs-' + walletId, cb);
|
||||
}
|
||||
|
||||
root.removeReceivedTransactions = function(walletId, cb) {
|
||||
storage.remove('receivedTxs-' + walletId, cb);
|
||||
}
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, intelTEE, storageService, configService, rateService, uxLanguage, $filter, gettextCatalog, bwcError, $ionicPopup, fingerprintService, ongoingProcess, gettext, $rootScope, txFormatService, $ionicModal, $state, bwcService, bitcore, popupService) {
|
||||
angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, intelTEE, storageService, configService, rateService, uxLanguage, $filter, gettextCatalog, bwcError, $ionicPopup, fingerprintService, ongoingProcess, gettext, $rootScope, txFormatService, $ionicModal, $state, bwcService, bitcore, popupService, firebaseEventsService) {
|
||||
|
||||
// Ratio low amount warning (fee/amount) in incoming TX
|
||||
var LOW_AMOUNT_RATIO = 0.15;
|
||||
|
|
@ -488,9 +488,43 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
});
|
||||
};
|
||||
|
||||
function createReceivedEvents(newTxs) {
|
||||
storageService.getReceivedTransactions(walletId, function(err, txIds) {
|
||||
if (!txIds) {
|
||||
txIds = [];
|
||||
} else {
|
||||
txIds = JSON.parse(txIds);
|
||||
}
|
||||
|
||||
var newReceived = lodash.filter(newTxs, function(t) {
|
||||
return t.action === 'received';
|
||||
});
|
||||
|
||||
var newReceivedTxIds = lodash.map(newReceived, function(t) {
|
||||
return t.txid;
|
||||
});
|
||||
|
||||
var notInStorage = lodash.filter(newReceivedTxIds, function(t) {
|
||||
return !lodash.includes(txIds, t);
|
||||
});
|
||||
|
||||
lodash.each(notInStorage, function(t) {
|
||||
firebaseEventsService.logEvent('received_bitcoin', { coin: wallet.coin });
|
||||
});
|
||||
|
||||
var receivedTransactions = txIds.concat(notInStorage);
|
||||
|
||||
storageService.setReceivedTransactions(walletId, receivedTransactions, function() {
|
||||
$log.debug('Received transactions saved');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getNewTxs([], 0, function(err, txs) {
|
||||
if (err) return cb(err);
|
||||
|
||||
createReceivedEvents(txs);
|
||||
|
||||
var newHistory = lodash.uniq(lodash.compact(txs.concat(confirmedTxs)), function(x) {
|
||||
return x.txid;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue