From cdeab33c2018d693442f4c290fa61e7ad879d43a Mon Sep 17 00:00:00 2001 From: sairajzero Date: Mon, 3 Feb 2020 18:43:29 +0530 Subject: [PATCH 01/14] Login as guest feature Entering a empty string for private Key now automatically generated a random key and logins as guest --- standard_Operations.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/standard_Operations.html b/standard_Operations.html index 1a2a1e1..d3470db 100644 --- a/standard_Operations.html +++ b/standard_Operations.html @@ -8600,7 +8600,7 @@ Bitcoin.Util = { try{ var privKey = floDapps.util.privKeyInput(); if(!privKey) - return reject("Empty Private Key") + privKey = floCrypto.generateNewID().privKey var floID = floCrypto.getFloIDfromPubkeyHex(floCrypto.getPubKeyHex(privKey)) console.log(floID) }catch(error){ From 7a6a2dc9ea6e0589408db45096d36f4c20a7ff62 Mon Sep 17 00:00:00 2001 From: sairajzero Date: Thu, 6 Feb 2020 13:38:09 +0530 Subject: [PATCH 02/14] Custom privKeyInput is made promisified privKeyInput now uses given key when resolved and generates random key when rejected --- standard_Operations.html | 57 ++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/standard_Operations.html b/standard_Operations.html index d3470db..3652b9d 100644 --- a/standard_Operations.html +++ b/standard_Operations.html @@ -8490,8 +8490,13 @@ Bitcoin.Util = { }, privKeyInput: function(){ - var privKey = prompt("Enter Private Key: ") - return privKey + return new Promise((resolve, reject) => { + var privKey = prompt("Enter Private Key: ") + if(privKey === null) + reject(null) + else + resolve(privKey) + }) }, startUpFunctions:{ @@ -8597,27 +8602,33 @@ Bitcoin.Util = { .then(result => resolve(result)) .catch(error => reject(error)) }else{ - try{ - var privKey = floDapps.util.privKeyInput(); - if(!privKey) - privKey = floCrypto.generateNewID().privKey - var floID = floCrypto.getFloIDfromPubkeyHex(floCrypto.getPubKeyHex(privKey)) - console.log(floID) - }catch(error){ - console.error(error) - return reject("Invalid Private Key") - } - var threshold = floCrypto.randInt(10,20) - writeSharesToIDB(floCrypto.createShamirsSecretShares(privKey, threshold, threshold)).then(resultIndexes =>{ - //store index keys in localStorage - localStorage.setItem(`${floGlobals.application}#privKey`, JSON.stringify(resultIndexes)) - //also add a dummy privatekey to the IDB - var randomPrivKey = floCrypto.generateNewID().privKey - var randomThreshold = floCrypto.randInt(10,20) - writeSharesToIDB(floCrypto.createShamirsSecretShares(randomPrivKey, randomThreshold, randomThreshold)) - //resolve private Key - resolve(privKey) - }).catch(error => reject(error)) + var privKey; + floDapps.util.privKeyInput().then(result => { + try{ + if(!result) + return reject("Empty Private Key") + var floID = floCrypto.getFloIDfromPubkeyHex(floCrypto.getPubKeyHex(result)) + console.log(floID) + }catch(error){ + console.error(error) + return reject("Invalid Private Key") + } + }).catch(error => { + console.log(error, "Generating Random Keys") + privKey = floCrypto.generateNewID().privKey + }).finally(_ => { + var threshold = floCrypto.randInt(10,20) + writeSharesToIDB(floCrypto.createShamirsSecretShares(privKey, threshold, threshold)).then(resultIndexes =>{ + //store index keys in localStorage + localStorage.setItem(`${floGlobals.application}#privKey`, JSON.stringify(resultIndexes)) + //also add a dummy privatekey to the IDB + var randomPrivKey = floCrypto.generateNewID().privKey + var randomThreshold = floCrypto.randInt(10,20) + writeSharesToIDB(floCrypto.createShamirsSecretShares(randomPrivKey, randomThreshold, randomThreshold)) + //resolve private Key + resolve(privKey) + }).catch(error => reject(error)) + }) } }) } From c3a51f44a7c9ad38476fbb4d6443a7cd54b409ed Mon Sep 17 00:00:00 2001 From: sairajzero Date: Thu, 6 Feb 2020 14:56:12 +0530 Subject: [PATCH 03/14] bug fix --- standard_Operations.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/standard_Operations.html b/standard_Operations.html index 3652b9d..07725d5 100644 --- a/standard_Operations.html +++ b/standard_Operations.html @@ -8608,7 +8608,7 @@ Bitcoin.Util = { if(!result) return reject("Empty Private Key") var floID = floCrypto.getFloIDfromPubkeyHex(floCrypto.getPubKeyHex(result)) - console.log(floID) + privKey = result }catch(error){ console.error(error) return reject("Invalid Private Key") From 86ea714139df968911e9424740013e3f2df3480d Mon Sep 17 00:00:00 2001 From: sairajzero Date: Sun, 16 Feb 2020 02:34:58 +0530 Subject: [PATCH 04/14] adding manage subAdmin to floDapps floDapps.manageSubAdmins() allows the user to add and/or remove subadmin list via blockchain *Requires Admin Privatekey of the app --- standard_Operations.html | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/standard_Operations.html b/standard_Operations.html index 07725d5..54c8909 100644 --- a/standard_Operations.html +++ b/standard_Operations.html @@ -8696,6 +8696,26 @@ Bitcoin.Util = { this.util.appObs = appObs }, + manageSubAdmins(adminPrivKey, addList, rmList){ + return new Promise((resolve, reject) => { + if(!Array.isArray(addList)) addList = undefined; + if(!Array.isArray(rmList)) rmList = undefined; + var floData = { + [floGlobals.application] : { + addSubAdmin : addList, + removeSubAdmin: rmList, + } + } + var floID = floCrypto.getFloIDfromPubkeyHex(floCrypto.getPubKeyHex(adminPrivKey)) + if(floID != floGlobals.adminID) + reject('Access Denied for Admin privilege') + else + floBlockchainAPI.writeData(floID, JSON.stringify(floData), adminPrivKey) + .then(result => resolve(['Updated SubAdmin List', result])) + .catch(error => reject(error)) + }) + }, + clearCredentials: function(){ var indexArr = localStorage.getItem(`${floGlobals.application}#privKey`) if(!indexArr) From d6c4b4882e3b1b7b32962941f55b713198dca53a Mon Sep 17 00:00:00 2001 From: sairajzero Date: Sun, 16 Feb 2020 02:36:35 +0530 Subject: [PATCH 05/14] changing TEST_MODE adminID --- standard_Operations.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/standard_Operations.html b/standard_Operations.html index 54c8909..96b1fe7 100644 --- a/standard_Operations.html +++ b/standard_Operations.html @@ -16,7 +16,7 @@ FLO: ['https://explorer.mediciland.com/', 'https://livenet.flocha.in/', 'https://flosight.duckdns.org/', 'http://livenet-explorer.floexperiments.com/'], FLO_TEST: ['https://testnet-flosight.duckdns.org/', 'https://testnet.flocha.in/'] }, - adminID: "FMeiptdJNtYQEtzyYAVNP8fjsDJ1i4EPfE", + adminID: "FKAEdnPfjXLHSYwrXQu377ugN4tXU7VGdf", sendAmt: 0.001, fee: 0.0005, From 47ca6a802e6c6ecf6eab04cb92f542d30469f544 Mon Sep 17 00:00:00 2001 From: sairajzero Date: Sun, 16 Feb 2020 02:38:51 +0530 Subject: [PATCH 06/14] moving onloadStartup to a seperate script tag --- standard_Operations.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/standard_Operations.html b/standard_Operations.html index 96b1fe7..b89f82c 100644 --- a/standard_Operations.html +++ b/standard_Operations.html @@ -8752,7 +8752,8 @@ Bitcoin.Util = { reactor.registerEvent("startUpErrorLog"); reactor.addEventListener("startUpErrorLog", log => console.error(log)) - + + @@ -7017,1342 +7019,1373 @@ Bitcoin.Util = {