From 856bb82ce789c2f9ddd2a8eb8c13302bcdbedf3d Mon Sep 17 00:00:00 2001 From: Abhishek Sinha Date: Sun, 29 Sep 2019 21:30:06 +0530 Subject: [PATCH] fixed fetch_config and consequent glitches in index and cash_payments_handler files --- supernode/cash_payments_handler.html | 2 +- supernode/index.html | 74 +++++++--------------------- 2 files changed, 20 insertions(+), 56 deletions(-) diff --git a/supernode/cash_payments_handler.html b/supernode/cash_payments_handler.html index 7f566dd..dbb0521 100644 --- a/supernode/cash_payments_handler.html +++ b/supernode/cash_payments_handler.html @@ -12876,7 +12876,7 @@ key = Obj[store.keyPath]; } let objectStoreRequest = store.get(key); - objectStoreRequest.onsuccess = async function(event) { + objectStoreRequest.onsuccess = function(event) { var myRecord = objectStoreRequest.result; if (typeof myRecord !== "object") { Obj.vectorClock = 1; diff --git a/supernode/index.html b/supernode/index.html index debdbbe..bccfe21 100644 --- a/supernode/index.html +++ b/supernode/index.html @@ -11522,7 +11522,7 @@ }); Object.defineProperty(localbitcoinplusplus, "RM_FLO_SENDING_ADDR", { - value: "oUbQYNBo7hWRcVN4dnx2ZQPfumfnTS7NsP", + value: "ocKKEivXC3TA8yf3ZEyh2kRMDgSh99y1a7", writable: false, configurable: false, enumerable: true @@ -12065,62 +12065,28 @@ }; localbitcoinplusplus.actions = { - parse_flo_comments: function(callback) { - return callback("fofof"); - if (this.floAddress == null) { - return false; - } - var request = new XMLHttpRequest(); + parse_flo_comments: async function(callback) { + const master_data = await helper_functions + .ajaxGet(`${localbitcoinplusplus.server.flo_testnet}/api/txs/?address=${localbitcoinplusplus.RM_FLO_SENDING_ADDR}`); + if(typeof master_data==="object" && typeof master_data.txs==="object") { + let text = ''; + let tx_cmnt_arr = []; - request.open( - "GET", - `${localbitcoinplusplus.server.flo_testnet}/api/txs/?address=${this.floAddress}`, - true - ); - request.onload = function() { - // Begin accessing JSON data here - var data = JSON.parse(this.response); - - if (request.status >= 200 && request.status < 400) { - data.txs.forEach(tx => { - if ( - typeof tx !== "undefined" && - typeof tx.floData == "string" && - tx.floData.length > 0 - ) { - callback(tx.floData); + for(txt of master_data.txs) { + if(txt.vin[0].addr === localbitcoinplusplus.RM_FLO_SENDING_ADDR) { + if(txt.floData.length===0) break; + tx_cmnt_arr.push(txt.floData); + } } - }); - } else { - console.log("error"); + + tx_cmnt_arr.reverse().map(m=>text += m.replace('text:', '')); + callback(text); } - }; - request.send(); }, fetch_configs: function(callback) { - this.floAddress = localbitcoinplusplus.RM_FLO_SENDING_ADDR; this.parse_flo_comments(function(floData) { - let RMAssets = floData.slice(5); - - // remove this line later - // btcTradeMargin is tolerable difference between Crypto trader should deposit and cryptos he actually deposited - RMAssets = `masterFLOPubKey=029EF7838D4D103E62262394B5417E8ABFD75539D19E61CA5FD0C2051B69B29910 - #!#tradableAsset1=BTC,FLO,BTC_TEST,FLO_TEST#!#tradableAsset2=INR,USD, - #!#validTradingAmount=10,50,100,#!#btcTradeMargin=5000 - #!#MaxBackups=2 - #!#miners_fee={"btc":0.0003, "flo":0.0003} - #!#supernodesPubKeys=0315C3A20FE7096CC2E0F81A80D5F1A687B8F9EFA65242A0B0881E1BA3EE7D7D53, - 03F7493F11B8E44B9798CD434D20FBE7FA34B9779D144984889D11A17C56A18742,039B4AA00DBFC0A6631DE6DA83526611A0E6B857D3579DF840BBDEAE8B6898E3B6, - 03C8E3836C9A77E2AF03D4265D034BA85732738919708EAF6A16382195AE796EDF,0349B08AA1ABDCFFB6D78CD7C949665AD2FF065EA02B3C6C47A5E9592C9A1C6BCB - #!#externalFiles={"d3js":"58f54395efa8346e8e94d12609770f66b916897e7f4e05f6c98780cffa5c70a3"} - #!#cashiers={"032871A74D2DDA9D0DE7135F58B5BD2D7F679D2CCA20EA7909466D1A6912DF4022":"johnDoe@upi"} - #!#ShamirsMaxShares=8#!#supernodeSeeds={"ranchimall1":{"ip":"127.0.0.1","port":"9111","kbucketId":"oZxHcbSf1JC8t5GjutopWYXs7C6Fe9p7ps"}, - "ranchimall2":{"ip":"127.0.0.1","port":"9112","kbucketId":"oTWjPupy3Z7uMdPcu5uXd521HBkcsLuSuM"}, - "ranchimall3":{"ip":"127.0.0.1","port":"9113","kbucketId":"odYA6KagmbokSh9GY7yAfeTUZRtZLwecY1"}, - "ranchimall4":{"ip":"127.0.0.1","port":"9114","kbucketId":"oJosrve9dBv2Hj2bfncxv2oEpTysg3Wejv"}, - "ranchimall5":{"ip":"127.0.0.1","port":"9115","kbucketId":"oMhv5sAzqg77sYHxmUGZWKRrVo4P4JQduS"}}`; - + let RMAssets = floData.trim(); let floAssetsArray = RMAssets.split("#!#"); if ( @@ -12150,7 +12116,7 @@ configurable: false, enumerable: true } - ); + ); }); deepFreeze(localbitcoinplusplus.master_configurations); return callback(localbitcoinplusplus); @@ -12565,7 +12531,6 @@ "withdraw_btc", "crypto_balances", "cash_balances", - "userPublicData", "buyOrders", "sellOrders" ]; @@ -12594,9 +12559,8 @@ } else { const allUsersData = await readAllDB("userPublicData"); - const supernodesFloList = localbitcoinplusplus.master_configurations.supernodesPubKeys.map( - s => bitjs.FLO_TEST.pubkey2address(s) - ); + const supernodesFloList = localbitcoinplusplus.master_configurations.supernodesPubKeys + .map(s => bitjs.FLO_TEST.pubkey2address(s)); for (let f = 0; f < allUsersData.length; f++) { let closestSu = await localbitcoinplusplus.kademlia.determineClosestSupernode(