update std-op
This commit is contained in:
parent
579d00b343
commit
e88799f01f
@ -1,82 +1,70 @@
|
||||
'use strict';
|
||||
(function(EXPORTS) { //floBlockchainAPI v2.3.0
|
||||
/* FLO Blockchain Operator to send/receive data from blockchain using API calls*/
|
||||
//version 2.2.1
|
||||
(function(GLOBAL) {
|
||||
const floBlockchainAPI = GLOBAL.floBlockchainAPI = {
|
||||
'use strict';
|
||||
const floBlockchainAPI = EXPORTS;
|
||||
|
||||
util: {
|
||||
serverList: floGlobals.apiURL[floGlobals.blockchain].slice(0),
|
||||
curPos: floCrypto.randInt(0, floGlobals.apiURL[floGlobals.blockchain].length - 1),
|
||||
fetch_retry: function(apicall, rm_flosight) {
|
||||
const serverList = floGlobals.apiURL[floGlobals.blockchain].slice(0);
|
||||
var curPos = floCrypto.randInt(0, serverList - 1);
|
||||
|
||||
function fetch_retry(apicall, rm_flosight) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let i = this.serverList.indexOf(rm_flosight)
|
||||
if (i != -1) this.serverList.splice(i, 1);
|
||||
this.curPos = floCrypto.randInt(0, this.serverList.length - 1);
|
||||
this.fetch_api(apicall)
|
||||
let i = serverList.indexOf(rm_flosight)
|
||||
if (i != -1) serverList.splice(i, 1);
|
||||
curPos = floCrypto.randInt(0, serverList.length - 1);
|
||||
fetch_api(apicall)
|
||||
.then(result => resolve(result))
|
||||
.catch(error => reject(error));
|
||||
})
|
||||
},
|
||||
fetch_api: function(apicall) {
|
||||
}
|
||||
|
||||
function fetch_api(apicall) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.serverList.length === 0)
|
||||
if (serverList.length === 0)
|
||||
reject("No floSight server working");
|
||||
else {
|
||||
let flosight = this.serverList[this.curPos];
|
||||
let flosight = serverList[curPos];
|
||||
fetch(flosight + apicall).then(response => {
|
||||
if (response.ok)
|
||||
response.json().then(data => resolve(data));
|
||||
else {
|
||||
this.fetch_retry(apicall, flosight)
|
||||
fetch_retry(apicall, flosight)
|
||||
.then(result => resolve(result))
|
||||
.catch(error => reject(error));
|
||||
}
|
||||
}).catch(error => {
|
||||
this.fetch_retry(apicall, flosight)
|
||||
fetch_retry(apicall, flosight)
|
||||
.then(result => resolve(result))
|
||||
.catch(error => reject(error));
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
current: function() {
|
||||
return this.serverList[this.curPos];
|
||||
}
|
||||
},
|
||||
|
||||
Object.defineProperty(floBlockchainAPI, 'current_server', {
|
||||
get: () => serverList[curPos]
|
||||
});
|
||||
|
||||
//Promised function to get data from API
|
||||
promisedAPI: function(apicall) {
|
||||
const promisedAPI = floBlockchainAPI.promisedAPI = function(apicall) {
|
||||
return new Promise((resolve, reject) => {
|
||||
//console.log(apicall);
|
||||
this.util.fetch_api(apicall)
|
||||
fetch_api(apicall)
|
||||
.then(result => resolve(result))
|
||||
.catch(error => reject(error));
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
//Get balance for the given Address
|
||||
getBalance: function(addr) {
|
||||
const getBalance = floBlockchainAPI.getBalance = function(addr) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.promisedAPI(`api/addr/${addr}/balance`)
|
||||
promisedAPI(`api/addr/${addr}/balance`)
|
||||
.then(balance => resolve(parseFloat(balance)))
|
||||
.catch(error => reject(error));
|
||||
});
|
||||
},
|
||||
|
||||
//Write Data into blockchain
|
||||
writeData: function(senderAddr, data, privKey, receiverAddr = floGlobals.adminID, strict_utxo = true) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof data != "string")
|
||||
data = JSON.stringify(data);
|
||||
this.sendTx(senderAddr, receiverAddr, floGlobals.sendAmt, privKey, data, strict_utxo)
|
||||
.then(txid => resolve(txid))
|
||||
.catch(error => reject(error));
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
//Send Tx to blockchain
|
||||
sendTx: function(senderAddr, receiverAddr, sendAmt, privKey, floData = '', strict_utxo = true) {
|
||||
const sendTx = floBlockchainAPI.sendTx = function(senderAddr, receiverAddr, sendAmt, privKey, floData = '', strict_utxo = true) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!floCrypto.validateASCII(floData))
|
||||
return reject("Invalid FLO_Data: only printable ASCII characters are allowed");
|
||||
@ -90,8 +78,8 @@
|
||||
return reject(`Invalid sendAmt : ${sendAmt}`);
|
||||
|
||||
//get unconfirmed tx list
|
||||
this.promisedAPI(`api/addr/${senderAddr}`).then(result => {
|
||||
this.readTxs(senderAddr, 0, result.unconfirmedTxApperances).then(result => {
|
||||
promisedAPI(`api/addr/${senderAddr}`).then(result => {
|
||||
readTxs(senderAddr, 0, result.unconfirmedTxApperances).then(result => {
|
||||
let unconfirmedSpent = {};
|
||||
for (let tx of result.items)
|
||||
if (tx.confirmations == 0)
|
||||
@ -103,7 +91,7 @@
|
||||
unconfirmedSpent[vin.txid] = [vin.vout];
|
||||
}
|
||||
//get utxos list
|
||||
this.promisedAPI(`api/addr/${senderAddr}/utxo`).then(utxos => {
|
||||
promisedAPI(`api/addr/${senderAddr}/utxo`).then(utxos => {
|
||||
//form/construct the transaction data
|
||||
var trx = bitjs.transaction();
|
||||
var utxoAmt = 0.0;
|
||||
@ -113,7 +101,7 @@
|
||||
//use only utxos with confirmations (strict_utxo mode)
|
||||
if (utxos[i].confirmations || !strict_utxo) {
|
||||
if (utxos[i].txid in unconfirmedSpent && unconfirmedSpent[utxos[i].txid].includes(utxos[i].vout))
|
||||
continue; //A transaction has already used this utxo, but is unconfirmed.
|
||||
continue; //A transaction has already used the utxo, but is unconfirmed.
|
||||
trx.addinput(utxos[i].txid, utxos[i].vout, utxos[i].scriptPubKey);
|
||||
utxoAmt += utxos[i].amount;
|
||||
};
|
||||
@ -127,7 +115,7 @@
|
||||
trx.addoutput(senderAddr, change);
|
||||
trx.addflodata(floData.replace(/\n/g, ' '));
|
||||
var signedTxHash = trx.sign(privKey, 1);
|
||||
this.broadcastTx(signedTxHash)
|
||||
broadcastTx(signedTxHash)
|
||||
.then(txid => resolve(txid))
|
||||
.catch(error => reject(error))
|
||||
}
|
||||
@ -135,10 +123,21 @@
|
||||
}).catch(error => reject(error))
|
||||
}).catch(error => reject(error))
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
//Write Data into blockchain
|
||||
floBlockchainAPI.writeData = function(senderAddr, data, privKey, receiverAddr = floGlobals.adminID, strict_utxo = true) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof data != "string")
|
||||
data = JSON.stringify(data);
|
||||
sendTx(senderAddr, receiverAddr, floGlobals.sendAmt, privKey, data, strict_utxo)
|
||||
.then(txid => resolve(txid))
|
||||
.catch(error => reject(error));
|
||||
});
|
||||
}
|
||||
|
||||
//merge all UTXOs of a given floID into a single UTXO
|
||||
mergeUTXOs: function(floID, privKey, floData = '') {
|
||||
floBlockchainAPI.mergeUTXOs = function(floID, privKey, floData = '') {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!floCrypto.validateAddr(floID))
|
||||
return reject(`Invalid floID`);
|
||||
@ -149,7 +148,7 @@
|
||||
var trx = bitjs.transaction();
|
||||
var utxoAmt = 0.0;
|
||||
var fee = floGlobals.fee;
|
||||
this.promisedAPI(`api/addr/${floID}/utxo`).then(utxos => {
|
||||
promisedAPI(`api/addr/${floID}/utxo`).then(utxos => {
|
||||
for (var i = utxos.length - 1; i >= 0; i--)
|
||||
if (utxos[i].confirmations) {
|
||||
trx.addinput(utxos[i].txid, utxos[i].vout, utxos[i].scriptPubKey);
|
||||
@ -158,12 +157,12 @@
|
||||
trx.addoutput(floID, utxoAmt - fee);
|
||||
trx.addflodata(floData.replace(/\n/g, ' '));
|
||||
var signedTxHash = trx.sign(privKey, 1);
|
||||
this.broadcastTx(signedTxHash)
|
||||
broadcastTx(signedTxHash)
|
||||
.then(txid => resolve(txid))
|
||||
.catch(error => reject(error))
|
||||
}).catch(error => reject(error))
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
/**Write data into blockchain from (and/or) to multiple floID
|
||||
* @param {Array} senderPrivKeys List of sender private-keys
|
||||
@ -172,7 +171,7 @@
|
||||
* @param {boolean} preserveRatio (optional) preserve ratio or equal contribution
|
||||
* @return {Promise}
|
||||
*/
|
||||
writeDataMultiple: function(senderPrivKeys, data, receivers = [floGlobals.adminID], preserveRatio = true) {
|
||||
floBlockchainAPI.writeDataMultiple = function(senderPrivKeys, data, receivers = [floGlobals.adminID], preserveRatio = true) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!Array.isArray(senderPrivKeys))
|
||||
return reject("Invalid senderPrivKeys: SenderPrivKeys must be Array");
|
||||
@ -192,11 +191,11 @@
|
||||
}
|
||||
if (typeof data != "string")
|
||||
data = JSON.stringify(data);
|
||||
this.sendTxMultiple(senderPrivKeys, receivers, data)
|
||||
sendTxMultiple(senderPrivKeys, receivers, data)
|
||||
.then(txid => resolve(txid))
|
||||
.catch(error => reject(error))
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
/**Send Tx from (and/or) to multiple floID
|
||||
* @param {Array or Object} senderPrivKeys List of sender private-key (optional: with coins to be sent)
|
||||
@ -204,7 +203,7 @@
|
||||
* @param {string} floData FLO data of the txn
|
||||
* @return {Promise}
|
||||
*/
|
||||
sendTxMultiple: function(senderPrivKeys, receivers, floData = '') {
|
||||
const sendTxMultiple = floBlockchainAPI.sendTxMultiple = function(senderPrivKeys, receivers, floData = '') {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!floCrypto.validateASCII(floData))
|
||||
return reject("Invalid FLO_Data: only printable ASCII characters are allowed");
|
||||
@ -286,7 +285,7 @@
|
||||
//Get balance of senders
|
||||
let promises = [];
|
||||
for (let floID in senders)
|
||||
promises.push(this.getBalance(floID));
|
||||
promises.push(getBalance(floID));
|
||||
Promise.all(promises).then(results => {
|
||||
let totalBalance = 0,
|
||||
totalFee = floGlobals.fee,
|
||||
@ -316,7 +315,7 @@
|
||||
//Get the UTXOs of the senders
|
||||
let promises = [];
|
||||
for (floID in senders)
|
||||
promises.push(this.promisedAPI(`api/addr/${floID}/utxo`));
|
||||
promises.push(promisedAPI(`api/addr/${floID}/utxo`));
|
||||
Promise.all(promises).then(results => {
|
||||
let wifSeq = [];
|
||||
var trx = bitjs.transaction();
|
||||
@ -350,20 +349,20 @@
|
||||
for (let i = 0; i < wifSeq.length; i++)
|
||||
trx.signinput(i, wifSeq[i], 1);
|
||||
var signedTxHash = trx.serialize();
|
||||
this.broadcastTx(signedTxHash)
|
||||
broadcastTx(signedTxHash)
|
||||
.then(txid => resolve(txid))
|
||||
.catch(error => reject(error))
|
||||
}).catch(error => reject(error))
|
||||
}).catch(error => reject(error))
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
//Broadcast signed Tx in blockchain using API
|
||||
broadcastTx: function(signedTxHash) {
|
||||
const broadcastTx = floBlockchainAPI.broadcastTx = function(signedTxHash) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (signedTxHash.length < 1)
|
||||
return reject("Empty Signature");
|
||||
var url = this.util.serverList[this.util.curPos] + 'api/tx/send';
|
||||
var url = serverList[curPos] + 'api/tx/send';
|
||||
fetch(url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
@ -377,35 +376,35 @@
|
||||
response.text().then(data => resolve(data));
|
||||
}).catch(error => reject(error));
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
getTx: function(txid) {
|
||||
floBlockchainAPI.getTx = function(txid) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.promisedAPI(`api/tx/${txid}`)
|
||||
promisedAPI(`api/tx/${txid}`)
|
||||
.then(response => resolve(response))
|
||||
.catch(error => reject(error))
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
//Read Txs of Address between from and to
|
||||
readTxs: function(addr, from, to) {
|
||||
const readTxs = floBlockchainAPI.readTxs = function(addr, from, to) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.promisedAPI(`api/addrs/${addr}/txs?from=${from}&to=${to}`)
|
||||
promisedAPI(`api/addrs/${addr}/txs?from=${from}&to=${to}`)
|
||||
.then(response => resolve(response))
|
||||
.catch(error => reject(error))
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
//Read All Txs of Address (newest first)
|
||||
readAllTxs: function(addr) {
|
||||
floBlockchainAPI.readAllTxs = function(addr) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.promisedAPI(`api/addrs/${addr}/txs?from=0&to=1`).then(response => {
|
||||
this.promisedAPI(`api/addrs/${addr}/txs?from=0&to=${response.totalItems}0`)
|
||||
promisedAPI(`api/addrs/${addr}/txs?from=0&to=1`).then(response => {
|
||||
promisedAPI(`api/addrs/${addr}/txs?from=0&to=${response.totalItems}0`)
|
||||
.then(response => resolve(response.items))
|
||||
.catch(error => reject(error));
|
||||
}).catch(error => reject(error))
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
/*Read flo Data from txs of given Address
|
||||
options can be used to filter data
|
||||
@ -419,15 +418,15 @@
|
||||
sender : flo-id(s) of sender
|
||||
receiver : flo-id(s) of receiver
|
||||
*/
|
||||
readData: function(addr, options = {}) {
|
||||
floBlockchainAPI.readData = function(addr, options = {}) {
|
||||
options.limit = options.limit || 0;
|
||||
options.ignoreOld = options.ignoreOld || 0;
|
||||
if (typeof options.sender === "string") options.sender = [options.sender];
|
||||
if (typeof options.receiver === "string") options.receiver = [options.receiver];
|
||||
return new Promise((resolve, reject) => {
|
||||
this.promisedAPI(`api/addrs/${addr}/txs?from=0&to=1`).then(response => {
|
||||
promisedAPI(`api/addrs/${addr}/txs?from=0&to=1`).then(response => {
|
||||
var newItems = response.totalItems - options.ignoreOld;
|
||||
this.promisedAPI(`api/addrs/${addr}/txs?from=0&to=${newItems*2}`).then(response => {
|
||||
promisedAPI(`api/addrs/${addr}/txs?from=0&to=${newItems*2}`).then(response => {
|
||||
if (options.limit <= 0)
|
||||
options.limit = response.items.length;
|
||||
var filteredData = [];
|
||||
@ -436,6 +435,7 @@
|
||||
for (let i = 0; i < numToRead && filteredData.length < options.limit; i++) {
|
||||
if (!response.items[i].confirmations) { //unconfirmed transactions
|
||||
unconfirmedCount++;
|
||||
if (numToRead < response.items[i].length)
|
||||
numToRead++;
|
||||
continue;
|
||||
}
|
||||
@ -509,5 +509,6 @@
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
})(typeof global !== "undefined" ? global : window);
|
||||
|
||||
|
||||
})('object' === typeof module ? module.exports : window.floBlockchainAPI = {});
|
||||
@ -1,27 +1,20 @@
|
||||
(function(EXPORTS) { //floCrypto v2.3.0a
|
||||
/* FLO Crypto Operators */
|
||||
'use strict';
|
||||
const floCrypto = EXPORTS;
|
||||
|
||||
(function(GLOBAL) {
|
||||
const floCrypto = GLOBAL.floCrypto = {
|
||||
const p = BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F", 16);
|
||||
const ecparams = EllipticCurve.getSECCurveByName("secp256k1");
|
||||
const ascii_alternatives = `‘ '\n’ '\n“ "\n” "\n– --\n— ---\n≥ >=\n≤ <=\n≠ !=\n× *\n÷ /\n← <-\n→ ->\n↔ <->\n⇒ =>\n⇐ <=\n⇔ <=>`;
|
||||
const exponent1 = () => p.add(BigInteger.ONE).divide(BigInteger("4"));
|
||||
|
||||
util: {
|
||||
p: BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F", 16),
|
||||
|
||||
ecparams: EllipticCurve.getSECCurveByName("secp256k1"),
|
||||
|
||||
asciiAlternatives: `‘ '\n’ '\n“ "\n” "\n– --\n— ---\n≥ >=\n≤ <=\n≠ !=\n× *\n÷ /\n← <-\n→ ->\n↔ <->\n⇒ =>\n⇐ <=\n⇔ <=>`,
|
||||
|
||||
exponent1: function() {
|
||||
return this.p.add(BigInteger.ONE).divide(BigInteger("4"))
|
||||
},
|
||||
|
||||
calculateY: function(x) {
|
||||
let p = this.p;
|
||||
let exp = this.exponent1();
|
||||
function calculateY(x) {
|
||||
let exp = exponent1();
|
||||
// x is x value of public key in BigInteger format without 02 or 03 or 04 prefix
|
||||
return x.modPow(BigInteger("3"), p).add(BigInteger("7")).mod(p).modPow(exp, p)
|
||||
},
|
||||
getUncompressedPublicKey: function(compressedPublicKey) {
|
||||
const p = this.p;
|
||||
}
|
||||
|
||||
function getUncompressedPublicKey(compressedPublicKey) {
|
||||
// Fetch x from compressedPublicKey
|
||||
let pubKeyBytes = Crypto.util.hexToBytes(compressedPublicKey);
|
||||
const prefix = pubKeyBytes.shift() // remove prefix
|
||||
@ -30,7 +23,7 @@
|
||||
let x = new BigInteger(pubKeyBytes)
|
||||
let xDecimalValue = x.toString()
|
||||
// Fetch y
|
||||
let y = this.calculateY(x);
|
||||
let y = calculateY(x);
|
||||
let yDecimalValue = y.toString();
|
||||
// verify y value
|
||||
let resultBigInt = y.mod(BigInteger("2"));
|
||||
@ -41,39 +34,34 @@
|
||||
x: xDecimalValue,
|
||||
y: yDecimalValue
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
getSenderPublicKeyString: function() {
|
||||
function getSenderPublicKeyString() {
|
||||
let privateKey = ellipticCurveEncryption.senderRandom();
|
||||
var senderPublicKeyString = ellipticCurveEncryption.senderPublicString(privateKey);
|
||||
return {
|
||||
privateKey: privateKey,
|
||||
senderPublicKeyString: senderPublicKeyString
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
deriveSharedKeySender: function(receiverCompressedPublicKey, senderPrivateKey) {
|
||||
let receiverPublicKeyString = this.getUncompressedPublicKey(receiverCompressedPublicKey);
|
||||
function deriveSharedKeySender(receiverPublicKeyHex, senderPrivateKey) {
|
||||
let receiverPublicKeyString = getUncompressedPublicKey(receiverPublicKeyHex);
|
||||
var senderDerivedKey = ellipticCurveEncryption.senderSharedKeyDerivation(
|
||||
receiverPublicKeyString.x, receiverPublicKeyString.y, senderPrivateKey);
|
||||
return senderDerivedKey;
|
||||
},
|
||||
}
|
||||
|
||||
deriveReceiverSharedKey: function(senderPublicKeyString, receiverPrivateKey) {
|
||||
function deriveSharedKeyReceiver(senderPublicKeyString, receiverPrivateKey) {
|
||||
return ellipticCurveEncryption.receiverSharedKeyDerivation(
|
||||
senderPublicKeyString.XValuePublicString, senderPublicKeyString.YValuePublicString, receiverPrivateKey);
|
||||
},
|
||||
}
|
||||
|
||||
getReceiverPublicKeyString: function(privateKey) {
|
||||
function getReceiverPublicKeyString(privateKey) {
|
||||
return ellipticCurveEncryption.receiverPublicString(privateKey);
|
||||
},
|
||||
}
|
||||
|
||||
deriveSharedKeyReceiver: function(senderPublicKeyString, receiverPrivateKey) {
|
||||
return ellipticCurveEncryption.receiverSharedKeyDerivation(
|
||||
senderPublicKeyString.XValuePublicString, senderPublicKeyString.YValuePublicString, receiverPrivateKey);
|
||||
},
|
||||
|
||||
wifToDecimal: function(pk_wif, isPubKeyCompressed = false) {
|
||||
function wifToDecimal(pk_wif, isPubKeyCompressed = false) {
|
||||
let pk = Bitcoin.Base58.decode(pk_wif)
|
||||
pk.shift()
|
||||
pk.splice(-4, 4)
|
||||
@ -87,94 +75,75 @@
|
||||
privateKeyHex: privateKeyHex
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
//generate a random Interger within range
|
||||
randInt: function(min, max) {
|
||||
floCrypto.randInt = function(min, max) {
|
||||
min = Math.ceil(min);
|
||||
max = Math.floor(max);
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
},
|
||||
}
|
||||
|
||||
//generate a random String within length (options : alphaNumeric chars only)
|
||||
randString: function(length, alphaNumeric = true) {
|
||||
floCrypto.randString = function(length, alphaNumeric = true) {
|
||||
var result = '';
|
||||
if (alphaNumeric)
|
||||
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
else
|
||||
var characters =
|
||||
var characters = alphaNumeric ? 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' :
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_+-./*?@#&$<>=[]{}():';
|
||||
for (var i = 0; i < length; i++)
|
||||
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
||||
return result;
|
||||
},
|
||||
}
|
||||
|
||||
//Encrypt Data using public-key
|
||||
encryptData: function(data, receiverCompressedPublicKey) {
|
||||
var senderECKeyData = this.util.getSenderPublicKeyString();
|
||||
var senderDerivedKey = this.util.deriveSharedKeySender(receiverCompressedPublicKey, senderECKeyData
|
||||
.privateKey);
|
||||
floCrypto.encryptData = function(data, receiverPublicKeyHex) {
|
||||
var senderECKeyData = getSenderPublicKeyString();
|
||||
var senderDerivedKey = deriveSharedKeySender(receiverPublicKeyHex, senderECKeyData.privateKey);
|
||||
let senderKey = senderDerivedKey.XValue + senderDerivedKey.YValue;
|
||||
let secret = Crypto.AES.encrypt(data, senderKey);
|
||||
return {
|
||||
secret: secret,
|
||||
senderPublicKeyString: senderECKeyData.senderPublicKeyString
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
//Decrypt Data using private-key
|
||||
decryptData: function(data, myPrivateKey) {
|
||||
floCrypto.decryptData = function(data, privateKeyHex) {
|
||||
var receiverECKeyData = {};
|
||||
if (typeof myPrivateKey !== "string") throw new Error("No private key found.");
|
||||
|
||||
let privateKey = this.util.wifToDecimal(myPrivateKey, true);
|
||||
if (typeof privateKey.privateKeyDecimal !== "string") throw new Error(
|
||||
"Failed to detremine your private key.");
|
||||
if (typeof privateKeyHex !== "string") throw new Error("No private key found.");
|
||||
let privateKey = wifToDecimal(privateKeyHex, true);
|
||||
if (typeof privateKey.privateKeyDecimal !== "string") throw new Error("Failed to detremine your private key.");
|
||||
receiverECKeyData.privateKey = privateKey.privateKeyDecimal;
|
||||
|
||||
var receiverDerivedKey = this.util.deriveReceiverSharedKey(data.senderPublicKeyString,
|
||||
receiverECKeyData
|
||||
.privateKey);
|
||||
|
||||
var receiverDerivedKey = deriveSharedKeyReceiver(data.senderPublicKeyString, receiverECKeyData.privateKey);
|
||||
let receiverKey = receiverDerivedKey.XValue + receiverDerivedKey.YValue;
|
||||
let decryptMsg = Crypto.AES.decrypt(data.secret, receiverKey);
|
||||
return decryptMsg;
|
||||
},
|
||||
}
|
||||
|
||||
//Sign data using private-key
|
||||
signData: function(data, privateKeyHex) {
|
||||
floCrypto.signData = function(data, privateKeyHex) {
|
||||
var key = new Bitcoin.ECKey(privateKeyHex);
|
||||
key.setCompressed(true);
|
||||
|
||||
var privateKeyArr = key.getBitcoinPrivateKeyByteArray();
|
||||
var privateKey = BigInteger.fromByteArrayUnsigned(privateKeyArr);
|
||||
var messageHash = Crypto.SHA256(data);
|
||||
|
||||
var messageHashBigInteger = new BigInteger(messageHash);
|
||||
var messageSign = Bitcoin.ECDSA.sign(messageHashBigInteger, key.priv);
|
||||
|
||||
var sighex = Crypto.util.bytesToHex(messageSign);
|
||||
return sighex;
|
||||
},
|
||||
}
|
||||
|
||||
//Verify signatue of the data using public-key
|
||||
verifySign: function(data, signatureHex, publicKeyHex) {
|
||||
floCrypto.verifySign = function(data, signatureHex, publicKeyHex) {
|
||||
var msgHash = Crypto.SHA256(data);
|
||||
var messageHashBigInteger = new BigInteger(msgHash);
|
||||
|
||||
var sigBytes = Crypto.util.hexToBytes(signatureHex);
|
||||
var signature = Bitcoin.ECDSA.parseSig(sigBytes);
|
||||
|
||||
var publicKeyPoint = this.util.ecparams.getCurve().decodePointHex(publicKeyHex);
|
||||
|
||||
var verify = Bitcoin.ECDSA.verifyRaw(messageHashBigInteger, signature.r, signature.s,
|
||||
publicKeyPoint);
|
||||
var publicKeyPoint = ecparams.getCurve().decodePointHex(publicKeyHex);
|
||||
var verify = Bitcoin.ECDSA.verifyRaw(messageHashBigInteger, signature.r, signature.s, publicKeyPoint);
|
||||
return verify;
|
||||
},
|
||||
}
|
||||
|
||||
//Generates a new flo ID and returns private-key, public-key and floID
|
||||
generateNewID: function() {
|
||||
try {
|
||||
const generateNewID = floCrypto.generateNewID = function() {
|
||||
var key = new Bitcoin.ECKey(false);
|
||||
key.setCompressed(true);
|
||||
return {
|
||||
@ -182,13 +151,14 @@
|
||||
pubKey: key.getPubKeyHex(),
|
||||
privKey: key.getBitcoinWalletImportFormat()
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
},
|
||||
|
||||
Object.defineProperty(floCrypto, 'newID', {
|
||||
get: () => generateNewID()
|
||||
});
|
||||
|
||||
//Returns public-key from private-key
|
||||
getPubKeyHex: function(privateKeyHex) {
|
||||
floCrypto.getPubKeyHex = function(privateKeyHex) {
|
||||
if (!privateKeyHex)
|
||||
return null;
|
||||
var key = new Bitcoin.ECKey(privateKeyHex);
|
||||
@ -196,10 +166,10 @@
|
||||
return null;
|
||||
key.setCompressed(true);
|
||||
return key.getPubKeyHex();
|
||||
},
|
||||
}
|
||||
|
||||
//Returns flo-ID from public-key or private-key
|
||||
getFloID: function(keyHex) {
|
||||
floCrypto.getFloID = function(keyHex) {
|
||||
if (!keyHex)
|
||||
return null;
|
||||
try {
|
||||
@ -207,13 +177,13 @@
|
||||
if (key.priv == null)
|
||||
key.setPub(keyHex);
|
||||
return key.getBitcoinAddress();
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
//Verify the private-key for the given public-key or flo-ID
|
||||
verifyPrivKey: function(privateKeyHex, pubKey_floID, isfloID = true) {
|
||||
floCrypto.verifyPrivKey = function(privateKeyHex, pubKey_floID, isfloID = true) {
|
||||
if (!privateKeyHex || !pubKey_floID)
|
||||
return false;
|
||||
try {
|
||||
@ -227,25 +197,25 @@
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
//Check if the given Address is valid or not
|
||||
validateAddr: function(inpAddr) {
|
||||
floCrypto.validateFloID = floCrypto.validateAddr = function(inpAddr) {
|
||||
if (!inpAddr)
|
||||
return false;
|
||||
try {
|
||||
var addr = new Bitcoin.Address(inpAddr);
|
||||
let addr = new Bitcoin.Address(inpAddr);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
//Split the str using shamir's Secret and Returns the shares
|
||||
createShamirsSecretShares: function(str, total_shares, threshold_limit) {
|
||||
floCrypto.createShamirsSecretShares = function(str, total_shares, threshold_limit) {
|
||||
try {
|
||||
if (str.length > 0) {
|
||||
var strHex = shamirSecretShare.str2hex(str);
|
||||
@ -256,15 +226,10 @@
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
//Verifies the shares and str
|
||||
verifyShamirsSecret: function(sharesArray, str) {
|
||||
return (str && this.retrieveShamirSecret(sharesArray) === str)
|
||||
},
|
||||
}
|
||||
|
||||
//Returns the retrived secret by combining the shamirs shares
|
||||
retrieveShamirSecret: function(sharesArray) {
|
||||
const retrieveShamirSecret = floCrypto.retrieveShamirSecret = function(sharesArray) {
|
||||
try {
|
||||
if (sharesArray.length > 0) {
|
||||
var comb = shamirSecretShare.combine(sharesArray.slice(0, sharesArray.length));
|
||||
@ -275,9 +240,19 @@
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
validateASCII: function(string, bool = true) {
|
||||
//Verifies the shares and str
|
||||
floCrypto.verifyShamirsSecret = function(sharesArray, str) {
|
||||
if (!str)
|
||||
return null;
|
||||
else if (retrieveShamirSecret(sharesArray) === str)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
const validateASCII = floCrypto.validateASCII = function(string, bool = true) {
|
||||
if (typeof string !== "string")
|
||||
return null;
|
||||
if (bool) {
|
||||
@ -303,17 +278,17 @@
|
||||
else
|
||||
return true;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
convertToASCII: function(string, mode = 'soft-remove') {
|
||||
let chars = this.validateASCII(string, false);
|
||||
floCrypto.convertToASCII = function(string, mode = 'soft-remove') {
|
||||
let chars = validateASCII(string, false);
|
||||
if (chars === true)
|
||||
return string;
|
||||
else if (chars === null)
|
||||
return null;
|
||||
let convertor, result = string,
|
||||
refAlt = {};
|
||||
this.util.asciiAlternatives.split('\n').forEach(a => refAlt[a[0]] = a.slice(2));
|
||||
ascii_alternatives.split('\n').forEach(a => refAlt[a[0]] = a.slice(2));
|
||||
mode = mode.toLowerCase();
|
||||
if (mode === "hard-unicode")
|
||||
convertor = (c) => `\\u${('000'+c.charCodeAt().toString(16)).slice(-4)}`;
|
||||
@ -328,12 +303,11 @@
|
||||
for (let c in chars)
|
||||
result = result.replaceAll(c, convertor(c));
|
||||
return result;
|
||||
},
|
||||
}
|
||||
|
||||
revertUnicode: function(string) {
|
||||
floCrypto.revertUnicode = function(string) {
|
||||
return string.replace(/\\u[\dA-F]{4}/gi,
|
||||
m => String.fromCharCode(parseInt(m.replace(/\\u/g, ''), 16)));
|
||||
}
|
||||
}
|
||||
|
||||
})(typeof global !== "undefined" ? global : window);
|
||||
})('object' === typeof module ? module.exports : window.floCrypto = {});
|
||||
@ -1,11 +1,13 @@
|
||||
(typeof global !== "undefined" ? global : window).cryptocoin = floGlobals.blockchain;
|
||||
/* Util Libraries required for Standard operations
|
||||
All credits for these codes belong to their respective creators, moderators and owners.
|
||||
For more info on licence for these codes, visit respective source.
|
||||
*/
|
||||
(function(GLOBAL) { //lib v1.2.2a
|
||||
'use strict';
|
||||
/* Utility Libraries required for Standard operations
|
||||
* All credits for these codes belong to their respective creators, moderators and owners.
|
||||
* For more info (including license and terms of use), please visit respective source.
|
||||
*/
|
||||
GLOBAL.cryptocoin = (typeof floGlobals === 'undefined' ? null : floGlobals.blockchain) || 'FLO';
|
||||
|
||||
//Crypto.js
|
||||
(function(GLOBAL) {
|
||||
(function() {
|
||||
// Global Crypto object
|
||||
var Crypto = GLOBAL.Crypto = {};
|
||||
/*!
|
||||
@ -398,10 +400,10 @@
|
||||
return g && g.asBytes ? c : g && g.asString ? a.bytesToString(c) : k.bytesToHex(c)
|
||||
}
|
||||
})();
|
||||
})(typeof global !== "undefined" ? global : window);
|
||||
})();
|
||||
|
||||
//SecureRandom.js
|
||||
(function(GLOBAL) {
|
||||
(function() {
|
||||
|
||||
const getRandomValues = function(buf) {
|
||||
if (typeof require === 'function') {
|
||||
@ -602,10 +604,10 @@
|
||||
sr.seedInt8(entropyBytes[i]);
|
||||
}
|
||||
}
|
||||
})(typeof global !== "undefined" ? global : window);
|
||||
})();
|
||||
|
||||
//ripemd160.js
|
||||
(function(GLOBAL) {
|
||||
(function() {
|
||||
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
@ -803,10 +805,10 @@
|
||||
var digestbytes = wordsToBytes(H);
|
||||
return digestbytes;
|
||||
}
|
||||
})(typeof global !== "undefined" ? global : window);
|
||||
})();
|
||||
|
||||
//BigInteger.js
|
||||
(function(GLOBAL) {
|
||||
(function() {
|
||||
// Upstream 'BigInteger' here:
|
||||
// Original Author: http://www-cs-students.stanford.edu/~tjw/jsbn/
|
||||
// Follows 'jsbn' on Github: https://github.com/jasondavies/jsbn
|
||||
@ -2369,10 +2371,10 @@
|
||||
// int hashCode()
|
||||
// long longValue()
|
||||
// static BigInteger valueOf(long val)
|
||||
})(typeof global !== "undefined" ? global : window);
|
||||
})();
|
||||
|
||||
//ellipticcurve.js
|
||||
(function(GLOBAL) {
|
||||
(function() {
|
||||
/*!
|
||||
* Basic Javascript Elliptic Curve implementation
|
||||
* Ported loosely from BouncyCastle's Java EC code
|
||||
@ -4319,10 +4321,10 @@
|
||||
if (ec.secNamedCurves[name] == undefined) return null;
|
||||
return ec.secNamedCurves[name]();
|
||||
}
|
||||
})(typeof global !== "undefined" ? global : window);
|
||||
})();
|
||||
|
||||
//bitTrx.js
|
||||
(function(GLOBAL) {
|
||||
(function() {
|
||||
|
||||
var bitjs = GLOBAL.bitjs = function() {};
|
||||
|
||||
@ -4913,10 +4915,10 @@
|
||||
}
|
||||
return bitjs;
|
||||
|
||||
})(typeof global !== "undefined" ? global : window);
|
||||
})();
|
||||
|
||||
//Bitcoin.js
|
||||
(function(GLOBAL) {
|
||||
(function() {
|
||||
/*
|
||||
Copyright (c) 2011 Stefan Thomas
|
||||
|
||||
@ -5875,10 +5877,10 @@
|
||||
return true;
|
||||
}
|
||||
};
|
||||
})(typeof global !== "undefined" ? global : window);
|
||||
})();
|
||||
|
||||
//ellipticCurveEncryption.js
|
||||
(function(GLOBAL) {
|
||||
(function() {
|
||||
(function(ellipticCurveType) {
|
||||
|
||||
//Defining Elliptic Encryption Object
|
||||
@ -6010,10 +6012,10 @@
|
||||
}
|
||||
|
||||
})("secp256k1");
|
||||
})(typeof global !== "undefined" ? global : window);
|
||||
})();
|
||||
|
||||
//secrets.js
|
||||
(function(GLOBAL) {
|
||||
(function() {
|
||||
//Shamir Secret Share by Alexander Stetsyuk - released under MIT License
|
||||
|
||||
var SecretShare = GLOBAL.shamirSecretShare = {};
|
||||
@ -6125,8 +6127,7 @@
|
||||
}
|
||||
|
||||
// browsers with window.crypto.getRandomValues()
|
||||
if (GLOBAL['crypto'] && typeof GLOBAL['crypto']['getRandomValues'] === 'function' && typeof GLOBAL[
|
||||
'Uint32Array'] === 'function') {
|
||||
if (GLOBAL['crypto'] && typeof GLOBAL['crypto']['getRandomValues'] === 'function' && typeof GLOBAL['Uint32Array'] === 'function') {
|
||||
crypto = GLOBAL['crypto'];
|
||||
return function(bits) {
|
||||
var elems = Math.ceil(bits / 32),
|
||||
@ -6584,4 +6585,203 @@
|
||||
|
||||
// by default, initialize without an RNG
|
||||
SecretShare.init();
|
||||
})(typeof global !== 'undefined' ? global : window);
|
||||
})();
|
||||
|
||||
//kbucket.js
|
||||
(function() {
|
||||
const getRandomValues = function(buf) {
|
||||
if (typeof require === 'function') {
|
||||
var bytes = require('crypto').randomBytes(buf.length);
|
||||
buf.set(bytes)
|
||||
return buf;
|
||||
} else if (GLOBAL.crypto && GLOBAL.crypto.getRandomValues)
|
||||
return GLOBAL.crypto.getRandomValues(buf);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
// Kademlia DHT K-bucket implementation as a binary tree.
|
||||
// by 'Tristan Slominski' under 'MIT License'
|
||||
GLOBAL.BuildKBucket = function KBucket(options = {}) {
|
||||
if (!(this instanceof KBucket))
|
||||
return new KBucket(options);
|
||||
this.localNodeId = options.localNodeId || getRandomValues(new Uint8Array(20))
|
||||
this.numberOfNodesPerKBucket = options.numberOfNodesPerKBucket || 20
|
||||
this.numberOfNodesToPing = options.numberOfNodesToPing || 3
|
||||
this.distance = options.distance || this.distance
|
||||
this.arbiter = options.arbiter || this.arbiter
|
||||
this.metadata = Object.assign({}, options.metadata)
|
||||
|
||||
this.createNode = function() {
|
||||
return {
|
||||
contacts: [],
|
||||
dontSplit: false,
|
||||
left: null,
|
||||
right: null
|
||||
}
|
||||
}
|
||||
|
||||
this.ensureInt8 = function(name, val) {
|
||||
if (!(val instanceof Uint8Array))
|
||||
throw new TypeError(name + ' is not a Uint8Array')
|
||||
}
|
||||
|
||||
this.arrayEquals = function(array1, array2) {
|
||||
if (array1 === array2)
|
||||
return true
|
||||
if (array1.length !== array2.length)
|
||||
return false
|
||||
for (let i = 0, length = array1.length; i < length; ++i)
|
||||
if (array1[i] !== array2[i])
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
this.ensureInt8('option.localNodeId as parameter 1', this.localNodeId)
|
||||
this.root = this.createNode()
|
||||
|
||||
this.arbiter = function(incumbent, candidate) {
|
||||
return incumbent.vectorClock > candidate.vectorClock ? incumbent : candidate
|
||||
}
|
||||
|
||||
this.distance = function(firstId, secondId) {
|
||||
let distance = 0
|
||||
let i = 0
|
||||
const min = Math.min(firstId.length, secondId.length)
|
||||
const max = Math.max(firstId.length, secondId.length)
|
||||
for (; i < min; ++i)
|
||||
distance = distance * 256 + (firstId[i] ^ secondId[i])
|
||||
for (; i < max; ++i) distance = distance * 256 + 255
|
||||
return distance
|
||||
}
|
||||
|
||||
this.add = function(contact) {
|
||||
this.ensureInt8('contact.id', (contact || {}).id)
|
||||
let bitIndex = 0
|
||||
let node = this.root
|
||||
while (node.contacts === null)
|
||||
node = this._determineNode(node, contact.id, bitIndex++)
|
||||
const index = this._indexOf(node, contact.id)
|
||||
if (index >= 0) {
|
||||
this._update(node, index, contact)
|
||||
return this
|
||||
}
|
||||
if (node.contacts.length < this.numberOfNodesPerKBucket) {
|
||||
node.contacts.push(contact)
|
||||
return this
|
||||
}
|
||||
if (node.dontSplit)
|
||||
return this
|
||||
this._split(node, bitIndex)
|
||||
return this.add(contact)
|
||||
}
|
||||
|
||||
this.closest = function(id, n = Infinity) {
|
||||
this.ensureInt8('id', id)
|
||||
if ((!Number.isInteger(n) && n !== Infinity) || n <= 0)
|
||||
throw new TypeError('n is not positive number')
|
||||
let contacts = []
|
||||
for (let nodes = [this.root], bitIndex = 0; nodes.length > 0 && contacts.length < n;) {
|
||||
const node = nodes.pop()
|
||||
if (node.contacts === null) {
|
||||
const detNode = this._determineNode(node, id, bitIndex++)
|
||||
nodes.push(node.left === detNode ? node.right : node.left)
|
||||
nodes.push(detNode)
|
||||
} else
|
||||
contacts = contacts.concat(node.contacts)
|
||||
}
|
||||
return contacts
|
||||
.map(a => [this.distance(a.id, id), a])
|
||||
.sort((a, b) => a[0] - b[0])
|
||||
.slice(0, n)
|
||||
.map(a => a[1])
|
||||
}
|
||||
|
||||
this.count = function() {
|
||||
let count = 0
|
||||
for (const nodes = [this.root]; nodes.length > 0;) {
|
||||
const node = nodes.pop()
|
||||
if (node.contacts === null)
|
||||
nodes.push(node.right, node.left)
|
||||
else
|
||||
count += node.contacts.length
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
this._determineNode = function(node, id, bitIndex) {
|
||||
const bytesDescribedByBitIndex = bitIndex >> 3
|
||||
const bitIndexWithinByte = bitIndex % 8
|
||||
if ((id.length <= bytesDescribedByBitIndex) && (bitIndexWithinByte !== 0))
|
||||
return node.left
|
||||
const byteUnderConsideration = id[bytesDescribedByBitIndex]
|
||||
if (byteUnderConsideration & (1 << (7 - bitIndexWithinByte)))
|
||||
return node.right
|
||||
return node.left
|
||||
}
|
||||
|
||||
this.get = function(id) {
|
||||
this.ensureInt8('id', id)
|
||||
let bitIndex = 0
|
||||
let node = this.root
|
||||
while (node.contacts === null)
|
||||
node = this._determineNode(node, id, bitIndex++)
|
||||
const index = this._indexOf(node, id)
|
||||
return index >= 0 ? node.contacts[index] : null
|
||||
}
|
||||
|
||||
this._indexOf = function(node, id) {
|
||||
for (let i = 0; i < node.contacts.length; ++i)
|
||||
if (this.arrayEquals(node.contacts[i].id, id))
|
||||
return i
|
||||
return -1
|
||||
}
|
||||
|
||||
this.remove = function(id) {
|
||||
this.ensureInt8('the id as parameter 1', id)
|
||||
let bitIndex = 0
|
||||
let node = this.root
|
||||
while (node.contacts === null)
|
||||
node = this._determineNode(node, id, bitIndex++)
|
||||
const index = this._indexOf(node, id)
|
||||
if (index >= 0)
|
||||
node.contacts.splice(index, 1)[0]
|
||||
return this
|
||||
}
|
||||
|
||||
this._split = function(node, bitIndex) {
|
||||
node.left = this.createNode()
|
||||
node.right = this.createNode()
|
||||
for (const contact of node.contacts)
|
||||
this._determineNode(node, contact.id, bitIndex).contacts.push(contact)
|
||||
node.contacts = null
|
||||
const detNode = this._determineNode(node, this.localNodeId, bitIndex)
|
||||
const otherNode = node.left === detNode ? node.right : node.left
|
||||
otherNode.dontSplit = true
|
||||
}
|
||||
|
||||
this.toArray = function() {
|
||||
let result = []
|
||||
for (const nodes = [this.root]; nodes.length > 0;) {
|
||||
const node = nodes.pop()
|
||||
if (node.contacts === null)
|
||||
nodes.push(node.right, node.left)
|
||||
else
|
||||
result = result.concat(node.contacts)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
this._update = function(node, index, contact) {
|
||||
if (!this.arrayEquals(node.contacts[index].id, contact.id))
|
||||
throw new Error('wrong index for _update')
|
||||
const incumbent = node.contacts[index]
|
||||
const selection = this.arbiter(incumbent, contact)
|
||||
if (selection === incumbent && incumbent !== contact) return
|
||||
node.contacts.splice(index, 1)
|
||||
node.contacts.push(selection)
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
})(typeof global !== "undefined" ? global : window);
|
||||
@ -1,10 +1,10 @@
|
||||
const fs = require('fs');
|
||||
const getInput = require('./getInput');
|
||||
|
||||
const floGlobals = require('../docs/scripts/floGlobals');
|
||||
global.floGlobals = require('../docs/scripts/floGlobals');
|
||||
require('../src/set_globals');
|
||||
require('../docs/scripts/lib');
|
||||
require('../docs/scripts/floCrypto');
|
||||
const floCrypto = require('../docs/scripts/floCrypto');
|
||||
|
||||
console.log(__dirname);
|
||||
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
global.floGlobals = require('../docs/scripts/floGlobals');
|
||||
require('./set_globals');
|
||||
require('../docs/scripts/lib');
|
||||
require('../docs/scripts/floCrypto');
|
||||
require('../docs/scripts/floBlockchainAPI');
|
||||
global.floCrypto = require('../docs/scripts/floCrypto');
|
||||
global.floBlockchainAPI = require('../docs/scripts/floBlockchainAPI');
|
||||
require('../docs/scripts/floTokenAPI');
|
||||
|
||||
const Database = require("./database");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user