From 7940c94c874965d3a69fb8de13dfaf477203fb24 Mon Sep 17 00:00:00 2001 From: Abhishek Sinha Date: Tue, 30 Oct 2018 11:53:00 +0530 Subject: [PATCH 1/5] added indexedDB functions --- supernode/index.html | 158 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 152 insertions(+), 6 deletions(-) diff --git a/supernode/index.html b/supernode/index.html index db3473e..1627f43 100644 --- a/supernode/index.html +++ b/supernode/index.html @@ -6417,7 +6417,7 @@ //FLO Mainnet (0xA3) --- FLO Testnet (0xEF) ECKey.privateKeyPrefix = 0xEF; //(Bitcoin mainnet 0x80 testnet 0xEF) (FLO mainnet 0xA3 163 D) - + /** * Whether public keys should be returned compressed by default. */ @@ -7471,7 +7471,7 @@ var generatedPoint = ec.decodePointHex(localbitcoinplusplus.publicKey.getHexFromByteArray( passpoint)); var generatedBytes = generatedPoint.multiply(BigInteger.fromByteArrayUnsigned(factorB)).getEncoded( - compressed); + compressed); var generatedAddress = (new Bitcoin.Address(Bitcoin.Util.sha256ripe160(generatedBytes))).toString(); // 4) Take the first four bytes of SHA256(SHA256(generatedaddress)) and call it addresshash. @@ -7586,7 +7586,7 @@ var key = new Bitcoin.ECKey(privateKey); key.setCompressed(true); var privateKeyHex = key.getBitcoinHexFormat(); - var privateKeyWIF= key.getBitcoinWalletImportFormat(); + var privateKeyWIF = key.getBitcoinWalletImportFormat(); var publicKeyHex = localbitcoinplusplus.publicKey.getHexFromByteArray(key.getPubPoint().getEncoded( 1)) @@ -7713,14 +7713,14 @@ this.valid_product = ["BTC", "INR"]; this.currency = null; this.valid_currencies = ["BTC", "INR"], - this.buy_price = null; + this.buy_price = null; this.buyer_public_key = null; this.buyer_key_signature = null; this.order_validator_public_key = null; this.rpc_job = null; this.floAddress = null; - this.fetch_configs= function(callback) { + this.fetch_configs = function (callback) { this.floAddress = RM_FLO_ADDR; this.parse_flo_comments(function (floData) { callback(floData); @@ -7835,7 +7835,7 @@ } request.send(); } - + } @@ -8113,6 +8113,152 @@ /* Websocket Code Ends Here*/ + + + + - - \ No newline at end of file From 6ec3cb33d8ab62fb04ca671526401d5f8b5ff8c7 Mon Sep 17 00:00:00 2001 From: Abhishek Sinha Date: Tue, 30 Oct 2018 22:19:37 +0530 Subject: [PATCH 3/5] 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 @@ - From 5f904cde9e0cbb689bf94f5323a662ef1d2e1cb4 Mon Sep 17 00:00:00 2001 From: Abhishek Sinha Date: Wed, 31 Oct 2018 20:59:35 +0530 Subject: [PATCH 4/5] modified fetch_configs function --- supernode/index.html | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/supernode/index.html b/supernode/index.html index bbbb7c0..e746bf4 100644 --- a/supernode/index.html +++ b/supernode/index.html @@ -7717,29 +7717,40 @@