Merge pull request #1130 from chjj/fix_bip21_calls

wallet: fix bip21 calls. fixes #1128.
This commit is contained in:
Matias Alejo Garcia 2014-08-19 15:13:32 -04:00
commit e4cac6d5dc
1 changed files with 14 additions and 9 deletions

View File

@ -113,10 +113,6 @@ angular.module('copayApp.controllers').controller('SendController',
var uri; var uri;
if (address.indexOf('bitcoin:') === 0) { if (address.indexOf('bitcoin:') === 0) {
uri = new bitcore.BIP21(address).data; uri = new bitcore.BIP21(address).data;
} else if (address.indexOf('Merchant: ') === 0) {
uri = {
merchant: address.split(/\s+/)[1]
};
} else if (/^https?:\/\//.test(address)) { } else if (/^https?:\/\//.test(address)) {
uri = { uri = {
merchant: address merchant: address
@ -403,19 +399,21 @@ angular.module('copayApp.controllers').controller('SendController',
$scope.onChanged = function() { $scope.onChanged = function() {
var scope = $scope; var scope = $scope;
var value = scope.address; var value = scope.address || '';
var uri; var uri;
if (/^https?:\/\//.test(value)) { if (value.indexOf('bitcoin:') === 0) {
uri = new bitcore.BIP21(value).data;
} else if (/^https?:\/\//.test(value)) {
uri = { uri = {
merchant: value merchant: value
}; };
} else {
uri = new bitcore.BIP21(value).data;
} }
if (!uri || !uri.merchant) { if (!uri || !uri.merchant) {
return; return;
} }
notification.info('Fetching Payment', notification.info('Fetching Payment',
'Retrieving Payment Request from ' + uri.merchant); 'Retrieving Payment Request from ' + uri.merchant);
@ -476,7 +474,14 @@ angular.module('copayApp.controllers').controller('SendController',
// delete the `merchant` property from the scope. // delete the `merchant` property from the scope.
var unregister = scope.$watch('address', function() { var unregister = scope.$watch('address', function() {
var val = scope.sendForm.address.$viewValue || ''; var val = scope.sendForm.address.$viewValue || '';
var uri = new bitcore.BIP21(val).data; var uri;
if (val.indexOf('bitcoin:') === 0) {
uri = new bitcore.BIP21(val).data;
} else if (/^https?:\/\//.test(val)) {
uri = {
merchant: val
};
}
if (!uri || !uri.merchant) { if (!uri || !uri.merchant) {
delete $rootScope.merchant; delete $rootScope.merchant;
scope.sendForm.amount.$setViewValue(''); scope.sendForm.amount.$setViewValue('');