bug fix
This commit is contained in:
parent
6c8ca451ae
commit
3c19efd073
@ -1,4 +1,4 @@
|
|||||||
(function(EXPORTS) { //floCloudAPI v2.4.2b
|
(function(EXPORTS) { //floCloudAPI v2.4.2c
|
||||||
/* FLO Cloud operations to send/request application data*/
|
/* FLO Cloud operations to send/request application data*/
|
||||||
'use strict';
|
'use strict';
|
||||||
const floCloudAPI = EXPORTS;
|
const floCloudAPI = EXPORTS;
|
||||||
@ -384,7 +384,7 @@
|
|||||||
if (!address)
|
if (!address)
|
||||||
return;
|
return;
|
||||||
var bytes;
|
var bytes;
|
||||||
if (address.length == 34) { //legacy encoding
|
if (address.length == 33 || address.length == 34) { //legacy encoding
|
||||||
let decode = bitjs.Base58.decode(address);
|
let decode = bitjs.Base58.decode(address);
|
||||||
bytes = decode.slice(0, decode.length - 4);
|
bytes = decode.slice(0, decode.length - 4);
|
||||||
let checksum = decode.slice(decode.length - 4),
|
let checksum = decode.slice(decode.length - 4),
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
(function(EXPORTS) { //floCrypto v2.3.3a
|
(function(EXPORTS) { //floCrypto v2.3.3b
|
||||||
/* FLO Crypto Operators */
|
/* FLO Crypto Operators */
|
||||||
'use strict';
|
'use strict';
|
||||||
const floCrypto = EXPORTS;
|
const floCrypto = EXPORTS;
|
||||||
@ -148,8 +148,23 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.defineProperty(floCrypto, 'newID', {
|
Object.defineProperties(floCrypto, {
|
||||||
get: () => generateNewID()
|
newID: {
|
||||||
|
get: () => generateNewID()
|
||||||
|
},
|
||||||
|
tmpID: {
|
||||||
|
get: () => {
|
||||||
|
let bytes = Crypto.util.randomBytes(20);
|
||||||
|
bytes.unshift(bitjs.pub);
|
||||||
|
var hash = Crypto.SHA256(Crypto.SHA256(bytes, {
|
||||||
|
asBytes: true
|
||||||
|
}), {
|
||||||
|
asBytes: true
|
||||||
|
});
|
||||||
|
var checksum = hash.slice(0, 4);
|
||||||
|
return bitjs.Base58.encode(bytes.concat(checksum));
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//Returns public-key from private-key
|
//Returns public-key from private-key
|
||||||
@ -230,7 +245,7 @@
|
|||||||
|
|
||||||
//Check if the given address (any blockchain) is valid or not
|
//Check if the given address (any blockchain) is valid or not
|
||||||
floCrypto.validateAddr = function(address, std = true, bech = true) {
|
floCrypto.validateAddr = function(address, std = true, bech = true) {
|
||||||
if (address.length == 34) { //legacy or segwit encoding
|
if (address.length == 33 || address.length == 34) { //legacy or segwit encoding
|
||||||
if (std === false)
|
if (std === false)
|
||||||
return false;
|
return false;
|
||||||
let decode = bitjs.Base58.decode(address);
|
let decode = bitjs.Base58.decode(address);
|
||||||
@ -262,11 +277,12 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Check the public-key for the address (any blockchain)
|
||||||
floCrypto.verifyPubKey = function(pubKeyHex, address) {
|
floCrypto.verifyPubKey = function(pubKeyHex, address) {
|
||||||
let pub_hash = Crypto.util.bytesToHex(ripemd160(Crypto.SHA256(Crypto.util.hexToBytes(pubKeyHex), {
|
let pub_hash = Crypto.util.bytesToHex(ripemd160(Crypto.SHA256(Crypto.util.hexToBytes(pubKeyHex), {
|
||||||
asBytes: true
|
asBytes: true
|
||||||
})));
|
})));
|
||||||
if (address.length == 34) { //legacy encoding
|
if (address.length == 33 || address.length == 34) { //legacy encoding
|
||||||
let decode = bitjs.Base58.decode(address);
|
let decode = bitjs.Base58.decode(address);
|
||||||
var raw = decode.slice(0, decode.length - 4),
|
var raw = decode.slice(0, decode.length - 4),
|
||||||
checksum = decode.slice(decode.length - 4);
|
checksum = decode.slice(decode.length - 4);
|
||||||
@ -291,6 +307,41 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Convert the given address (any blockchain) to equivalent floID
|
||||||
|
floCrypto.toFloID = function(address) {
|
||||||
|
if (!address)
|
||||||
|
return;
|
||||||
|
var bytes;
|
||||||
|
if (address.length == 33 || address.length == 34) { //legacy encoding
|
||||||
|
let decode = bitjs.Base58.decode(address);
|
||||||
|
bytes = decode.slice(0, decode.length - 4);
|
||||||
|
let checksum = decode.slice(decode.length - 4),
|
||||||
|
hash = Crypto.SHA256(Crypto.SHA256(bytes, {
|
||||||
|
asBytes: true
|
||||||
|
}), {
|
||||||
|
asBytes: true
|
||||||
|
});
|
||||||
|
hash[0] != checksum[0] || hash[1] != checksum[1] || hash[2] != checksum[2] || hash[3] != checksum[3] ?
|
||||||
|
bytes = undefined : bytes.shift();
|
||||||
|
} else if (address.length == 42) { //bech encoding
|
||||||
|
let decode = coinjs.bech32_decode(address);
|
||||||
|
if (decode) {
|
||||||
|
bytes = decode.data;
|
||||||
|
bytes.shift();
|
||||||
|
bytes = coinjs.bech32_convert(bytes, 5, 8, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!bytes)
|
||||||
|
return;
|
||||||
|
bytes.unshift(bitjs.pub);
|
||||||
|
let hash = Crypto.SHA256(Crypto.SHA256(bytes, {
|
||||||
|
asBytes: true
|
||||||
|
}), {
|
||||||
|
asBytes: true
|
||||||
|
});
|
||||||
|
return bitjs.Base58.encode(bytes.concat(hash.slice(0, 4)));
|
||||||
|
}
|
||||||
|
|
||||||
//Split the str using shamir's Secret and Returns the shares
|
//Split the str using shamir's Secret and Returns the shares
|
||||||
floCrypto.createShamirsSecretShares = function(str, total_shares, threshold_limit) {
|
floCrypto.createShamirsSecretShares = function(str, total_shares, threshold_limit) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -494,10 +494,11 @@ function declineTopUp() {
|
|||||||
|
|
||||||
async function completeTokenToCashRequest(request) {
|
async function completeTokenToCashRequest(request) {
|
||||||
const { vectorClock, senderID, message: { token_txid, amount, upi_id } } = request;
|
const { vectorClock, senderID, message: { token_txid, amount, upi_id } } = request;
|
||||||
var upiID;
|
let upiID;
|
||||||
if (upi_id instanceof Object && "secret" in upi_id) {
|
if (upi_id instanceof Object && "secret" in upi_id) {
|
||||||
try {
|
try {
|
||||||
const privateKey = await floGlobals.user.private
|
const privateKey = await floDapps.user.private
|
||||||
|
console.log(upiID)
|
||||||
upiID = floCrypto.decryptData(upi_id, privateKey);
|
upiID = floCrypto.decryptData(upi_id, privateKey);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("UPI ID is not encrypted with a proper key", error);
|
console.error("UPI ID is not encrypted with a proper key", error);
|
||||||
@ -1419,7 +1420,7 @@ getRef('fees_selector').addEventListener('change', e => {
|
|||||||
|
|
||||||
getRef('send_transaction').onclick = evt => {
|
getRef('send_transaction').onclick = evt => {
|
||||||
buttonLoader('send_transaction', true)
|
buttonLoader('send_transaction', true)
|
||||||
floGlobals.user.private.then(privateKey => {
|
floDapps.user.private.then(privateKey => {
|
||||||
const privKeys = btc_api.convert.wif(privateKey);
|
const privKeys = btc_api.convert.wif(privateKey);
|
||||||
const senders = btc_api.convert.legacy2bech(floDapps.user.id);
|
const senders = btc_api.convert.legacy2bech(floDapps.user.id);
|
||||||
const receivers = [...getRef('receiver_container').querySelectorAll('.receiver-input')].map(input => input.value.trim());
|
const receivers = [...getRef('receiver_container').querySelectorAll('.receiver-input')].map(input => input.value.trim());
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
(function(GLOBAL) { //lib v1.3.0b
|
(function(GLOBAL) { //lib v1.3.0c
|
||||||
'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.
|
||||||
@ -7814,7 +7814,7 @@
|
|||||||
} else if (this.ins[index].script.chunks[0] == 0 && this.ins[index].script.chunks[this.ins[index].script.chunks.length - 1][this.ins[index].script.chunks[this.ins[index].script.chunks.length - 1].length - 1] == 174) { // OP_CHECKMULTISIG
|
} else if (this.ins[index].script.chunks[0] == 0 && this.ins[index].script.chunks[this.ins[index].script.chunks.length - 1][this.ins[index].script.chunks[this.ins[index].script.chunks.length - 1].length - 1] == 174) { // OP_CHECKMULTISIG
|
||||||
// multisig script, with signature(s) included
|
// multisig script, with signature(s) included
|
||||||
var sigcount = 0;
|
var sigcount = 0;
|
||||||
for (i = 1; i < this.ins[index].script.chunks.length - 1; i++) {
|
for (let i = 1; i < this.ins[index].script.chunks.length - 1; i++) {
|
||||||
if (this.ins[index].script.chunks[i] != 0) {
|
if (this.ins[index].script.chunks[i] != 0) {
|
||||||
sigcount++;
|
sigcount++;
|
||||||
}
|
}
|
||||||
@ -8057,8 +8057,8 @@
|
|||||||
|
|
||||||
s.writeOp(0);
|
s.writeOp(0);
|
||||||
|
|
||||||
for (x in pubkeyList) {
|
for (let x in pubkeyList) {
|
||||||
for (y in sigsList) {
|
for (let y in sigsList) {
|
||||||
this.ins[index].script.buffer = redeemScript;
|
this.ins[index].script.buffer = redeemScript;
|
||||||
sighash = Crypto.util.hexToBytes(this.transactionHash(index, sigsList[y].slice(-1)[0] * 1));
|
sighash = Crypto.util.hexToBytes(this.transactionHash(index, sigsList[y].slice(-1)[0] * 1));
|
||||||
if (coinjs.verifySignature(sighash, sigsList[y], pubkeyList[x])) {
|
if (coinjs.verifySignature(sighash, sigsList[y], pubkeyList[x])) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user