2015-09-12 10:44:01 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
angular.module('copayApp.controllers').controller('preferencesInformation',
|
2016-05-31 19:03:24 -03:00
|
|
|
function($scope, $log, $timeout, platformInfo, gettextCatalog, lodash, profileService, storageService, go, bitcore) {
|
2015-10-15 18:18:11 -03:00
|
|
|
var base = 'xpub';
|
2015-10-29 12:10:31 -03:00
|
|
|
var fc = profileService.focusedClient;
|
|
|
|
|
var c = fc.credentials;
|
2015-09-12 10:44:01 -03:00
|
|
|
|
2015-10-15 18:18:11 -03:00
|
|
|
this.init = function() {
|
2015-12-02 15:34:34 -03:00
|
|
|
var basePath = c.getBaseAddressDerivationPath();
|
2015-10-20 18:11:07 -03:00
|
|
|
|
|
|
|
|
$scope.walletName = c.walletName;
|
|
|
|
|
$scope.walletId = c.walletId;
|
|
|
|
|
$scope.network = c.network;
|
|
|
|
|
$scope.addressType = c.addressType || 'P2SH';
|
|
|
|
|
$scope.derivationStrategy = c.derivationStrategy || 'BIP45';
|
|
|
|
|
$scope.basePath = basePath;
|
|
|
|
|
$scope.M = c.m;
|
|
|
|
|
$scope.N = c.n;
|
|
|
|
|
$scope.pubKeys = lodash.pluck(c.publicKeyRing, 'xPubKey');
|
|
|
|
|
$scope.addrs = null;
|
|
|
|
|
|
|
|
|
|
fc.getMainAddresses({
|
|
|
|
|
doNotVerify: true
|
|
|
|
|
}, function(err, addrs) {
|
|
|
|
|
if (err) {
|
|
|
|
|
$log.warn(err);
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
var last10 = [],
|
2015-10-29 12:10:31 -03:00
|
|
|
i = 0,
|
|
|
|
|
e = addrs.pop();
|
2015-10-20 18:11:07 -03:00
|
|
|
while (i++ < 10 && e) {
|
|
|
|
|
e.path = base + e.path.substring(1);
|
|
|
|
|
last10.push(e);
|
|
|
|
|
e = addrs.pop();
|
|
|
|
|
}
|
|
|
|
|
$scope.addrs = last10;
|
|
|
|
|
$timeout(function() {
|
|
|
|
|
$scope.$apply();
|
|
|
|
|
});
|
2015-09-14 16:32:12 -03:00
|
|
|
|
2015-10-20 18:11:07 -03:00
|
|
|
});
|
2015-10-15 18:18:11 -03:00
|
|
|
};
|
2015-09-12 10:44:01 -03:00
|
|
|
|
|
|
|
|
this.sendAddrs = function() {
|
2015-10-15 18:18:11 -03:00
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
self.loading = true;
|
2015-09-12 10:44:01 -03:00
|
|
|
|
|
|
|
|
function formatDate(ts) {
|
|
|
|
|
var dateObj = new Date(ts * 1000);
|
|
|
|
|
if (!dateObj) {
|
|
|
|
|
$log.debug('Error formating a date');
|
|
|
|
|
return 'DateError';
|
|
|
|
|
}
|
|
|
|
|
if (!dateObj.toJSON()) {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
return dateObj.toJSON();
|
|
|
|
|
};
|
|
|
|
|
|
2015-10-15 18:18:11 -03:00
|
|
|
$timeout(function() {
|
|
|
|
|
fc.getMainAddresses({
|
|
|
|
|
doNotVerify: true
|
|
|
|
|
}, function(err, addrs) {
|
|
|
|
|
self.loading = false;
|
|
|
|
|
if (err) {
|
|
|
|
|
$log.warn(err);
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var body = 'Copay Wallet "' + $scope.walletName + '" Addresses\n Only Main Addresses are shown.\n\n';
|
|
|
|
|
body += "\n";
|
|
|
|
|
body += addrs.map(function(v) {
|
|
|
|
|
return ('* ' + v.address + ' ' + base + v.path.substring(1) + ' ' + formatDate(v.createdOn));
|
|
|
|
|
}).join("\n");
|
2015-09-12 10:44:01 -03:00
|
|
|
|
2016-04-15 10:26:51 -03:00
|
|
|
window.plugins.socialsharing.shareViaEmail(
|
|
|
|
|
body,
|
|
|
|
|
'Copay Addresses',
|
|
|
|
|
null, // TO: must be null or an array
|
|
|
|
|
null, // CC: must be null or an array
|
|
|
|
|
null, // BCC: must be null or an array
|
|
|
|
|
null, // FILES: can be null, a string, or an array
|
|
|
|
|
function() {},
|
|
|
|
|
function() {}
|
|
|
|
|
);
|
2015-09-12 10:44:01 -03:00
|
|
|
|
2015-10-15 18:18:11 -03:00
|
|
|
$timeout(function() {
|
|
|
|
|
$scope.$apply();
|
|
|
|
|
}, 1000);
|
|
|
|
|
});
|
|
|
|
|
}, 100);
|
2015-09-12 10:44:01 -03:00
|
|
|
};
|
2015-10-29 12:10:31 -03:00
|
|
|
|
2015-09-12 10:44:01 -03:00
|
|
|
});
|