Added amountSatoshis.
This commit is contained in:
parent
fa15b26792
commit
48b8bbf90a
2 changed files with 14 additions and 2 deletions
|
|
@ -84,6 +84,14 @@
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function infoFromImport(data) {
|
||||||
|
var split = data.split('|');
|
||||||
|
// Copay seems to use extra parameter for coin.
|
||||||
|
if (split.length < 5 || split.length > 6) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
For parsing:
|
For parsing:
|
||||||
|
|
@ -93,6 +101,7 @@
|
||||||
returns:
|
returns:
|
||||||
{
|
{
|
||||||
amount: '',
|
amount: '',
|
||||||
|
amountSatoshis: 0,
|
||||||
bareUrl: '',
|
bareUrl: '',
|
||||||
coin: '',
|
coin: '',
|
||||||
copayInvitation: '',
|
copayInvitation: '',
|
||||||
|
|
@ -206,7 +215,8 @@
|
||||||
case 'amount':
|
case 'amount':
|
||||||
var amount = parseFloat(decodedValue);
|
var amount = parseFloat(decodedValue);
|
||||||
if (amount) { // Checking for NaN, or no numbers at all etc. & convert to satoshi
|
if (amount) { // Checking for NaN, or no numbers at all etc. & convert to satoshi
|
||||||
parsed.amount = decodedValue * 100000000; // Need to check if a currency is precised
|
parsed.amount = decodedValue; // Need to check if a currency is precised
|
||||||
|
parsed.amountSatoshis = amount * 100000000
|
||||||
} else {
|
} else {
|
||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
|
|
@ -252,6 +262,7 @@
|
||||||
var copayInvitationRe = /^[0-9A-HJ-NP-Za-km-z]{70,80}$/;
|
var copayInvitationRe = /^[0-9A-HJ-NP-Za-km-z]{70,80}$/;
|
||||||
//var legacyRe = /^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$/;
|
//var legacyRe = /^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$/;
|
||||||
//var legacyTestnetRe = /^[mn][a-km-zA-HJ-NP-Z1-9]{25,34}$/;
|
//var legacyTestnetRe = /^[mn][a-km-zA-HJ-NP-Z1-9]{25,34}$/;
|
||||||
|
var importRe = /^[123]|$/;
|
||||||
var privateKeyEncryptedRe = /^6P[1-9A-HJ-NP-Za-km-z]{56}$/;
|
var privateKeyEncryptedRe = /^6P[1-9A-HJ-NP-Za-km-z]{56}$/;
|
||||||
var privateKeyForUncompressedPublicKeyRe = /^5[1-9A-HJ-NP-Za-km-z]{50}$/;
|
var privateKeyForUncompressedPublicKeyRe = /^5[1-9A-HJ-NP-Za-km-z]{50}$/;
|
||||||
var privateKeyForUncompressedPublicKeyTestnetRe = /^9[1-9A-HJ-NP-Za-km-z]{50}$/;
|
var privateKeyForUncompressedPublicKeyTestnetRe = /^9[1-9A-HJ-NP-Za-km-z]{50}$/;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
fdescribe('bitcoinUriService', function() {
|
describe('bitcoinUriService', function() {
|
||||||
var bitcoinUriService;
|
var bitcoinUriService;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
|
|
@ -113,6 +113,7 @@ fdescribe('bitcoinUriService', function() {
|
||||||
|
|
||||||
expect(parsed.isValid).toBe(true);
|
expect(parsed.isValid).toBe(true);
|
||||||
expect(parsed.amount).toBe('20.3');
|
expect(parsed.amount).toBe('20.3');
|
||||||
|
expect(parsed.amountSatoshis).toBe(2030000000);
|
||||||
expect(parsed.coin).toBe('btc');
|
expect(parsed.coin).toBe('btc');
|
||||||
expect(parsed.label).toBe('Luke-Jr');
|
expect(parsed.label).toBe('Luke-Jr');
|
||||||
expect(parsed.publicAddress.legacy).toBe('12nCRhMDfxVnuF3uYMXv2fNxBohNmacfWu');
|
expect(parsed.publicAddress.legacy).toBe('12nCRhMDfxVnuF3uYMXv2fNxBohNmacfWu');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue