diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index 315a28386..8bbb57e15 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -380,7 +380,7 @@ angular.module('copayApp.services') bitpayAccounts = bitpayAccounts || {}; bitpayAccounts[data.email] = bitpayAccounts[data.email] || {}; bitpayAccounts[data.email]['bitpayDebitCards-' + network] = data.cards; - storage.set('bitpayAccounts-v2-' + network, JSON.stringify(bitpayAccounts), cb); + storage.set('bitpayAccounts-v3-' + network, JSON.stringify(bitpayAccounts), cb); }); }; @@ -539,6 +539,28 @@ angular.module('copayApp.services') }); }; + // account: { + // email: account email + // apiContext: the context needed for making future api calls + // bitpayDebitCards: an array of cards + // } + root.removeBitpayAccount = function(network, account, cb) { + if (lodash.isString(account)) { + account = JSON.parse(account); + } + account = account || {}; + if (lodash.isEmpty(account)) return cb('No account to remove'); + storage.get('bitpayAccounts-v3-' + network, function(err, bitpayAccounts) { + if (err) cb(err); + if (lodash.isString(bitpayAccounts)) { + bitpayAccounts = JSON.parse(bitpayAccounts); + } + bitpayAccounts = bitpayAccounts || {}; + delete bitpayAccounts[account.email]; + storage.set('bitpayAccounts-v3-' + network, JSON.stringify(bitpayAccounts), cb); + }); + }; + root.setAppIdentity = function(network, data, cb) { storage.set('appIdentity-' + network, data, cb); };