changed _readDB to readDB while getting supernode pub key while trade buy, sell, balance updates

This commit is contained in:
Abhishek Sinha 2019-05-27 16:33:44 +05:30
parent 8d43e33e8e
commit 07cea65783

View File

@ -14030,7 +14030,7 @@
let res_btc; let res_btc;
// supernode data query // supernode data query
_readDB('localbitcoinUser', '00-01').then(function (user_data) { readDB('localbitcoinUser', '00-01').then(function (user_data) {
if (typeof user_data == "object" && typeof localbitcoinplusplus.wallets if (typeof user_data == "object" && typeof localbitcoinplusplus.wallets
.MY_SUPERNODE_PRIVATE_KEY == .MY_SUPERNODE_PRIVATE_KEY ==
"string" && localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY "string" && localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY
@ -14130,7 +14130,7 @@
} }
// supernode data query // supernode data query
_readDB('localbitcoinUser', '00-01').then(function (user_data) { readDB('localbitcoinUser', '00-01').then(function (user_data) {
if (typeof user_data == "object" && typeof localbitcoinplusplus.wallets if (typeof user_data == "object" && typeof localbitcoinplusplus.wallets
.MY_SUPERNODE_PRIVATE_KEY == .MY_SUPERNODE_PRIVATE_KEY ==
"string" && localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY "string" && localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY
@ -14629,7 +14629,7 @@
} }
// supernode data query // supernode data query
_readDB('localbitcoinUser', '00-01') readDB('localbitcoinUser', '00-01')
.then( .then(
function (user_data) { function (user_data) {
if (typeof user_data == if (typeof user_data ==
@ -16856,9 +16856,13 @@
// Only the relevent user node should get response // Only the relevent user node should get response
if(buyOrders_data.trader_flo_address !== localbitcoinplusplus.wallets.my_local_flo_address) return; if(buyOrders_data.trader_flo_address !== localbitcoinplusplus.wallets.my_local_flo_address) return;
if (typeof localbitcoinplusplus.master_configurations.supernodesPubKeys == "object" && if (typeof localbitcoinplusplus.master_configurations.supernodesPubKeys == "object"
localbitcoinplusplus.master_configurations.supernodesPubKeys.includes( // Commented this because it prevents usernode to register data in db
buyOrders_data.supernodePubKey)) { // while a backup supernode sends it any data like trade_buy
// && localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(
// buyOrders_data.supernodePubKey)
) {
let isDataSignedBySuperNode = RM_WALLET let isDataSignedBySuperNode = RM_WALLET
.verify(buyOrders_data.data_hash, buyOrders_data.supernode_sign, .verify(buyOrders_data.data_hash, buyOrders_data.supernode_sign,
buyOrders_data.supernodePubKey); buyOrders_data.supernodePubKey);
@ -16881,10 +16885,13 @@
// Only the relevent user node should get response // Only the relevent user node should get response
if(res_obj.params[0].trader_flo_address !== localbitcoinplusplus.wallets.my_local_flo_address) return; if(res_obj.params[0].trader_flo_address !== localbitcoinplusplus.wallets.my_local_flo_address) return;
if (typeof localbitcoinplusplus.master_configurations.supernodesPubKeys == "object" && if (typeof localbitcoinplusplus.master_configurations.supernodesPubKeys == "object"
localbitcoinplusplus.master_configurations.supernodesPubKeys.includes( // Commented this because it prevents usernode to register data in db
sellOrders_data // while a backup supernode sends it any data like trade_buy
.supernodePubKey)) {
// && localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(
// sellOrders_data.supernodePubKey)
) {
let isDataSignedBySuperNode = RM_WALLET let isDataSignedBySuperNode = RM_WALLET
.verify(sellOrders_data.data_hash, sellOrders_data.supernode_sign, .verify(sellOrders_data.data_hash, sellOrders_data.supernode_sign,
sellOrders_data.supernodePubKey); sellOrders_data.supernodePubKey);
@ -17060,8 +17067,8 @@
`${trade_info_str}${buyer_cash_data_str}${seller_cash_data_str}${buyer_btc_data_str}${seller_btc_data_str}`; `${trade_info_str}${buyer_cash_data_str}${seller_cash_data_str}${buyer_btc_data_str}${seller_btc_data_str}`;
let hashed_data = Crypto.SHA256(res_str); let hashed_data = Crypto.SHA256(res_str);
if (localbitcoinplusplus.master_configurations.supernodesPubKeys.includes( // if (localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(
trade_balance_res.supernodePubKey)) { // trade_balance_res.supernodePubKey)) {
if (RM_WALLET.verify(hashed_data, if (RM_WALLET.verify(hashed_data,
trade_balance_res.supernode_sign, trade_balance_res.supernodePubKey)) { trade_balance_res.supernode_sign, trade_balance_res.supernodePubKey)) {
@ -17089,7 +17096,7 @@
throw new Error(error); throw new Error(error);
} }
} }
} //}
} }
break; break;
case "store_shamirs_secret_pvtkey_shares": case "store_shamirs_secret_pvtkey_shares":
@ -17114,7 +17121,10 @@
} }
break; break;
case "send_back_shamirs_secret_supernode_pvtkey": case "send_back_shamirs_secret_supernode_pvtkey":
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") { if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object"
&& localbitcoinplusplus.master_configurations.supernodesPubKeys
.includes(localbitcoinplusplus.wallets.my_local_flo_public_key)
) {
if(typeof res_obj.globalParams.primarySupernode !="string") return; if(typeof res_obj.globalParams.primarySupernode !="string") return;
localbitcoinplusplus.kademlia.determineClosestSupernode(res_obj.globalParams.primarySupernode) localbitcoinplusplus.kademlia.determineClosestSupernode(res_obj.globalParams.primarySupernode)