mirror of https://github.com/BTCPrivate/copay.git
Replace parseBitcoinURI with bitcore implementation
This commit is contained in:
parent
acf2deb87a
commit
b19a0daa64
|
@ -6,8 +6,5 @@ angular.module('copayApp.controllers').controller('HomeController',
|
||||||
controllerUtils.redirIfLogged();
|
controllerUtils.redirIfLogged();
|
||||||
|
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
if ($rootScope.pendingPayment) {
|
|
||||||
notification.info('Login Required', 'Please open wallet to complete payment');
|
|
||||||
}
|
|
||||||
$scope.hasWallets = (walletFactory.getWallets() && walletFactory.getWallets().length > 0) ? true : false;
|
$scope.hasWallets = (walletFactory.getWallets() && walletFactory.getWallets().length > 0) ? true : false;
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
angular.module('copayApp.controllers').controller('OpenController', function($scope, $rootScope, $location, walletFactory, controllerUtils, Passphrase, notification) {
|
angular.module('copayApp.controllers').controller('OpenController', function($scope, $rootScope, $location, walletFactory, controllerUtils, Passphrase, notification) {
|
||||||
controllerUtils.redirIfLogged();
|
controllerUtils.redirIfLogged();
|
||||||
|
|
||||||
|
if ($rootScope.pendingPayment) {
|
||||||
|
notification.info('Login Required', 'Please open wallet to complete payment');
|
||||||
|
}
|
||||||
|
|
||||||
var cmp = function(o1, o2) {
|
var cmp = function(o1, o2) {
|
||||||
var v1 = o1.show.toLowerCase(),
|
var v1 = o1.show.toLowerCase(),
|
||||||
v2 = o2.show.toLowerCase();
|
v2 = o2.show.toLowerCase();
|
||||||
|
|
|
@ -38,9 +38,9 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
if ($rootScope.pendingPayment) {
|
if ($rootScope.pendingPayment) {
|
||||||
var pp = $rootScope.pendingPayment;
|
var pp = $rootScope.pendingPayment;
|
||||||
$scope.address = pp.address;
|
$scope.address = pp.address;
|
||||||
var amount = pp.amount / config.unitToSatoshi * 100000000;
|
var amount = pp.data.amount / config.unitToSatoshi * 100000000;
|
||||||
$scope.amount = amount;
|
$scope.amount = amount;
|
||||||
$scope.commentText = pp.message;
|
$scope.commentText = pp.data.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
|
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
|
||||||
|
@ -261,12 +261,12 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
function onSuccess(result) {
|
function onSuccess(result) {
|
||||||
if (result.cancelled) return;
|
if (result.cancelled) return;
|
||||||
|
|
||||||
debugger;
|
var bip21 = new bitcore.BIP21(result.text);
|
||||||
var bip21 = copay.HDPath.parseBitcoinURI(result.text);
|
$scope.address = bip21.address + '';
|
||||||
$scope.address = bip21.address;
|
$scope.commentText = bip21.data.message;
|
||||||
|
|
||||||
if (bip21.amount) {
|
if (bip21.data.amount) {
|
||||||
$scope.amount = bip21.amount * bitcore.util.COIN * satToUnit;
|
$scope.amount = bip21.data.amount * bitcore.util.COIN * satToUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rootScope.$digest();
|
$rootScope.$digest();
|
||||||
|
|
|
@ -1,16 +1,13 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var bitcore = require('bitcore');
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('UriPaymentController', function($rootScope, $scope, $routeParams, $timeout, $location) {
|
angular.module('copayApp.controllers').controller('UriPaymentController', function($rootScope, $scope, $routeParams, $timeout, $location) {
|
||||||
var data = decodeURIComponent($routeParams.data);
|
var data = decodeURIComponent($routeParams.data);
|
||||||
$rootScope.pendingPayment = copay.HDPath.parseBitcoinURI($routeParams.data);
|
$rootScope.pendingPayment = new bitcore.BIP21($routeParams.data);
|
||||||
|
|
||||||
$scope.protocol = $rootScope.pendingPayment.protocol;
|
|
||||||
$scope.address = $rootScope.pendingPayment.address;
|
|
||||||
$scope.amount = $rootScope.pendingPayment.amount;
|
|
||||||
$scope.message = $rootScope.pendingPayment.message;
|
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$location.path('/');
|
$location.path('/open');
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -76,13 +76,4 @@ describe('HDPath model', function() {
|
||||||
i.isChange.should.equal(result.isChange);
|
i.isChange.should.equal(result.isChange);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('should get the correct result for bitcoin uri', function() {
|
|
||||||
var uri = 'bitcoin:19mP9FKrXqL46Si58pHdhGKow88SUPy1V8%3Famount=0.1&message=a%20bitcoin%20donation';
|
|
||||||
var result = HDPath.parseBitcoinURI(uri);
|
|
||||||
result.address.should.equal('19mP9FKrXqL46Si58pHdhGKow88SUPy1V8');
|
|
||||||
result.amount.should.equal(0.1);
|
|
||||||
result.message.should.equal('a bitcoin donation');
|
|
||||||
result.protocol.should.equal('bitcoin');
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
<h3 class="text-center text-white">
|
|
||||||
Preparing payment...
|
|
||||||
</h3>
|
|
||||||
<div data-ng-init="" data-ng-controller="UriPaymentController">
|
<div data-ng-init="" data-ng-controller="UriPaymentController">
|
||||||
<p>Protocol: {{protocol}}</p>
|
|
||||||
<p>To: {{address}}</p>
|
<div data-alert class="loading-screen">
|
||||||
<p>Amount: {{amount}}</p>
|
<i class="size-60 fi-bitcoin-circle icon-rotate spinner"></i>
|
||||||
<p>Message:</p>
|
Preparing payment...
|
||||||
<div class="alert-box secondary radius">{{message}}</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue