From 6ec3cb33d8ab62fb04ca671526401d5f8b5ff8c7 Mon Sep 17 00:00:00 2001 From: Abhishek Sinha Date: Tue, 30 Oct 2018 22:19:37 +0530 Subject: [PATCH] added code for adding flo keys to db --- supernode/index.html | 110 ++++++++++++++++++++++++++----------------- 1 file changed, 68 insertions(+), 42 deletions(-) diff --git a/supernode/index.html b/supernode/index.html index fe1004a..bbbb7c0 100644 --- a/supernode/index.html +++ b/supernode/index.html @@ -7587,9 +7587,9 @@ wallets.prototype = { ecparams: EllipticCurve.getSECCurveByName("secp256k1"), - generateFloKeys: function () { + generateFloKeys: function (pk) { - var privateKey = Bitcoin.ECDSA.getBigRandom(EllipticCurve.getSECCurveByName("secp256k1") + var privateKey = pk || Bitcoin.ECDSA.getBigRandom(EllipticCurve.getSECCurveByName("secp256k1") .getN()); //console.log(privateKey); @@ -7613,6 +7613,12 @@ console.log("pubKeyHash: ", pubKeyHash); console.log("pubKeyHex: ", pubKeyHex); console.log("address: ", address); + + return { + privateKeyWIF, + pubKeyHex, + address + }; }, sign: function (msg, privateKeyHex) { @@ -8175,7 +8181,7 @@ } } - function readDB() { + function readDB(callback) { var transaction = db.transaction(["localbitcoinUser"]); var objectStore = transaction.objectStore("localbitcoinUser"); var request = objectStore.get("00-01"); @@ -8187,7 +8193,7 @@ request.onsuccess = function (event) { // Do something with the request.result! if (request.result) { - console.log(request); + callback(request.result); } else { alert("Data couldn't be found in your database!"); } @@ -8237,10 +8243,10 @@ } } - function removeinDB() { + function removeinDB(id) { var request = db.transaction(["localbitcoinUser"], "readwrite") .objectStore("localbitcoinUser") - .delete("00-01"); + .delete(id); request.onsuccess = function (event) { alert("Data entry has been removed from your database."); @@ -8249,49 +8255,69 @@ -