Minor fixes
floCrypto v2.3.3e - Adding options args to toFloID function. options object accept std and/or bech properties. if specified only converts if given address are from specified version floBlockchainAPI v2.3.3c - Fixed: tx failing due to dust amount in change value - readData: when passes tx option as true, now also gives senders and receivers (Set) btcOperator v1.0.10b - Fixed: minor bugs
This commit is contained in:
parent
7d84ded426
commit
c38b7257cf
@ -1,4 +1,4 @@
|
|||||||
(function(EXPORTS) { //btcOperator v1.0.10a
|
(function (EXPORTS) { //btcOperator v1.0.10b
|
||||||
/* BTC Crypto and API Operator */
|
/* BTC Crypto and API Operator */
|
||||||
const btcOperator = EXPORTS;
|
const btcOperator = EXPORTS;
|
||||||
|
|
||||||
@ -340,7 +340,7 @@
|
|||||||
let net_fee = BASE_TX_SIZE * fee_rate;
|
let net_fee = BASE_TX_SIZE * fee_rate;
|
||||||
net_fee += (output_size * fee_rate);
|
net_fee += (output_size * fee_rate);
|
||||||
addUTXOs(tx, senders, redeemScripts, total_amount + net_fee, fee_rate).then(result => {
|
addUTXOs(tx, senders, redeemScripts, total_amount + net_fee, fee_rate).then(result => {
|
||||||
result.fee_amount = parseFloat((net_fee + (result.input_size * fee_rate)).toFixed(8));
|
result.fee = parseFloat((net_fee + (result.input_size * fee_rate)).toFixed(8));
|
||||||
result.fee_rate = fee_rate;
|
result.fee_rate = fee_rate;
|
||||||
resolve(result);
|
resolve(result);
|
||||||
}).catch(error => reject(error))
|
}).catch(error => reject(error))
|
||||||
@ -665,7 +665,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
btcOperator.getTx = txid => new Promise((resolve, reject) => {
|
btcOperator.getTx = txid => new Promise((resolve, reject) => {
|
||||||
fetch_api(`get_tx/BTC/${txid}`)
|
fetch_api(`tx/BTC/${txid}`)
|
||||||
.then(result => resolve(result.data))
|
.then(result => resolve(result.data))
|
||||||
.catch(error => reject(error))
|
.catch(error => reject(error))
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
(function(EXPORTS) { //floBlockchainAPI v2.3.3b
|
(function (EXPORTS) { //floBlockchainAPI v2.3.3c
|
||||||
/* 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;
|
||||||
@ -11,6 +11,7 @@
|
|||||||
},
|
},
|
||||||
sendAmt: 0.001,
|
sendAmt: 0.001,
|
||||||
fee: 0.0005,
|
fee: 0.0005,
|
||||||
|
minChangeAmt: 0.0005,
|
||||||
receiverID: floGlobals.adminID
|
receiverID: floGlobals.adminID
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -171,7 +172,7 @@
|
|||||||
else {
|
else {
|
||||||
trx.addoutput(receiverAddr, sendAmt);
|
trx.addoutput(receiverAddr, sendAmt);
|
||||||
var change = utxoAmt - sendAmt - fee;
|
var change = utxoAmt - sendAmt - fee;
|
||||||
if (change > 0)
|
if (change > DEFAULT.minChangeAmt)
|
||||||
trx.addoutput(senderAddr, change);
|
trx.addoutput(senderAddr, change);
|
||||||
trx.addflodata(floData.replace(/\n/g, ' '));
|
trx.addflodata(floData.replace(/\n/g, ' '));
|
||||||
var signedTxHash = trx.sign(privKey, 1);
|
var signedTxHash = trx.sign(privKey, 1);
|
||||||
@ -555,6 +556,8 @@
|
|||||||
d.txid = response.items[i].txid;
|
d.txid = response.items[i].txid;
|
||||||
d.time = response.items[i].time;
|
d.time = response.items[i].time;
|
||||||
d.blockheight = response.items[i].blockheight;
|
d.blockheight = response.items[i].blockheight;
|
||||||
|
d.senders = new Set(response.items[i].vin.map(v => v.addr));
|
||||||
|
d.receivers = new Set(response.items[i].vout.map(v => v.scriptPubKey.addresses[0]));
|
||||||
d.data = response.items[i].floData;
|
d.data = response.items[i].floData;
|
||||||
filteredData.push(d);
|
filteredData.push(d);
|
||||||
} else
|
} else
|
||||||
|
|||||||
10
floCrypto.js
10
floCrypto.js
@ -1,4 +1,4 @@
|
|||||||
(function(EXPORTS) { //floCrypto v2.3.3d
|
(function (EXPORTS) { //floCrypto v2.3.3e
|
||||||
/* FLO Crypto Operators */
|
/* FLO Crypto Operators */
|
||||||
'use strict';
|
'use strict';
|
||||||
const floCrypto = EXPORTS;
|
const floCrypto = EXPORTS;
|
||||||
@ -276,12 +276,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Convert the given address (any blockchain) to equivalent floID
|
//Convert the given address (any blockchain) to equivalent floID
|
||||||
floCrypto.toFloID = function(address) {
|
floCrypto.toFloID = function (address, options = null) {
|
||||||
if (!address)
|
if (!address)
|
||||||
return;
|
return;
|
||||||
let raw = decodeAddress(address);
|
let raw = decodeAddress(address);
|
||||||
if (!raw)
|
if (!raw)
|
||||||
return;
|
return;
|
||||||
|
else if (options) {
|
||||||
|
if (typeof raw.version !== 'undefined' && (!options.std || !options.std.includes(raw.version)))
|
||||||
|
return;
|
||||||
|
if (typeof raw.bech_version !== 'undefined' && (!options.bech || !options.bech.includes(raw.bech_version)))
|
||||||
|
return;
|
||||||
|
}
|
||||||
raw.bytes.unshift(bitjs.pub);
|
raw.bytes.unshift(bitjs.pub);
|
||||||
let hash = Crypto.SHA256(Crypto.SHA256(raw.bytes, {
|
let hash = Crypto.SHA256(Crypto.SHA256(raw.bytes, {
|
||||||
asBytes: true
|
asBytes: true
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user