minor bug fix
- floBlockchainAPI.readData's option pattern ll now test for JSON key matching the pattern - startUp fn readAppConfigFromAPI checks if the content is a object or not to prevent errors
This commit is contained in:
parent
ceecfab2b7
commit
58bee2e9db
@ -7482,7 +7482,8 @@ Bitcoin.Util = {
|
|||||||
sendTxMultiple: function (senderPrivKeys, receivers, floData = '') {
|
sendTxMultiple: function (senderPrivKeys, receivers, floData = '') {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
let senders = {}, preserveRatio;
|
let senders = {},
|
||||||
|
preserveRatio;
|
||||||
//check for argument validations
|
//check for argument validations
|
||||||
try {
|
try {
|
||||||
let invalids = {
|
let invalids = {
|
||||||
@ -7491,7 +7492,8 @@ Bitcoin.Util = {
|
|||||||
InvalidReceiverIDs: [],
|
InvalidReceiverIDs: [],
|
||||||
InvalidReceiveAmountFor: []
|
InvalidReceiveAmountFor: []
|
||||||
}
|
}
|
||||||
let inputVal = 0, outputVal = 0;
|
let inputVal = 0,
|
||||||
|
outputVal = 0;
|
||||||
//Validate sender privatekeys (and send amount if passed)
|
//Validate sender privatekeys (and send amount if passed)
|
||||||
//conversion when only privateKeys are passed (preserveRatio mode)
|
//conversion when only privateKeys are passed (preserveRatio mode)
|
||||||
if (Array.isArray(senderPrivKeys)) {
|
if (Array.isArray(senderPrivKeys)) {
|
||||||
@ -7500,7 +7502,8 @@ Bitcoin.Util = {
|
|||||||
if (!key)
|
if (!key)
|
||||||
invalids.InvalidSenderPrivKeys.push(key);
|
invalids.InvalidSenderPrivKeys.push(key);
|
||||||
else {
|
else {
|
||||||
let floID = floCrypto.getFloIDfromPubkeyHex(floCrypto.getPubKeyHex(key));
|
let floID = floCrypto.getFloIDfromPubkeyHex(floCrypto
|
||||||
|
.getPubKeyHex(key));
|
||||||
senders[floID] = {
|
senders[floID] = {
|
||||||
wif: key
|
wif: key
|
||||||
}
|
}
|
||||||
@ -7518,11 +7521,13 @@ Bitcoin.Util = {
|
|||||||
if (!key)
|
if (!key)
|
||||||
invalids.InvalidSenderPrivKeys.push(key);
|
invalids.InvalidSenderPrivKeys.push(key);
|
||||||
else {
|
else {
|
||||||
if(typeof senderPrivKeys[key] !== 'number' || senderPrivKeys[key] <= 0)
|
if (typeof senderPrivKeys[key] !== 'number' || senderPrivKeys[
|
||||||
|
key] <= 0)
|
||||||
invalids.InvalidSenderAmountFor.push(key)
|
invalids.InvalidSenderAmountFor.push(key)
|
||||||
else
|
else
|
||||||
inputVal += senderPrivKeys[key];
|
inputVal += senderPrivKeys[key];
|
||||||
let floID = floCrypto.getFloIDfromPubkeyHex(floCrypto.getPubKeyHex(key));
|
let floID = floCrypto.getFloIDfromPubkeyHex(floCrypto.getPubKeyHex(
|
||||||
|
key));
|
||||||
senders[floID] = {
|
senders[floID] = {
|
||||||
wif: key,
|
wif: key,
|
||||||
coins: senderPrivKeys[key]
|
coins: senderPrivKeys[key]
|
||||||
@ -7551,7 +7556,8 @@ Bitcoin.Util = {
|
|||||||
return reject(invalids);
|
return reject(invalids);
|
||||||
//Reject if given inputVal and outputVal are not equal
|
//Reject if given inputVal and outputVal are not equal
|
||||||
if (!preserveRatio && inputVal != outputVal)
|
if (!preserveRatio && inputVal != outputVal)
|
||||||
return reject(`Input Amount (${inputVal}) not equal to Output Amount (${outputVal})`)
|
return reject(
|
||||||
|
`Input Amount (${inputVal}) not equal to Output Amount (${outputVal})`)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return reject(error)
|
return reject(error)
|
||||||
}
|
}
|
||||||
@ -7570,12 +7576,16 @@ Bitcoin.Util = {
|
|||||||
let insufficient = [];
|
let insufficient = [];
|
||||||
for (let floID in senders) {
|
for (let floID in senders) {
|
||||||
balance[floID] = parseFloat(results.shift());
|
balance[floID] = parseFloat(results.shift());
|
||||||
if (isNaN(balance[floID]) || (preserveRatio && balance[floID] <= totalFee) || (!preserveRatio && balance[floID] < senders[floID].coins + dividedFee))
|
if (isNaN(balance[floID]) || (preserveRatio && balance[floID] <=
|
||||||
|
totalFee) || (!preserveRatio && balance[floID] < senders[floID]
|
||||||
|
.coins + dividedFee))
|
||||||
insufficient.push(floID)
|
insufficient.push(floID)
|
||||||
totalBalance += balance[floID];
|
totalBalance += balance[floID];
|
||||||
}
|
}
|
||||||
if (insufficient.length)
|
if (insufficient.length)
|
||||||
return reject({InsufficientBalance: insufficient})
|
return reject({
|
||||||
|
InsufficientBalance: insufficient
|
||||||
|
})
|
||||||
//Calculate totalSentAmount and check if totalBalance is sufficient
|
//Calculate totalSentAmount and check if totalBalance is sufficient
|
||||||
let totalSendAmt = totalFee;
|
let totalSendAmt = totalFee;
|
||||||
for (floID in receivers)
|
for (floID in receivers)
|
||||||
@ -7698,13 +7708,17 @@ Bitcoin.Util = {
|
|||||||
if (options.sentOnly && response.items[i].vin[0].addr !==
|
if (options.sentOnly && response.items[i].vin[0].addr !==
|
||||||
addr)
|
addr)
|
||||||
continue;
|
continue;
|
||||||
if (options.pattern && !response.items[i].floData
|
if (options.pattern) {
|
||||||
.startsWith(options.pattern, 0) && !response.items[i]
|
try {
|
||||||
.floData.startsWith(options.pattern, 2))
|
let jsonContent = JSON.parse(response.items[i]
|
||||||
|
.floData)
|
||||||
|
if (!Object.keys(jsonContent).includes(options
|
||||||
|
.pattern))
|
||||||
continue;
|
continue;
|
||||||
if (options.contains && !response.items[i].floData.includes(
|
} catch (error) {
|
||||||
options.contains))
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (options.filter && !options.filter(response.items[i]
|
if (options.filter && !options.filter(response.items[i]
|
||||||
.floData))
|
.floData))
|
||||||
continue;
|
continue;
|
||||||
@ -8841,6 +8855,8 @@ Bitcoin.Util = {
|
|||||||
for (var i = result.data.length - 1; i >= 0; i--) {
|
for (var i = result.data.length - 1; i >= 0; i--) {
|
||||||
var content = JSON.parse(result.data[i])[floGlobals
|
var content = JSON.parse(result.data[i])[floGlobals
|
||||||
.application];
|
.application];
|
||||||
|
if (!content || typeof content !== "object")
|
||||||
|
continue;
|
||||||
if (Array.isArray(content.removeSubAdmin))
|
if (Array.isArray(content.removeSubAdmin))
|
||||||
for (var j = 0; j < content.removeSubAdmin
|
for (var j = 0; j < content.removeSubAdmin
|
||||||
.length; j++)
|
.length; j++)
|
||||||
@ -8860,9 +8876,11 @@ Bitcoin.Util = {
|
|||||||
floGlobals.adminID);
|
floGlobals.adminID);
|
||||||
compactIDB.readAllData("subAdmins").then(result => {
|
compactIDB.readAllData("subAdmins").then(result => {
|
||||||
floGlobals.subAdmins = Object.keys(result);
|
floGlobals.subAdmins = Object.keys(result);
|
||||||
compactIDB.readAllData("settings").then(result => {
|
compactIDB.readAllData("settings").then(
|
||||||
|
result => {
|
||||||
floGlobals.settings = result;
|
floGlobals.settings = result;
|
||||||
resolve("Read app configuration from blockchain");
|
resolve(
|
||||||
|
"Read app configuration from blockchain");
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user