Bug fixes: floBlockchainAPI and lib.js
This commit is contained in:
parent
f0a4837222
commit
dc19a4e565
@ -1,4 +1,4 @@
|
|||||||
(function(EXPORTS) { //floBlockchainAPI v2.3.3a
|
(function(EXPORTS) { //floBlockchainAPI v2.3.3b
|
||||||
/* FLO Blockchain Operator to send/receive data from blockchain using API calls*/
|
/* FLO Blockchain Operator to send/receive data from blockchain using API calls*/
|
||||||
'use strict';
|
'use strict';
|
||||||
const floBlockchainAPI = EXPORTS;
|
const floBlockchainAPI = EXPORTS;
|
||||||
@ -6,7 +6,7 @@
|
|||||||
const DEFAULT = {
|
const DEFAULT = {
|
||||||
blockchain: floGlobals.blockchain,
|
blockchain: floGlobals.blockchain,
|
||||||
apiURL: {
|
apiURL: {
|
||||||
FLO: ['https://livenet.flocha.in/', 'https://flosight.duckdns.org/'],
|
FLO: ['https://flosight.duckdns.org/'],
|
||||||
FLO_TEST: ['https://testnet-flosight.duckdns.org', 'https://testnet.flocha.in/']
|
FLO_TEST: ['https://testnet-flosight.duckdns.org', 'https://testnet.flocha.in/']
|
||||||
},
|
},
|
||||||
sendAmt: 0.001,
|
sendAmt: 0.001,
|
||||||
@ -49,7 +49,7 @@
|
|||||||
const allServerList = new Set(floGlobals.apiURL && floGlobals.apiURL[DEFAULT.blockchain] ? floGlobals.apiURL[DEFAULT.blockchain] : DEFAULT.apiURL[DEFAULT.blockchain]);
|
const allServerList = new Set(floGlobals.apiURL && floGlobals.apiURL[DEFAULT.blockchain] ? floGlobals.apiURL[DEFAULT.blockchain] : DEFAULT.apiURL[DEFAULT.blockchain]);
|
||||||
|
|
||||||
var serverList = Array.from(allServerList);
|
var serverList = Array.from(allServerList);
|
||||||
var curPos = floCrypto.randInt(0, serverList - 1);
|
var curPos = floCrypto.randInt(0, serverList.length - 1);
|
||||||
|
|
||||||
function fetch_retry(apicall, rm_flosight) {
|
function fetch_retry(apicall, rm_flosight) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -371,18 +371,18 @@
|
|||||||
})
|
})
|
||||||
//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 (let floID in receivers)
|
||||||
totalSendAmt += receivers[floID];
|
totalSendAmt += receivers[floID];
|
||||||
if (totalBalance < totalSendAmt)
|
if (totalBalance < totalSendAmt)
|
||||||
return reject("Insufficient total Balance");
|
return reject("Insufficient total Balance");
|
||||||
//Get the UTXOs of the senders
|
//Get the UTXOs of the senders
|
||||||
let promises = [];
|
let promises = [];
|
||||||
for (floID in senders)
|
for (let floID in senders)
|
||||||
promises.push(promisedAPI(`api/addr/${floID}/utxo`));
|
promises.push(promisedAPI(`api/addr/${floID}/utxo`));
|
||||||
Promise.all(promises).then(results => {
|
Promise.all(promises).then(results => {
|
||||||
let wifSeq = [];
|
let wifSeq = [];
|
||||||
var trx = bitjs.transaction();
|
var trx = bitjs.transaction();
|
||||||
for (floID in senders) {
|
for (let floID in senders) {
|
||||||
let utxos = results.shift();
|
let utxos = results.shift();
|
||||||
let sendAmt;
|
let sendAmt;
|
||||||
if (preserveRatio) {
|
if (preserveRatio) {
|
||||||
@ -406,7 +406,7 @@
|
|||||||
if (change > 0)
|
if (change > 0)
|
||||||
trx.addoutput(floID, change);
|
trx.addoutput(floID, change);
|
||||||
}
|
}
|
||||||
for (floID in receivers)
|
for (let floID in receivers)
|
||||||
trx.addoutput(floID, receivers[floID]);
|
trx.addoutput(floID, receivers[floID]);
|
||||||
trx.addflodata(floData.replace(/\n/g, ' '));
|
trx.addflodata(floData.replace(/\n/g, ' '));
|
||||||
for (let i = 0; i < wifSeq.length; i++)
|
for (let i = 0; i < wifSeq.length; i++)
|
||||||
|
|||||||
6
lib.js
6
lib.js
@ -1,4 +1,4 @@
|
|||||||
(function(GLOBAL) { //lib v1.3.0c
|
(function(GLOBAL) { //lib v1.3.0d
|
||||||
'use strict';
|
'use strict';
|
||||||
/* Utility Libraries required for Standard operations
|
/* Utility Libraries required for Standard operations
|
||||||
* All credits for these codes belong to their respective creators, moderators and owners.
|
* All credits for these codes belong to their respective creators, moderators and owners.
|
||||||
@ -4782,8 +4782,8 @@
|
|||||||
} else if (floDataCount < 253) {
|
} else if (floDataCount < 253) {
|
||||||
floDataCountString = floDataCount.toString(16);
|
floDataCountString = floDataCount.toString(16);
|
||||||
} else if (floDataCount <= 1040) {
|
} else if (floDataCount <= 1040) {
|
||||||
floDataCountAdjusted = (floDataCount - 253) + parseInt("0xfd00fd");
|
let floDataCountAdjusted = (floDataCount - 253) + parseInt("0xfd00fd");
|
||||||
floDataCountStringAdjusted = floDataCountAdjusted.toString(16);
|
let floDataCountStringAdjusted = floDataCountAdjusted.toString(16);
|
||||||
floDataCountString = floDataCountStringAdjusted.substr(0, 2) + floDataCountStringAdjusted.substr(4, 2) + floDataCountStringAdjusted.substr(2, 2);
|
floDataCountString = floDataCountStringAdjusted.substr(0, 2) + floDataCountStringAdjusted.substr(4, 2) + floDataCountStringAdjusted.substr(2, 2);
|
||||||
} else {
|
} else {
|
||||||
floDataCountString = "Character Limit Exceeded";
|
floDataCountString = "Character Limit Exceeded";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user