Added amountSatoshis.

This commit is contained in:
Brendon Duncan 2018-09-03 12:53:12 +12:00
commit 48b8bbf90a
2 changed files with 14 additions and 2 deletions

View file

@ -84,6 +84,14 @@
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:
@ -93,6 +101,7 @@
returns:
{
amount: '',
amountSatoshis: 0,
bareUrl: '',
coin: '',
copayInvitation: '',
@ -206,7 +215,8 @@
case 'amount':
var amount = parseFloat(decodedValue);
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 {
return parsed;
}
@ -252,6 +262,7 @@
var copayInvitationRe = /^[0-9A-HJ-NP-Za-km-z]{70,80}$/;
//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 importRe = /^[123]|$/;
var privateKeyEncryptedRe = /^6P[1-9A-HJ-NP-Za-km-z]{56}$/;
var privateKeyForUncompressedPublicKeyRe = /^5[1-9A-HJ-NP-Za-km-z]{50}$/;
var privateKeyForUncompressedPublicKeyTestnetRe = /^9[1-9A-HJ-NP-Za-km-z]{50}$/;

View file

@ -1,4 +1,4 @@
fdescribe('bitcoinUriService', function() {
describe('bitcoinUriService', function() {
var bitcoinUriService;
beforeEach(function() {
@ -113,6 +113,7 @@ fdescribe('bitcoinUriService', function() {
expect(parsed.isValid).toBe(true);
expect(parsed.amount).toBe('20.3');
expect(parsed.amountSatoshis).toBe(2030000000);
expect(parsed.coin).toBe('btc');
expect(parsed.label).toBe('Luke-Jr');
expect(parsed.publicAddress.legacy).toBe('12nCRhMDfxVnuF3uYMXv2fNxBohNmacfWu');