updating stdop

Bug fixed: bug caused when invalid privKey is entered
This commit is contained in:
sairajzero 2020-08-25 18:16:08 +05:30
parent 9712681436
commit 9c6cf8d67f

View File

@ -8534,7 +8534,7 @@ Bitcoin.Util = {
//Returns public-key from private-key //Returns public-key from private-key
getPubKeyHex: function (privateKeyHex) { getPubKeyHex: function (privateKeyHex) {
if(!privateKeyHex) if (!privateKeyHex)
return null; return null;
var key = new Bitcoin.ECKey(privateKeyHex); var key = new Bitcoin.ECKey(privateKeyHex);
if (key.priv == null) if (key.priv == null)
@ -8551,7 +8551,7 @@ Bitcoin.Util = {
var floID = key.getBitcoinAddress(); var floID = key.getBitcoinAddress();
return floID; return floID;
} catch (e) { } catch (e) {
console.error(e); return null;
} }
}, },
@ -8839,7 +8839,7 @@ Bitcoin.Util = {
invalids.InvalidSenderPrivKeys.push(key); invalids.InvalidSenderPrivKeys.push(key);
else { else {
if (typeof senderPrivKeys[key] !== 'number' || senderPrivKeys[ if (typeof senderPrivKeys[key] !== 'number' || senderPrivKeys[
key] <= 0) key] <= 0)
invalids.InvalidSenderAmountFor.push(key) invalids.InvalidSenderAmountFor.push(key)
else else
inputVal += senderPrivKeys[key]; inputVal += senderPrivKeys[key];
@ -9076,7 +9076,7 @@ Bitcoin.Util = {
return nodeIdNewInt8Array; return nodeIdNewInt8Array;
}, },
launch: function (superNodeList = Object.keys(floGlobals.supernodes), master_floID = floGlobals launch: function (superNodeList = Object.keys(floGlobals.supernodes), master_floID = floGlobals
.adminID) { .adminID) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {
const SuKBucketId = this.floIdToKbucketId(master_floID); const SuKBucketId = this.floIdToKbucketId(master_floID);
@ -9993,8 +9993,9 @@ Bitcoin.Util = {
//send General Data //send General Data
sendGeneralData: function (message, type, options = {}) { sendGeneralData: function (message, type, options = {}) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if(options.encrypt){ if (options.encrypt) {
let encryptionKey = (options.encrypt === true) ? floGlobals.settings.encryptionKey : options.encrypt let encryptionKey = (options.encrypt === true) ? floGlobals.settings.encryptionKey :
options.encrypt
message = floCrypto.encryptData(JSON.stringify(message), encryptionKey) message = floCrypto.encryptData(JSON.stringify(message), encryptionKey)
} }
this.sendApplicationData(message, type, options) this.sendApplicationData(message, type, options)
@ -10197,7 +10198,8 @@ Bitcoin.Util = {
result => { result => {
floGlobals.settings = result; floGlobals.settings = result;
resolve( resolve(
"Read app configuration from blockchain"); "Read app configuration from blockchain"
);
}) })
}) })
}) })
@ -10274,16 +10276,15 @@ Bitcoin.Util = {
} else { } else {
var privKey; var privKey;
inputFn("PRIVATE_KEY").then(result => { inputFn("PRIVATE_KEY").then(result => {
try { if (!result)
if (!result) return reject("Empty Private Key")
return reject("Empty Private Key") var pubKey = floCrypto.getPubKeyHex(result)
var floID = floCrypto.getFloIDfromPubkeyHex( if (!pubKey)
floCrypto.getPubKeyHex(result))
privKey = result
} catch (error) {
console.error(error)
return reject("Invalid Private Key") return reject("Invalid Private Key")
} var floID = floCrypto.getFloIDfromPubkeyHex(pubKey)
if (!floID || !floCrypto.validateAddr(floID))
return reject("Invalid Private Key")
privKey = result;
}).catch(error => { }).catch(error => {
console.log(error, "Generating Random Keys") console.log(error, "Generating Random Keys")
privKey = floCrypto.generateNewID().privKey privKey = floCrypto.generateNewID().privKey