mirror of https://github.com/BTCPrivate/copay.git
Trying to fix bip72
This commit is contained in:
parent
6d72d00b99
commit
92737bc49c
|
@ -2,27 +2,12 @@
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('PaymentIntentController', function($rootScope, $scope, $modal, $location, balanceService) {
|
angular.module('copayApp.controllers').controller('PaymentIntentController', function($rootScope, $scope, $modal, $location, balanceService) {
|
||||||
|
|
||||||
$scope.wallets = [];
|
$rootScope.title = 'Payment intent';
|
||||||
$rootScope.title = 'Payment intent';
|
|
||||||
$scope.wallets = $rootScope.iden.listWallets();
|
|
||||||
|
|
||||||
var l = $scope.wallet.length;
|
$scope.open = function() {
|
||||||
_.each($scope.wallets, function(w, i) {
|
|
||||||
balanceService.update(w, function(){
|
|
||||||
if (i === l-1)
|
|
||||||
$rootScope.$digest();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.open = function() {
|
|
||||||
var modalInstance = $modal.open({
|
var modalInstance = $modal.open({
|
||||||
templateUrl: 'myModalContent.html',
|
templateUrl: 'myModalContent.html',
|
||||||
controller: ModalInstanceCtrl,
|
controller: ModalInstanceCtrl
|
||||||
resolve: {
|
|
||||||
items: function() {
|
|
||||||
return $scope.wallets;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,8 +15,22 @@ angular.module('copayApp.controllers').controller('PaymentIntentController', fun
|
||||||
// Please note that $modalInstance represents a modal window (instance) dependency.
|
// Please note that $modalInstance represents a modal window (instance) dependency.
|
||||||
// It is not the same as the $modal service used above.
|
// It is not the same as the $modal service used above.
|
||||||
|
|
||||||
var ModalInstanceCtrl = function($scope, $modalInstance, items, identityService) {
|
var ModalInstanceCtrl = function($scope, $modalInstance, identityService) {
|
||||||
$scope.wallets = items;
|
$scope.loading = true;
|
||||||
|
$scope.setWallets = function() {
|
||||||
|
if (!$rootScope.iden) return;
|
||||||
|
var ret = _.filter($rootScope.iden.listWallets(), function(w) {
|
||||||
|
return w.balanceInfo && w.balanceInfo.totalBalanceBTC;
|
||||||
|
});
|
||||||
|
$scope.wallets = ret;
|
||||||
|
$scope.loading = false;
|
||||||
|
};
|
||||||
|
if ($rootScope.iden) {
|
||||||
|
var iden = $rootScope.iden;
|
||||||
|
iden.on('newWallet', function() {
|
||||||
|
$scope.setWallets();
|
||||||
|
});
|
||||||
|
}
|
||||||
$scope.ok = function(selectedItem) {
|
$scope.ok = function(selectedItem) {
|
||||||
identityService.setPaymentWallet(selectedItem);
|
identityService.setPaymentWallet(selectedItem);
|
||||||
$modalInstance.close();
|
$modalInstance.close();
|
||||||
|
|
|
@ -11,10 +11,10 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
$rootScope.title = 'Send';
|
$rootScope.title = 'Send';
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
$scope.error = $scope.success = null;
|
$scope.error = $scope.success = null;
|
||||||
var satToUnit = 1 / w.settings.unitToSatoshi;
|
var unitToSatoshi = w.settings.unitToSatoshi;
|
||||||
|
var satToUnit = 1 / unitToSatoshi;
|
||||||
$scope.defaultFee = bitcore.TransactionBuilder.FEE_PER_1000B_SAT * satToUnit;
|
$scope.defaultFee = bitcore.TransactionBuilder.FEE_PER_1000B_SAT * satToUnit;
|
||||||
$scope.unitToBtc = w.settings.unitToSatoshi / bitcore.util.COIN;
|
$scope.unitToBtc = unitToSatoshi / bitcore.util.COIN;
|
||||||
$scope.unitToSatoshi = w.settings.unitToSatoshi;
|
|
||||||
|
|
||||||
$scope.alternativeName = w.settings.alternativeName;
|
$scope.alternativeName = w.settings.alternativeName;
|
||||||
$scope.alternativeIsoCode = w.settings.alternativeIsoCode;
|
$scope.alternativeIsoCode = w.settings.alternativeIsoCode;
|
||||||
|
@ -33,9 +33,9 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
$scope.setAlternativeAmount = function(w, tx, cb) {
|
$scope.setAlternativeAmount = function(w, tx, cb) {
|
||||||
rateService.whenAvailable(function() {
|
rateService.whenAvailable(function() {
|
||||||
_.each(tx.outs, function(out) {
|
_.each(tx.outs, function(out) {
|
||||||
var valueSat = out.value * w.settings.unitToSatoshi;
|
var valueSat = out.value * unitToSatoshi;
|
||||||
out.alternativeAmount = rateService.toFiat(valueSat, w.settings.alternativeIsoCode);
|
out.alternativeAmount = rateService.toFiat(valueSat, $scope.alternativeIsoCode);
|
||||||
out.alternativeIsoCode = w.settings.alternativeIsoCode;
|
out.alternativeIsoCode = $scope.alternativeIsoCode;
|
||||||
});
|
});
|
||||||
if (cb) return cb(tx);
|
if (cb) return cb(tx);
|
||||||
});
|
});
|
||||||
|
@ -78,7 +78,7 @@ console.log('[send.js.44:updateTxs:]'); //TODO
|
||||||
this._alternative = newValue;
|
this._alternative = newValue;
|
||||||
if (typeof(newValue) === 'number' && $scope.isRateAvailable) {
|
if (typeof(newValue) === 'number' && $scope.isRateAvailable) {
|
||||||
this._amount = parseFloat(
|
this._amount = parseFloat(
|
||||||
(rateService.fromFiat(newValue, w.settings.alternativeIsoCode) * satToUnit).toFixed(w.settings.unitDecimals), 10);
|
(rateService.fromFiat(newValue, $scope.alternativeIsoCode) * satToUnit).toFixed(w.settings.unitDecimals), 10);
|
||||||
} else {
|
} else {
|
||||||
this._amount = 0;
|
this._amount = 0;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ console.log('[send.js.44:updateTxs:]'); //TODO
|
||||||
if (typeof(newValue) === 'number' && $scope.isRateAvailable) {
|
if (typeof(newValue) === 'number' && $scope.isRateAvailable) {
|
||||||
|
|
||||||
this._alternative = parseFloat(
|
this._alternative = parseFloat(
|
||||||
(rateService.toFiat(newValue * w.settings.unitToSatoshi, w.settings.alternativeIsoCode)).toFixed(2), 10);
|
(rateService.toFiat(newValue * unitToSatoshi, $scope.alternativeIsoCode)).toFixed(2), 10);
|
||||||
} else {
|
} else {
|
||||||
this._alternative = 0;
|
this._alternative = 0;
|
||||||
}
|
}
|
||||||
|
@ -124,12 +124,19 @@ console.log('[send.js.44:updateTxs:]'); //TODO
|
||||||
|
|
||||||
if ($rootScope.pendingPayment) {
|
if ($rootScope.pendingPayment) {
|
||||||
var pp = $rootScope.pendingPayment;
|
var pp = $rootScope.pendingPayment;
|
||||||
$scope.address = pp.address + '';
|
var amount = pp.data.amount * 100000000 * satToUnit;
|
||||||
var amount = pp.data.amount / w.settings.unitToSatoshi * 100000000;
|
var alternativeAmountPayPro = rateService.toFiat((amount + $scope.defaultFee) * unitToSatoshi, $scope.alternativeIsoCode);
|
||||||
$scope.amount = $filter('noFractionNumber')(amount);
|
if (pp.data.merchant) {
|
||||||
var alternativeAmount = rateService.toFiat((amount + defaultFee) * unitToSatoshi, alternativeIsoCode);
|
$scope.address = 'bitcoin:' + pp.address.data + '?amount=' + amount + '&r=' + pp.data.r;
|
||||||
$scope.alternativeAmountPayPro = $filter('noFractionNumber')(alternativeAmount, 2);
|
}
|
||||||
|
else {
|
||||||
|
$scope.address = pp.address + '';
|
||||||
|
$scope.amount = amount;
|
||||||
|
$scope.alternative = alternativeAmountPayPro;
|
||||||
|
}
|
||||||
|
$scope.alternativeAmountPayPro = $filter('noFractionNumber')(alternativeAmountPayPro, 2);
|
||||||
$scope.commentText = pp.data.message;
|
$scope.commentText = pp.data.message;
|
||||||
|
$scope.onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
|
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
|
||||||
|
@ -165,7 +172,7 @@ console.log('[send.js.44:updateTxs:]'); //TODO
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
|
|
||||||
var address = form.address.$modelValue;
|
var address = form.address.$modelValue;
|
||||||
var amount = parseInt((form.amount.$modelValue * w.settings.unitToSatoshi).toFixed(0));
|
var amount = parseInt((form.amount.$modelValue * unitToSatoshi).toFixed(0));
|
||||||
var commentText = form.comment.$modelValue;
|
var commentText = form.comment.$modelValue;
|
||||||
|
|
||||||
|
|
||||||
|
@ -539,7 +546,7 @@ console.log('[send.js.44:updateTxs:]'); //TODO
|
||||||
apply();
|
apply();
|
||||||
|
|
||||||
var balance = $rootScope.availableBalance;
|
var balance = $rootScope.availableBalance;
|
||||||
var available = +(balance * w.settings.unitToSatoshi).toFixed(0);
|
var available = +(balance * unitToSatoshi).toFixed(0);
|
||||||
if (merchantData && available < +merchantData.total) {
|
if (merchantData && available < +merchantData.total) {
|
||||||
err = new Error('Insufficient funds.');
|
err = new Error('Insufficient funds.');
|
||||||
err.amount = merchantData.total;
|
err.amount = merchantData.total;
|
||||||
|
@ -547,7 +554,7 @@ console.log('[send.js.44:updateTxs:]'); //TODO
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err.amount) {
|
if (err.amount) {
|
||||||
$scope.sendForm.amount.$setViewValue(+err.amount / w.settings.unitToSatoshi);
|
$scope.sendForm.amount.$setViewValue(+err.amount / unitToSatoshi);
|
||||||
$scope.sendForm.amount.$render();
|
$scope.sendForm.amount.$render();
|
||||||
$scope.sendForm.amount.$isValid = false;
|
$scope.sendForm.amount.$isValid = false;
|
||||||
$scope.notEnoughAmount = true;
|
$scope.notEnoughAmount = true;
|
||||||
|
@ -578,7 +585,7 @@ console.log('[send.js.44:updateTxs:]'); //TODO
|
||||||
var url = merchantData.request_url;
|
var url = merchantData.request_url;
|
||||||
var domain = /^(?:https?)?:\/\/([^\/:]+).*$/.exec(url)[1];
|
var domain = /^(?:https?)?:\/\/([^\/:]+).*$/.exec(url)[1];
|
||||||
|
|
||||||
merchantData.unitTotal = (+merchantData.total / w.settings.unitToSatoshi) + '';
|
merchantData.unitTotal = (+merchantData.total / unitToSatoshi) + '';
|
||||||
merchantData.expiration = new Date(
|
merchantData.expiration = new Date(
|
||||||
merchantData.pr.pd.expires * 1000);
|
merchantData.pr.pd.expires * 1000);
|
||||||
merchantData.domain = domain;
|
merchantData.domain = domain;
|
||||||
|
|
|
@ -629,7 +629,7 @@ Wallet.prototype._onAddressBook = function(senderId, data) {
|
||||||
var self = this,
|
var self = this,
|
||||||
hasChange;
|
hasChange;
|
||||||
_.each(data.addressBook, function(value, key) {
|
_.each(data.addressBook, function(value, key) {
|
||||||
if (!self.addressBook[key] && Address.validate(key)) {
|
if (key && !self.addressBook[key] && Address.validate(key)) {
|
||||||
|
|
||||||
self.addressBook[key] = _.pick(value, ['createdTs', 'label']);
|
self.addressBook[key] = _.pick(value, ['createdTs', 'label']);
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,13 @@
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<span class="size-21">
|
<span class="size-21">
|
||||||
<strong>
|
<strong>
|
||||||
<span ng-if="!$root.updatingBalance">{{$root.wallet.balanceInfo.totalBalance || 0 |noFractionNumber}}</span>
|
<span ng-if="!$root.updatingBalance">{{$root.wallet.balanceInfo.totalBalance || 0}}</span>
|
||||||
<span ng-if="$root.updatingBalance"><i class="fi-bitcoin-circle icon-rotate spinner"></i></span>
|
<span ng-if="$root.updatingBalance"><i class="fi-bitcoin-circle icon-rotate spinner"></i></span>
|
||||||
{{$root.wallet.settings.unitName}}
|
{{$root.wallet.settings.unitName}}
|
||||||
</strong>
|
</strong>
|
||||||
</span>
|
</span>
|
||||||
<span class="size-14 db m5t text-gray">
|
<span class="size-14 db m5t text-gray">
|
||||||
<span ng-if="!$root.wallet.balanceInfo.updatingBalance && alternativeBalanceAvailable">{{$root.wallet.balanceInfo.totalBalanceAlternative |noFractionNumber:2}} {{$root.wallet.balanceInfo.alternativeIsoCode}}</span>
|
<span ng-if="!$root.wallet.balanceInfo.updatingBalance && $root.wallet.balanceInfo.alternativeBalanceAvailable">{{$root.wallet.balanceInfo.totalBalanceAlternative}} {{$root.wallet.balanceInfo.alternativeIsoCode}}</span>
|
||||||
<span ng-if="!$root.wallet.balanceInfo.updatingBalance && !$root.wallet.balanceInfo.alternativeBalanceAvailable">N/A</span>
|
<span ng-if="!$root.wallet.balanceInfo.updatingBalance && !$root.wallet.balanceInfo.alternativeBalanceAvailable">N/A</span>
|
||||||
<span ng-if="$root.wallet.balanceInfo.updatingBalance"><i class="fi-bitcoin-circle icon-rotate spinner"></i></span>
|
<span ng-if="$root.wallet.balanceInfo.updatingBalance"><i class="fi-bitcoin-circle icon-rotate spinner"></i></span>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
|
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
|
||||||
</span>
|
</span>
|
||||||
<span ng-show="!$root.updatingBalance">
|
<span ng-show="!$root.updatingBalance">
|
||||||
{{address.balance || 0|noFractionNumber}} {{$root.wallet.settings.unitName}}
|
{{address.balance || 0}} {{$root.wallet.settings.unitName}}
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<div ng-controller="PaymentIntentController" ng-init="open()">
|
<div ng-controller="PaymentIntentController" ng-init="open()">
|
||||||
<script type="text/ng-template" id="myModalContent.html">
|
<script type="text/ng-template" id="myModalContent.html">
|
||||||
<h3>Select a wallet to make the payment</h3>
|
<h3>Select a wallet to make the payment</h3>
|
||||||
|
<span ng-show="loading">Loading...</span>
|
||||||
<ul class="w-popup-menu" ng-show="wallets[0]"
|
<ul class="w-popup-menu" ng-show="wallets[0]"
|
||||||
ng-class="{'large':wallets.length > 4, 'medium':wallets.length > 2 && wallets.length < 5}">
|
ng-class="{'large':wallets.length > 4, 'medium':wallets.length > 2 && wallets.length < 5}">
|
||||||
<li data-ng-repeat="item in wallets track by $index" class="nav-item" ng-click="ok(item)">
|
<li data-ng-repeat="item in wallets track by $index" class="nav-item" ng-click="ok(item)">
|
||||||
|
|
|
@ -67,7 +67,7 @@
|
||||||
<td>
|
<td>
|
||||||
<span ng-if="!isComplete">-</span>
|
<span ng-if="!isComplete">-</span>
|
||||||
<span ng-if="isComplete">
|
<span ng-if="isComplete">
|
||||||
{{item.balanceInfo.totalBalance || 0 |noFractionNumber}} {{item.settings.unitName}}
|
{{item.balanceInfo.totalBalance || 0}} {{item.settings.unitName}}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
|
@ -108,7 +108,7 @@
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<input type="number" id="alternative_amount"
|
<input type="number" id="alternative_amount"
|
||||||
ng-disabled="loading || !isRateAvailable || ($root.merchant && +$root.merchant.total > 0)"
|
ng-disabled="loading || !isRateAvailable || ($root.merchant && +$root.merchant.total > 0)"
|
||||||
name="alternative" placeholder="{{'Amount'|translate}}" ng-model="alternative"requiredautocomplete="off">
|
name="alternative" placeholder="{{'Amount'|translate}}" ng-model="alternative" requiredautocomplete="off">
|
||||||
<i class="icon-usd"></i>
|
<i class="icon-usd"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue