get URI parsing into copay core
This commit is contained in:
parent
8acaca75fb
commit
1b780d268b
2 changed files with 24 additions and 18 deletions
|
|
@ -2,25 +2,12 @@
|
||||||
|
|
||||||
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);
|
||||||
var splitDots = data.split(':');
|
$rootScope.pendingPayment = copay.Structure.parseBitcoinURI($routeParams.data);
|
||||||
$scope.protocol = splitDots[0];
|
|
||||||
data = splitDots[1];
|
|
||||||
var splitQuestion = data.split('?');
|
|
||||||
$scope.address = splitQuestion[0];
|
|
||||||
var search = splitQuestion[1];
|
|
||||||
data = JSON.parse('{"' + search.replace(/&/g, '","').replace(/=/g, '":"') + '"}',
|
|
||||||
function(key, value) {
|
|
||||||
return key === "" ? value : decodeURIComponent(value);
|
|
||||||
});
|
|
||||||
$scope.amount = parseFloat(data.amount);
|
|
||||||
$scope.message = data.message;
|
|
||||||
|
|
||||||
$rootScope.pendingPayment = {
|
$scope.protocol = $rootScope.pendingPayment.protocol;
|
||||||
protocol: $scope.protocol,
|
$scope.address = $rootScope.pendingPayment.address;
|
||||||
address: $scope.address,
|
$scope.amount = $rootScope.pendingPayment.amount;
|
||||||
amount: $scope.amount,
|
$scope.message = $rootScope.pendingPayment.message;
|
||||||
message: $scope.message
|
|
||||||
};
|
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$location.path('signin');
|
$location.path('signin');
|
||||||
|
|
|
||||||
|
|
@ -50,4 +50,23 @@ Structure.MAX_NON_HARDENED = MAX_NON_HARDENED;
|
||||||
Structure.SHARED_INDEX = SHARED_INDEX;
|
Structure.SHARED_INDEX = SHARED_INDEX;
|
||||||
Structure.ID_INDEX = ID_INDEX;
|
Structure.ID_INDEX = ID_INDEX;
|
||||||
|
|
||||||
|
Structure.parseBitcoinURI = function(uri) {
|
||||||
|
var ret = {};
|
||||||
|
var data = decodeURIComponent(uri);
|
||||||
|
var splitDots = data.split(':');
|
||||||
|
ret.protocol = splitDots[0];
|
||||||
|
data = splitDots[1];
|
||||||
|
var splitQuestion = data.split('?');
|
||||||
|
ret.address = splitQuestion[0];
|
||||||
|
var search = splitQuestion[1];
|
||||||
|
data = JSON.parse('{"' + search.replace(/&/g, '","').replace(/=/g, '":"') + '"}',
|
||||||
|
function(key, value) {
|
||||||
|
return key === "" ? value : decodeURIComponent(value);
|
||||||
|
});
|
||||||
|
ret.amount = parseFloat(data.amount);
|
||||||
|
ret.message = data.message;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = require('soop')(Structure);
|
module.exports = require('soop')(Structure);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue