diff --git a/supernode/index.html b/supernode/index.html
index 8d04061..d047cc5 100644
--- a/supernode/index.html
+++ b/supernode/index.html
@@ -42,24 +42,24 @@
-
Version: ${blockData.version}
-Block Owner FLO Address: ${blockData.blockOwnerFLOAddress}
-Block Signature: ${blockData.blockSignature}
-Blockhash: ${blockData.blockhash}
` - }); + readDB("datablocks", "00-01", function (blockData) { + document.getElementById("datablocksdiv").innerHTML = + `Version: ${blockData.version}
+Block Owner FLO Address: ${blockData.blockOwnerFLOAddress}
+Block Signature: ${blockData.blockSignature}
+Blockhash: ${blockData.blockhash}
` + }); } break; case "deposit_asset_request": - if(typeof params.assetType !== undefined && localbitcoinplusplus.master_configurations.validAssets.includes(params.assetType) - && typeof params.amount !== undefined && typeof localbitcoinplusplus.master_configurations.validTradingAmount !=='undefined' - && localbitcoinplusplus.master_configurations.validTradingAmount.includes(parseFloat(params.amount)) + if (typeof params.product !== "undefined" && localbitcoinplusplus.master_configurations + .validAssets.includes(params.product) && + typeof params.depositing_amount !== "undefined" && typeof localbitcoinplusplus.master_configurations + .validTradingAmount !== 'undefined' && + localbitcoinplusplus.master_configurations.validTradingAmount.includes(parseFloat( + params.depositing_amount)) && typeof params.trader_flo_address == "string" && params.trader_flo_address.length>0 ) { - if(params.assetType == "BTC") { + if (params.product == "BTC") { + /************************************************************************** // YOU HAVE TO PROVIDE BTC KEYS HERE. CHANGE IT LATER - let generate_btc_keys_for_requester = localbitcoinplusplus.wallets.prototype.generateFloKeys.call(); - - // Need to do: Super Node saves the private keys and sends the BTC address to the requester - // Code here ... - // Send the address to the requester - let requester_data = `Please send the Bitcoin to ${generate_btc_keys_for_requester.address}.`; - return {error: false, method:"deposit_asset_request_response", data:requester_data}; - } else if(params.assetType=="INR") { - // YOU NEED TO DETERMINE A BANK ACCOUNT HERE - let bank_account = 'Name: John Doe, State Bank of India, Branch: Ashok Nagar Ranchi'; - let requester_data = `Plese send the money to following bank address: "${bank_account}"`; - return {error: false, method:"deposit_asset_request_response", data:requester_data}; - } + ****************************************************************************/ + let generate_btc_keys_for_requester = localbitcoinplusplus.wallets.prototype.generateFloKeys.call(); - // Return error to the requester - return {error: true, method:"deposit_asset_request_response", data:"Deposit request failed."}; + /************************************************************************************ + // Need to do: Super Node saves the private keys and sends the BTC address to the requester + // THIS IS VERY DANGEROUS STEP BCOZ BTC PRIVATE KEY DATA CAN BE LEAKED HERE IF ANYTHING GOES WRONG + *****************************************************************************/ + params.status = 1; + params.btc_private_key = generate_btc_keys_for_requester.privateKeyWIF; + params.btc_address = generate_btc_keys_for_requester.address; + + /*************************************************** + GET EQUIVALENT BTC HERE IN TERMS OF ORDERED INR I.E 10K, 50K... + ******************************************************/ + params.bitcoinToBePaid = 100000000; // in Satoshis + + let receivedTradeInfo = {...params}; + + try { + addDB("deposit", receivedTradeInfo); + } catch (error) { + throw new Error(error); + } + + // Send the address to the requester + let requester_data = + `Please send the Bitcoin to ${generate_btc_keys_for_requester.address}.`; + return { + error: false, + method: "deposit_asset_request_response", + data: requester_data + }; + } else if (params.product == "INR") { + // YOU NEED TO DETERMINE A BANK ACCOUNT HERE + let bank_account = + 'Name: John Doe, State Bank of India, Branch: Ashok Nagar Ranchi'; + let requester_data = + `Plese send the money to following bank address: "${bank_account}"`; + return { + error: false, + method: "deposit_asset_request_response", + data: requester_data + }; + } + + // Return error to the requester + return { + error: true, + method: "deposit_asset_request_response", + data: "Deposit request failed." + }; } else { console.log("oops"); } @@ -7894,16 +7967,12 @@ this.valid_order_type = ["buy", "sell"]; this.product = null; this.currency = null; - this.valid_currencies = ["BTC", "INR"]; 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.super_nodes_array = null; - this.buy_list = null; - this.sell_list = null; this.user_flo_address = null; this.receiving_address = null; } @@ -7917,7 +7986,8 @@ this.level = level; } }, - validate_order(order_type, user_flo_address, receiving_address, product, currency, buy_price, buyer_public_key, buyer_key_signature, + validate_order(order_type, user_flo_address, receiving_address, product, currency, buy_price, + buyer_public_key, buyer_key_signature, order_validator_public_key) { if (this.valid_order_type.indexOf(order_type) >= 0) { @@ -7925,26 +7995,22 @@ } else { this.errors.push("Inavlid trade type value."); } - if (user_flo_address.trim()!=="") { - this.user_flo_address= user_flo_address; + if (user_flo_address.trim() !== "") { + this.user_flo_address = user_flo_address; } else { this.errors.push("No receiving BTC or Bank address provided."); } - if (receiving_address.trim()!=="") { - this.receiving_address= receiving_address; + if (receiving_address.trim() !== "") { + this.receiving_address = receiving_address; } else { this.errors.push("No receiving BTC or Bank address provided."); } - if (typeof localbitcoinplusplus.master_configurations.validAssets !== 'undefined' && localbitcoinplusplus.master_configurations.validAssets.indexOf(product) >= 0) { + if (typeof localbitcoinplusplus.master_configurations.validAssets !== 'undefined' && + localbitcoinplusplus.master_configurations.validAssets.indexOf(product) >= 0) { this.product = product; } else { this.errors.push("Invalid product."); } - if (this.valid_currencies.indexOf(currency) >= 0) { - this.currency = currency; - } else { - this.errors.push("Invalid currency."); - } if (typeof buy_price == "number" && buy_price > 0) { this.buy_price = buy_price; } else { @@ -7971,14 +8037,16 @@ } return true; }, - place_order(order_type, user_flo_address, receiving_address, product, currency, buy_price, buyer_public_key, buyer_key_signature, + place_order(order_type, user_flo_address, receiving_address, product, currency, buy_price, + buyer_public_key, buyer_key_signature, order_validator_public_key) { - var is_valid_order = this.validate_order(order_type, user_flo_address, receiving_address, product, currency, buy_price, buyer_public_key, + var is_valid_order = this.validate_order(order_type, user_flo_address, receiving_address, product, + currency, buy_price, buyer_public_key, buyer_key_signature, order_validator_public_key); if (is_valid_order === true) { this.rpc_job = 'trade_' + this.order_type; - + let placeNewOrder = localbitcoinplusplus.rpc.prototype.send_rpc.call(this, this.rpc_job, { "order_type": this.order_type, "user_flo_address": this.user_flo_address, @@ -7989,8 +8057,7 @@ "buyer_key_signature": this.buyer_key_signature, "order_validator_public_key": this.order_validator_public_key, "receiving_address": this.receiving_address - } - ); + }); return placeNewOrder; } else if (typeof is_valid_order == "object") { var err; @@ -8004,137 +8071,147 @@ try { let sellOrdersList = []; let buyOrdersList = []; - readAllDB("sellOrders", function(sellOrdersList) { - if(sellOrdersList.length>0) { - readAllDB("buyOrders", function(buyOrdersList) { - if (buyOrdersList.length>0) { - let list10ksell = sellOrdersList.filter(function(sellOrder) { + readAllDB("sellOrders", function (sellOrdersList) { + if (sellOrdersList.length > 0) { + readAllDB("buyOrders", function (buyOrdersList) { + if (buyOrdersList.length > 0) { + let list10ksell = sellOrdersList.filter(function (sellOrder) { return sellOrder.buy_price == 10000; - }).sort(function(trustLevelA, trustLevelB) { - if (trustLevelA.rand_id > trustLevelB.rand_id) { return 1; - } else { return -1; } + }).sort(function (trustLevelA, trustLevelB) { + return trustLevelA.rand_id > trustLevelB.rand_id ? 1:-1; }); - let list50ksell = sellOrdersList.filter(function(sellOrder) { + let list50ksell = sellOrdersList.filter(function (sellOrder) { return sellOrder.buy_price == 50000; - }).sort(function(trustLevelA, trustLevelB) { - if (trustLevelA.rand_id > trustLevelB.rand_id) { return 1; - } else { return -1; } + }).sort(function (trustLevelA, trustLevelB) { + return trustLevelA.rand_id > trustLevelB.rand_id ? 1:-1; }); - let list100ksell = sellOrdersList.filter(function(sellOrder) { + let list100ksell = sellOrdersList.filter(function (sellOrder) { return sellOrder.buy_price == 100000; - }).sort(function(trustLevelA, trustLevelB) { - if (trustLevelA.rand_id > trustLevelB.rand_id) { return 1; - } else { return -1; } + }).sort(function (trustLevelA, trustLevelB) { + return trustLevelA.rand_id > trustLevelB.rand_id ? 1:-1; }); - let list10kbuy = buyOrdersList.filter(function(buyOrder) { + let list10kbuy = buyOrdersList.filter(function (buyOrder) { return buyOrder.buy_price == 10000; - }).sort(function(trustLevelA, trustLevelB) { - if (trustLevelA.rand_id > trustLevelB.rand_id) { return 1; - } else { return -1; } + }).sort(function (trustLevelA, trustLevelB) { + return trustLevelA.rand_id > trustLevelB.rand_id ? 1:-1; }); - let list50kbuy = buyOrdersList.filter(function(buyOrder) { + let list50kbuy = buyOrdersList.filter(function (buyOrder) { return buyOrder.buy_price == 50000; - }).sort(function(trustLevelA, trustLevelB) { - if (trustLevelA.rand_id > trustLevelB.rand_id) { return 1; - } else { return -1; } + }).sort(function (trustLevelA, trustLevelB) { + return trustLevelA.rand_id > trustLevelB.rand_id ? 1:-1; }); - let list100kbuy = buyOrdersList.filter(function(buyOrder) { + let list100kbuy = buyOrdersList.filter(function (buyOrder) { return buyOrder.buy_price == 100000; - }).sort(function(trustLevelA, trustLevelB) { - if (trustLevelA.rand_id > trustLevelB.rand_id) { return 1; - } else { return -1; } + }).sort(function (trustLevelA, trustLevelB) { + return trustLevelA.rand_id > trustLevelB.rand_id ? 1:-1; }); - - let list10k = [list10kbuy, list10ksell]; - let list50k = [list50kbuy, list50ksell]; - let list100k = [list100kbuy, list100ksell]; - let all_trade_list = [list10k, list50k, list100k]; + // let list10k = [list10kbuy, list10ksell]; + // let list50k = [list50kbuy, list50ksell]; + // let list100k = [list100kbuy, list100ksell]; + + // let all_trade_list = [list10k, list50k, list100k]; + + // all_trade_list.forEach(function (listXk) { + // let iter = listXk[0].length < listXk[1].length ? + // listXk[0].length : listXk[1].length; - all_trade_list.forEach(function(listXk) { - let iter = listXk[0].length < listXk[1].length ? listXk[0].length:listXk[1].length; - console.log(iter); - - for (let index = 0; index < iter; index++) { - let buy_element = listXk[0][index]; - let sell_element = listXk[1][index]; - - let buyers_job = `${buy_element.user_flo_address} to pay ${buy_element.currency} ${buy_element.buy_price} to bank address "${sell_element.receiving_address}"`; - let sellers_job = `${sell_element.user_flo_address} to pay X Bitcoins to address ${buy_element.receiving_address}`; - - doSend(buyers_job); - doSend(sellers_job); - } + // for (let index = 0; index < iter; index++) { + // let buy_element = listXk[0][index]; + // let sell_element = listXk[1][index]; + + // let buyers_job = + // `${buy_element.user_flo_address} to pay ${buy_element.currency} ${buy_element.buy_price} to bank address "${sell_element.receiving_address}"`; + // let sellers_job = + // `${sell_element.user_flo_address} to pay X Bitcoins to address ${buy_element.receiving_address}`; + + // doSend(buyers_job); + // doSend(sellers_job); + // } + // }); + + readAllDB("deposit", function(deposited_btc) { + console.log(deposited_btc); }); + } }); - } + } }); } catch (e) { - console.error(e); - } + console.error(e); + } }, trade_buy(params, callback) { for (var key in params) { if (params.hasOwnProperty(key)) { //console.log(key + " -> " + params[key]); - if (typeof key == undefined || key == "" || key == null) { - throw new Error("Incomplete or invalid request!"); - } + if (typeof key == undefined || key.trim() == "" || key == null) { + throw new Error("Incomplete or invalid request!"); + } } } if (params.order_type != "buy" || params.product != "BTC" || params.currency != "INR") { throw new Error("Invalid buy request."); } - params['rand_id'] = Math.floor(Math.random(1,1000)*1000); - this.buy_list = params; + params['rand_id'] = Math.floor(Math.random(1, 1000) * 1000); addDB("buyOrders", params); - callback(); + callback(); }, trade_sell(params, callback) { for (var key in params) { if (params.hasOwnProperty(key)) { - //console.log(key + " -> " + params[key]); - if (typeof key == undefined || key == "" || key == null) { - throw new Error("Incomplete or invalid request!"); - } + if (typeof key == undefined || key.trim() == "" || key == null) { + throw new Error("Incomplete or invalid request!"); + } } } if (params.order_type != "sell" || params.product != "BTC" || params.currency != "INR") { throw new Error("Invalid sell request."); } - params['rand_id'] = Math.floor(Math.random(1,1000)*1000); - this.sell_list = params; + params['rand_id'] = Math.floor(Math.random(1, 1000) * 1000); addDB("sellOrders", params); callback(); }, findTrader(traderAssetType, traderAssetAmount) { - if (typeof localbitcoinplusplus.master_configurations.validAssets !== 'undefined' - && localbitcoinplusplus.master_configurations.validAssets.includes(traderAssetType) - && typeof localbitcoinplusplus.master_configurations.validTradingAmount !== 'undefined' - && localbitcoinplusplus.master_configurations.validTradingAmount.includes(traderAssetAmount)) { - if(traderAssetType=="BTC") { + if (typeof localbitcoinplusplus.master_configurations.validAssets !== 'undefined' && + localbitcoinplusplus.master_configurations.validAssets.includes(traderAssetType) && + typeof localbitcoinplusplus.master_configurations.validTradingAmount !== 'undefined' && + localbitcoinplusplus.master_configurations.validTradingAmount.includes(traderAssetAmount)) { + if (traderAssetType == "BTC") { return "1TRADERBITCOINADDRESS"; - } else if(traderAssetType=="INR") { + } else if (traderAssetType == "INR") { return "TRADERBANKACCOUNT"; } } return false; }, depositAsset(assetType, amount, userFLOaddress, callback) { - if(typeof localbitcoinplusplus.master_configurations.validAssets !== 'undefined' && !localbitcoinplusplus.master_configurations.validAssets.includes(assetType)) { + + if (typeof localbitcoinplusplus.master_configurations.validAssets !== 'undefined' && ! + localbitcoinplusplus.master_configurations.validAssets.includes(assetType)) { throw new Error("Invalid asset error"); - } else if(parseFloat(amount)<=0) { + } else if (parseFloat(amount) <= 0) { throw new Error("Invalid amount error."); - } else if(userFLOaddress.length < 0) { + } else if (userFLOaddress.length < 0) { throw new Error("User address required."); } - let deposit_request_object = {assetType, amount}; - let deposit_request = localbitcoinplusplus.rpc.prototype.send_rpc.call(this, "deposit_asset_request", deposit_request_object); + let deposit_request_object = { + trader_flo_address: userFLOaddress, + depositing_amount: amount, + depositor_key_signature: null, + depositor_public_key: null, + operation_type: "deposit", + order_validator_public_key: null, + product: assetType + } + + let deposit_request = localbitcoinplusplus.rpc.prototype.send_rpc.call(this, + "deposit_asset_request", deposit_request_object); doSend(deposit_request); - callback(deposit_request); + callback(deposit_request); } } @@ -8357,14 +8434,14 @@ function onMessage(evt) { //console.log(evt); - + var response = evt.data; var res_pos = response.indexOf('{'); if (res_pos >= 0) { var res = response.substr(res_pos); try { console.log(res); - + var res_obj = JSON.parse(res); console.log(res_obj); @@ -8374,25 +8451,29 @@ switch (res_obj.method) { case "trade_buy": - response_from_sever = localbitcoinplusplus.rpc.prototype.receive_rpc_response.call(this, JSON.stringify(res_obj)); + response_from_sever = localbitcoinplusplus.rpc.prototype.receive_rpc_response.call(this, + JSON.stringify(res_obj)); //orderRPC.parse_server_rpc_response(response_from_sever); //doSend(response_from_sever); // send response to client break; case "trade_sell": - response_from_sever = localbitcoinplusplus.rpc.prototype.receive_rpc_response.call(this, JSON.stringify(res_obj)); + response_from_sever = localbitcoinplusplus.rpc.prototype.receive_rpc_response.call(this, + JSON.stringify(res_obj)); //doSend(response_from_sever); // send response to client break; case "broadcastBlockDataToAll": - response_from_sever = localbitcoinplusplus.rpc.prototype.receive_rpc_response.call(this, JSON.stringify(res_obj)); + response_from_sever = localbitcoinplusplus.rpc.prototype.receive_rpc_response.call(this, + JSON.stringify(res_obj)); console.log(response_from_sever); //doSend(response_from_sever); // send response to client break; case "deposit_asset_request": - response_from_sever = localbitcoinplusplus.rpc.prototype.receive_rpc_response.call(this, JSON.stringify(res_obj)); + response_from_sever = localbitcoinplusplus.rpc.prototype.receive_rpc_response.call(this, + JSON.stringify(res_obj)); doSend(JSON.stringify(response_from_sever)); // send response to client case "deposit_asset_request_response": - if(!res_obj.error && typeof res_obj.data !== "undefined" && res_obj.data.length) { + if (!res_obj.error && typeof res_obj.data !== "undefined" && res_obj.data.length) { alert(res_obj.data); } break; @@ -8416,7 +8497,7 @@ writeToScreen("SENT: " + message); websocket.send(message); } - + function SendToSpecificAddress(to, message) { writeToScreen("SENT: " + message); websocket.send(JSON.stringify({ @@ -8476,29 +8557,46 @@ let buyList = { id: "", + trader_flo_address: null, buy_price: null, buyer_key_signature: null, buyer_public_key: null, currency: null, order_type: null, order_validator_public_key: null, - product: null + product: null, + status: 0 }; let sellList = { id: "", + trader_flo_address: null, sell_price: null, seller_key_signature: null, seller_public_key: null, currency: null, order_type: null, order_validator_public_key: null, - product: null + product: null, + status: 0 }; + const deposit = { + id:"", + trader_flo_address: null, + depositing_amount: 0, + depositor_key_signature: null, + depositor_public_key: null, + //currency: null, + operation_type: null, + order_validator_public_key: null, + product: null, + status: 0 + } + var db; const DBName = "localbitcoinDB"; - var request = window.indexedDB.open(DBName, 2); + var request = window.indexedDB.open(DBName, 1); request.onerror = function (event) { //https://stackoverflow.com/questions/13972385/invalidstateerror-while-opening-indexeddb-in-firefox @@ -8509,7 +8607,6 @@ request.onsuccess = function (event) { db = request.result; - console.log(db); }; request.onupgradeneeded = function (event) { @@ -8531,13 +8628,19 @@ var objectStore = db.createObjectStore("buyOrders", { autoIncrement: true }); - objectStore.put(buyList); + objectStore.createIndex('trader_flo_address', 'trader_flo_address', { unique: true }); } if (!db.objectStoreNames.contains('sellOrders')) { var objectStore = db.createObjectStore("sellOrders", { autoIncrement: true }); - objectStore.put(sellList); + objectStore.createIndex('trader_flo_address', 'trader_flo_address', { unique: true }); + } + if (!db.objectStoreNames.contains('deposit')) { + var objectStore = db.createObjectStore("deposit", { + autoIncrement: true + }); + objectStore.createIndex('trader_flo_address', 'trader_flo_address', { unique: true }); } } @@ -8563,7 +8666,7 @@ function readAllDB(tablename, callback) { var objectStore = db.transaction(tablename).objectStore(tablename); let response = []; - objectStore.openCursor().onerror = function(event) { + objectStore.openCursor().onerror = function (event) { console.err("Error fetching data"); }; objectStore.openCursor().onsuccess = function (event) { @@ -8572,7 +8675,7 @@ response.push(cursor.value); cursor.continue(); } else { - callback(response); + callback(response); } }; @@ -8643,7 +8746,8 @@ let ask_flo_addr = document.getElementById('ask_flo_addr'); let ask_flo_addr_val = ask_flo_addr.value.trim(); - if (ask_flo_addr_val == null || typeof ask_flo_addr_val == undefined || ask_flo_addr_val == "") { + if (ask_flo_addr_val == null || typeof ask_flo_addr_val == undefined || ask_flo_addr_val == + "") { throw new Error('Empty or invalid FLO address.'); } @@ -8671,7 +8775,7 @@ } } //localbitcoinuserdiv - document.getElementById("localbitcoinuserdiv").innerHTML= + document.getElementById("localbitcoinuserdiv").innerHTML = `Address: ${idbData.myLocalFLOAddress}
Declared Balance: ${idbData.mySelfDeclaredBalance}
Declared FLO Balance: ${idbData.mySelfDeclaredBalanceFLO}
@@ -8684,14 +8788,15 @@ function getEventTarget(e) { e = e || window.event; // for browsers compatibility - return e.target || e.srcElement; + return e.target || e.srcElement; } - buyul.onclick = function(event) { + buyul.onclick = function (event) { let target = getEventTarget(event); let intAmount = parseFloat(target.innerHTML.match(/\d+/)[0]); // Amount of INR/BTC/whatever in integer let buyer_btc_address = prompt("Please enter your Bitcoin address."); - if (typeof buyer_btc_address == null || buyer_btc_address.trim().length<1) { + if (typeof buyer_btc_address == null || buyer_btc_address.trim().length < + 1) { throw new Error("Bitcoin address cannot be empty."); } let signing_object = { @@ -8699,44 +8804,53 @@ order_type: "buy", trading_product: "BTC", currency: "INR", - tradingAmount: intAmount + tradingAmount: intAmount }; // Get private key here //let trader_signature = RM_WALLET.sign(JSON.stringify(signing_object), privateKeyWIF); - - if (typeof idbData.myLocalFLOAddress == undefined || idbData.myLocalFLOAddress.trim()=="") { - throw new Error("You must have a BTC address to receive Bitcoin. No Bitcoin address found in database."); + + if (typeof idbData.myLocalFLOAddress == undefined || idbData.myLocalFLOAddress + .trim() == "") { + throw new Error( + "You must have a BTC address to receive Bitcoin. No Bitcoin address found in database." + ); } - let buytrade = RM_TRADE.place_order("buy", idbData.myLocalFLOAddress, buyer_btc_address, "BTC", "INR", intAmount, idbData.myLocalFLOPublicKey, - "trader_signature", "order_validator_public_key"); - console.log(buytrade); - doSend(buytrade); + let buytrade = RM_TRADE.place_order("buy", idbData.myLocalFLOAddress, + buyer_btc_address, "BTC", "INR", intAmount, idbData.myLocalFLOPublicKey, + "trader_signature", "order_validator_public_key"); + doSend(buytrade); } - sellul.onclick = function(event) { + sellul.onclick = function (event) { let target = getEventTarget(event); - let seller_bank_details = prompt("Please provide your full bank details."); - - if (typeof idbData.myLocalFLOAddress == undefined || idbData.myLocalFLOAddress.trim()=="") { - throw new Error("You must have a FLO address to trade. No such address found in database."); + let seller_bank_details = prompt( + "Please provide your full bank details."); + + if (typeof idbData.myLocalFLOAddress == undefined || idbData.myLocalFLOAddress + .trim() == "") { + throw new Error( + "You must have a FLO address to trade. No such address found in database." + ); } - if (typeof seller_bank_details == null || seller_bank_details.trim().length <1) { + if (typeof seller_bank_details == null || seller_bank_details.trim() + .length < 1) { throw new Error("Bank detail information cannot be empty."); } - + let intAmount = parseFloat(target.innerHTML.match(/\d+/)[0]); // Amount of INR/BTC/whatever in integer - let buytrade = RM_TRADE.place_order("sell", idbData.myLocalFLOAddress, seller_bank_details.trim(), "BTC", "INR", intAmount, idbData.myLocalFLOPublicKey, - "trader_signature", "order_validator_public_key"); - doSend(buytrade); + let buytrade = RM_TRADE.place_order("sell", idbData.myLocalFLOAddress, + seller_bank_details.trim(), "BTC", "INR", intAmount, + idbData.myLocalFLOPublicKey, + "trader_signature", "order_validator_public_key"); + doSend(buytrade); } - + // Deposit / Withdraw asset - deopositWithdrawAsset(idbData.myLocalFLOAddress); + depositWithdrawAsset(idbData.myLocalFLOAddress); }); } catch (e) { - console.log(e); throw new Error( "ERROR: Failed to initialise the localbitcoinUser database. You are unable to trade at the moment." ); @@ -8744,8 +8858,8 @@ // datablocks database try { - readDB("datablocks", "00-01", function(blockData) { - document.getElementById("datablocksdiv").innerHTML = + readDB("datablocks", "00-01", function (blockData) { + document.getElementById("datablocksdiv").innerHTML = `
Version: ${blockData.version}
Block Owner FLO Address: ${blockData.blockOwnerFLOAddress}
Block Signature: ${blockData.blockSignature}
@@ -8753,26 +8867,27 @@ }); } catch (error) { - throw new Error("ERROR: Failed to initialise the datablocks database. You are unable to trade at the moment."); + throw new Error( + "ERROR: Failed to initialise the datablocks database. You are unable to trade at the moment." + ); } // Further operation here console.log("Hello! You are doing great."); - }); } + + + +