.
This commit is contained in:
parent
246f1927dc
commit
d5d3f9ee28
13 changed files with 310 additions and 119 deletions
|
|
@ -1123,50 +1123,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
return finale;
|
||||
};
|
||||
|
||||
// Here?
|
||||
root.redirFromUri = function(uri) {
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
// URI extensions for Payment Protocol with non-backwards-compatible request
|
||||
if ((/^bitcoin:\?r=[\w+]/).exec(uri)) {
|
||||
uri = decodeURIComponent(uri.replace('bitcoin:?r=', ''));
|
||||
$state.go('send.confirm', {paypro: uri})
|
||||
} else {
|
||||
uri = sanitizeUri(uri);
|
||||
|
||||
if (!bitcore.URI.isValid(uri)) {
|
||||
return false;
|
||||
}
|
||||
var parsed = new bitcore.URI(uri);
|
||||
|
||||
var addr = parsed.address ? parsed.address.toString() : '';
|
||||
var message = parsed.message;
|
||||
|
||||
var amount = parsed.amount ? parsed.amount : '';
|
||||
|
||||
if (parsed.r) {
|
||||
$state.go('send.confirm', {paypro: parsed.r});
|
||||
} else {
|
||||
if (amount) {
|
||||
$state.go('send.confirm', {toAmount: amount, toAddress: addr, description:message})
|
||||
} else {
|
||||
$state.go('send.amount', {toAddress: addr})
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue