rebase
This commit is contained in:
parent
8759b633fb
commit
dd382de0dd
5 changed files with 10 additions and 238 deletions
|
|
@ -1,12 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('disclaimerController',
|
||||
<<<<<<< e68d1d87ec5d6c817929721a32f43cefc88aa290
|
||||
function($scope, $timeout, $log, profileService, applicationService, gettextCatalog, uxLanguage, go) {
|
||||
=======
|
||||
function($scope, $timeout, $log, $ionicSideMenuDelegate, profileService, isCordova, applicationService, gettextCatalog, uxLanguage, go) {
|
||||
|
||||
>>>>>>> do not allow drag side bar in disclaimer screen
|
||||
function($scope, $timeout, $log, $ionicSideMenuDelegate, profileService, applicationService, gettextCatalog, uxLanguage, go) {
|
||||
var self = this;
|
||||
self.tries = 0;
|
||||
$scope.creatingProfile = true;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('customAmountController', function($scope, $timeout, $filter, isCordova, isMobile, rateService) {
|
||||
angular.module('copayApp.controllers').controller('customAmountController', function($scope, $timeout, $filter, platformInfo, rateService) {
|
||||
var self = $scope.self;
|
||||
|
||||
$scope.unitName = self.unitName;
|
||||
|
|
@ -12,7 +12,7 @@ angular.module('copayApp.controllers').controller('customAmountController', func
|
|||
$scope.unitDecimals = self.unitDecimals;
|
||||
var satToUnit = 1 / self.unitToSatoshi;
|
||||
$scope.showAlternative = false;
|
||||
$scope.isCordova = isCordova;
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
|
||||
Object.defineProperty($scope,
|
||||
"_customAlternative", {
|
||||
|
|
@ -68,8 +68,8 @@ angular.module('copayApp.controllers').controller('customAmountController', func
|
|||
};
|
||||
|
||||
$scope.shareAddress = function(uri) {
|
||||
if (isCordova) {
|
||||
if (isMobile.Android() || isMobile.Windows()) {
|
||||
if (platformInfo.isCordova) {
|
||||
if (platformInfo.isAndroid || platformInfo.isWP) {
|
||||
window.ignoreMobilePause = true;
|
||||
}
|
||||
window.plugins.socialsharing.share(uri, null, null, null);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, txStatus, $ionicScrollDelegate, txFormatService, fingerprintService, bwsError, isChromeApp, gettextCatalog, lodash, profileService, walletService) {
|
||||
angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, platformInfo, txStatus, $ionicScrollDelegate, txFormatService, fingerprintService, bwsError, gettextCatalog, lodash, profileService, walletService) {
|
||||
var self = $scope.self;
|
||||
var tx = $scope.tx;
|
||||
var copayers = $scope.copayers;
|
||||
|
|
@ -131,7 +131,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
|||
};
|
||||
|
||||
function checkPaypro() {
|
||||
if (tx.payProUrl && !isChromeApp) {
|
||||
if (tx.payProUrl && !platformInfo.isChromeApp) {
|
||||
fc.fetchPayPro({
|
||||
payProUrl: tx.payProUrl,
|
||||
}, function(err, paypro) {
|
||||
|
|
|
|||
|
|
@ -931,226 +931,3 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
}
|
||||
|
||||
});
|
||||
out(function() {
|
||||
$rootScope.$digest();
|
||||
}, 1);
|
||||
return cb(true);
|
||||
}
|
||||
|
||||
self._paypro = paypro;
|
||||
self.setForm(paypro.toAddress, (paypro.amount * satToUnit).toFixed(self.unitDecimals), paypro.memo);
|
||||
_paymentTimeControl(paypro.expires);
|
||||
return cb();
|
||||
});
|
||||
}, 1);
|
||||
};
|
||||
|
||||
function _paymentTimeControl(expirationTime) {
|
||||
self.paymentExpired = false;
|
||||
setExpirationTime();
|
||||
|
||||
self.countDown = $interval(function() {
|
||||
setExpirationTime();
|
||||
}, 1000);
|
||||
|
||||
function setExpirationTime() {
|
||||
var now = Math.floor(Date.now() / 1000);
|
||||
if (now > expirationTime) {
|
||||
setExpiredValues();
|
||||
return;
|
||||
}
|
||||
|
||||
var totalSecs = expirationTime - now;
|
||||
var m = Math.floor(totalSecs / 60);
|
||||
var s = totalSecs % 60;
|
||||
self.remainingTimeStr = ('0' + m).slice(-2) + ":" + ('0' + s).slice(-2);
|
||||
};
|
||||
|
||||
function setExpiredValues() {
|
||||
self.paymentExpired = true;
|
||||
self.remainingTimeStr = null;
|
||||
self._paypro = null;
|
||||
self.error = gettext('Cannot sign: The payment request has expired');
|
||||
if (self.countDown) $interval.cancel(self.countDown);
|
||||
};
|
||||
};
|
||||
|
||||
this.setFromUri = function(uri) {
|
||||
var self = this;
|
||||
|
||||
function sanitizeUri(uri) {
|
||||
// Fixes when a region uses comma to separate decimals
|
||||
var regex = /[\?\&]amount=(\d+([\,\.]\d+)?)/i;
|
||||
var match = regex.exec(uri);
|
||||
if (!match || match.length === 0) {
|
||||
return uri;
|
||||
}
|
||||
var value = match[0].replace(',', '.');
|
||||
var newUri = uri.replace(regex, value);
|
||||
return newUri;
|
||||
};
|
||||
|
||||
var satToUnit = 1 / this.unitToSatoshi;
|
||||
|
||||
// URI extensions for Payment Protocol with non-backwards-compatible request
|
||||
if ((/^bitcoin:\?r=[\w+]/).exec(uri)) {
|
||||
uri = decodeURIComponent(uri.replace('bitcoin:?r=', ''));
|
||||
this.setFromPayPro(uri, function(err) {
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
uri = sanitizeUri(uri);
|
||||
|
||||
if (!bitcore.URI.isValid(uri)) {
|
||||
return uri;
|
||||
}
|
||||
var parsed = new bitcore.URI(uri);
|
||||
|
||||
var addr = parsed.address ? parsed.address.toString() : '';
|
||||
var message = parsed.message;
|
||||
|
||||
var amount = parsed.amount ?
|
||||
(parsed.amount.toFixed(0) * satToUnit).toFixed(this.unitDecimals) : 0;
|
||||
|
||||
|
||||
if (parsed.r) {
|
||||
this.setFromPayPro(parsed.r, function(err) {
|
||||
if (err && addr && amount) {
|
||||
self.setForm(addr, amount, message);
|
||||
return addr;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.setForm(addr, amount, message);
|
||||
return addr;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.onAddressChange = function(value) {
|
||||
this.resetError();
|
||||
if (!value) return '';
|
||||
|
||||
if (this._paypro)
|
||||
return value;
|
||||
|
||||
if (value.indexOf('bitcoin:') === 0) {
|
||||
return this.setFromUri(value);
|
||||
} else if (/^https?:\/\//.test(value)) {
|
||||
return this.setFromPayPro(value);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
// History
|
||||
|
||||
function strip(number) {
|
||||
return (parseFloat(number.toPrecision(12)));
|
||||
}
|
||||
|
||||
this.getUnitName = function() {
|
||||
return this.unitName;
|
||||
};
|
||||
|
||||
this.getAlternativeIsoCode = function() {
|
||||
return this.alternativeIsoCode;
|
||||
};
|
||||
|
||||
this.openTxModal = function(tx) {
|
||||
$rootScope.$emit('Local/TxModal', tx);
|
||||
};
|
||||
|
||||
this.hasAction = function(actions, action) {
|
||||
return actions.hasOwnProperty('create');
|
||||
};
|
||||
|
||||
this.sendMax = function(availableBalanceSat) {
|
||||
if (availableBalanceSat == 0) {
|
||||
this.error = gettext("Cannot create transaction. Insufficient funds");
|
||||
return;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
var fc = profileService.focusedClient;
|
||||
this.error = null;
|
||||
this.setOngoingProcess(gettextCatalog.getString('Calculating fee'));
|
||||
|
||||
feeService.getCurrentFeeValue(function(err, feePerKb) {
|
||||
if (err || !lodash.isNumber(feePerKb)) {
|
||||
self.setOngoingProcess();
|
||||
self.error = gettext('Could not get fee value');
|
||||
return;
|
||||
}
|
||||
|
||||
var opts = {};
|
||||
opts.feePerKb = feePerKb;
|
||||
opts.returnInputs = true;
|
||||
var config = configService.getSync();
|
||||
opts.excludeUnconfirmedUtxos = !config.wallet.spendUnconfirmed;
|
||||
self.setOngoingProcess(gettextCatalog.getString('Retrieving inputs information'));
|
||||
|
||||
fc.getSendMaxInfo(opts, function(err, resp) {
|
||||
self.setOngoingProcess();
|
||||
if (err) {
|
||||
self.error = err;
|
||||
$scope.$apply();
|
||||
return;
|
||||
}
|
||||
|
||||
if (resp.amount == 0) {
|
||||
self.error = gettext("Not enough funds for fee");
|
||||
$scope.$apply();
|
||||
return;
|
||||
}
|
||||
|
||||
var msg = gettextCatalog.getString("{{fee}} will be deducted for bitcoin networking fees", {
|
||||
fee: profileService.formatAmount(resp.fee) + ' ' + self.unitName
|
||||
});
|
||||
|
||||
var warningMsg = verifyExcludedUtxos();
|
||||
|
||||
if (!lodash.isEmpty(warningMsg))
|
||||
msg += '. \n' + warningMsg;
|
||||
|
||||
confirmDialog.show(msg, function(confirmed) {
|
||||
if (confirmed) {
|
||||
self.sendMaxInfo = resp;
|
||||
var amount = parseFloat((resp.amount * self.satToUnit).toFixed(self.unitDecimals));
|
||||
self.setForm(null, amount, null);
|
||||
} else {
|
||||
self.resetForm();
|
||||
}
|
||||
});
|
||||
|
||||
function verifyExcludedUtxos() {
|
||||
var warningMsg = [];
|
||||
if (resp.utxosBelowFee > 0) {
|
||||
warningMsg.push(gettextCatalog.getString("Note: a total of {{amountBelowFeeStr}} were excluded. These funds come from UTXOs smaller than the network fee provided.", {
|
||||
amountBelowFeeStr: profileService.formatAmount(resp.amountBelowFee) + ' ' + self.unitName
|
||||
}));
|
||||
}
|
||||
if (resp.utxosAboveMaxSize > 0) {
|
||||
warningMsg.push(gettextCatalog.getString("Note: a total of {{amountAboveMaxSizeStr}} were excluded. The maximum size allowed for a transaction was exceeded", {
|
||||
amountAboveMaxSizeStr: profileService.formatAmount(resp.amountAboveMaxSize) + ' ' + self.unitName
|
||||
}));
|
||||
}
|
||||
return warningMsg.join('\n');
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/* Start setup */
|
||||
lodash.assign(self, vanillaScope);
|
||||
|
||||
this.bindTouchDown();
|
||||
if (profileService.focusedClient) {
|
||||
this.setAddress();
|
||||
this.setSendFormInputs();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@ angular
|
|||
$urlRouterProvider.otherwise('/');
|
||||
|
||||
$logProvider.debugEnabled(true);
|
||||
$provide.decorator('$log', ['$delegate', 'isDevel',
|
||||
function($delegate, isDevel) {
|
||||
$provide.decorator('$log', ['$delegate', 'platformInfo',
|
||||
function($delegate, platformInfo) {
|
||||
var historicLog = historicLogProvider.$get();
|
||||
|
||||
['debug', 'info', 'warn', 'error', 'log'].forEach(function(level) {
|
||||
if (isDevel && level == 'error') return;
|
||||
if (platformInfo.isDevel && level == 'error') return;
|
||||
|
||||
var orig = $delegate[level];
|
||||
$delegate[level] = function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue