fixed minor issues in primary operations
This commit is contained in:
parent
6b5565f806
commit
915c2d7cd4
@ -15796,6 +15796,7 @@
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "trade_balance_updates":
|
case "trade_balance_updates":
|
||||||
|
if(!localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(res_obj.nodePubKey)) return;
|
||||||
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
||||||
const trade_balance_res = res_obj.params[0];
|
const trade_balance_res = res_obj.params[0];
|
||||||
// Verify data
|
// Verify data
|
||||||
@ -15809,10 +15810,6 @@
|
|||||||
`${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);
|
||||||
|
|
||||||
RM_RPC.filter_legit_requests(trade_balance_res.trade_infos.buyer_flo_id,
|
|
||||||
function (is_valid_request) {
|
|
||||||
if (is_valid_request !== true) return false;
|
|
||||||
|
|
||||||
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,
|
||||||
@ -15842,7 +15839,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "store_shamirs_secret_pvtkey_shares":
|
case "store_shamirs_secret_pvtkey_shares":
|
||||||
@ -16267,21 +16263,17 @@
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "updateUserCryptoBalanceRequest":
|
case "updateUserCryptoBalanceRequest":
|
||||||
|
if (localbitcoinplusplus.master_configurations.supernodesPubKeys
|
||||||
|
.includes(res_obj.nodePubKey)) {
|
||||||
let updateUserCryptoBalanceResponseObject = res_obj.params[0];
|
let updateUserCryptoBalanceResponseObject = res_obj.params[0];
|
||||||
let SuPubKey = readDB('userPublicData', updateUserCryptoBalanceResponseObject.trader_flo_address)
|
|
||||||
.then(user_data => {
|
|
||||||
if (typeof user_data !== "object" || user_data.supernode_flo_public_key.length <
|
|
||||||
1)
|
|
||||||
throw new Error(`No such user exists.`);
|
|
||||||
let updateUserCryptoBalanceResponseString = JSON.stringify(
|
let updateUserCryptoBalanceResponseString = JSON.stringify(
|
||||||
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject);
|
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject);
|
||||||
let isBalanceLegit = RM_WALLET.verify(updateUserCryptoBalanceResponseString,
|
let isBalanceLegit = RM_WALLET.verify(updateUserCryptoBalanceResponseString,
|
||||||
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObjectSign,
|
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObjectSign,
|
||||||
user_data.supernode_flo_public_key
|
res_obj.nodePubKey
|
||||||
);
|
);
|
||||||
if (isBalanceLegit) {
|
if (isBalanceLegit) {
|
||||||
updateinDB("crypto_balances", updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject,
|
updateinDB("crypto_balances", updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject);
|
||||||
user_data.trader_flo_address);
|
|
||||||
if (localbitcoinplusplus.wallets.my_local_flo_address ==
|
if (localbitcoinplusplus.wallets.my_local_flo_address ==
|
||||||
updateUserCryptoBalanceResponseObject.trader_flo_address) {
|
updateUserCryptoBalanceResponseObject.trader_flo_address) {
|
||||||
displayBalances(updateUserCryptoBalanceResponseObject.trader_flo_address);
|
displayBalances(updateUserCryptoBalanceResponseObject.trader_flo_address);
|
||||||
@ -16291,7 +16283,7 @@
|
|||||||
} else {
|
} else {
|
||||||
showMessage(`WARNING: Failed to update balance in your DB. Please refresh.`);
|
showMessage(`WARNING: Failed to update balance in your DB. Please refresh.`);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "addNewKbucketNode":
|
case "addNewKbucketNode":
|
||||||
@ -17029,6 +17021,7 @@
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "trade_balance_updates":
|
case "trade_balance_updates":
|
||||||
|
if(!localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(res_obj.nodePubKey)) return;
|
||||||
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
||||||
const trade_balance_res = res_obj.params[0];
|
const trade_balance_res = res_obj.params[0];
|
||||||
// Verify data
|
// Verify data
|
||||||
@ -17042,10 +17035,6 @@
|
|||||||
`${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);
|
||||||
|
|
||||||
RM_RPC.filter_legit_backup_requests(trade_balance_res.trade_infos.buyer_flo_id,
|
|
||||||
function (is_valid_request) {
|
|
||||||
if (is_valid_request !== true) return false;
|
|
||||||
|
|
||||||
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,
|
||||||
@ -17076,12 +17065,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "store_shamirs_secret_pvtkey_shares":
|
case "store_shamirs_secret_pvtkey_shares":
|
||||||
|
if (localbitcoinplusplus.master_configurations.supernodesPubKeys
|
||||||
|
.includes(localbitcoinplusplus.wallets.my_local_flo_public_key)) {
|
||||||
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
||||||
|
|
||||||
if(typeof res_obj.params[0].trader_flo_address !="string") return;
|
if(typeof res_obj.params[0].trader_flo_address !="string") return;
|
||||||
localbitcoinplusplus.kademlia.determineClosestSupernode(res_obj.params[0].trader_flo_address)
|
localbitcoinplusplus.kademlia.determineClosestSupernode(res_obj.params[0].trader_flo_address)
|
||||||
.then(my_closest_su_list=>{
|
.then(my_closest_su_list=>{
|
||||||
@ -17097,6 +17086,7 @@
|
|||||||
backup_server_db_instance.backup_addDB("supernode_private_key_chunks", res_obj.params[0]);
|
backup_server_db_instance.backup_addDB("supernode_private_key_chunks", res_obj.params[0]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
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") {
|
||||||
@ -17596,21 +17586,18 @@
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "updateUserCryptoBalanceRequest":
|
case "updateUserCryptoBalanceRequest":
|
||||||
|
if (localbitcoinplusplus.master_configurations.supernodesPubKeys
|
||||||
|
.includes(res_obj.nodePubKey)) {
|
||||||
let updateUserCryptoBalanceResponseObject = res_obj.params[0];
|
let updateUserCryptoBalanceResponseObject = res_obj.params[0];
|
||||||
let SuPubKey = readDB('userPublicData', updateUserCryptoBalanceResponseObject.trader_flo_address)
|
|
||||||
.then(user_data => {
|
|
||||||
if (typeof user_data !== "object" || user_data.supernode_flo_public_key.length <
|
|
||||||
1)
|
|
||||||
throw new Error(`No such user exists.`);
|
|
||||||
let updateUserCryptoBalanceResponseString = JSON.stringify(
|
let updateUserCryptoBalanceResponseString = JSON.stringify(
|
||||||
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject);
|
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject);
|
||||||
let isBalanceLegit = RM_WALLET.verify(updateUserCryptoBalanceResponseString,
|
let isBalanceLegit = RM_WALLET.verify(updateUserCryptoBalanceResponseString,
|
||||||
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObjectSign,
|
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObjectSign,
|
||||||
user_data.supernode_flo_public_key
|
res_obj.nodePubKey
|
||||||
);
|
);
|
||||||
if (isBalanceLegit) {
|
if (isBalanceLegit) {
|
||||||
updateinDB("crypto_balances", updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject,
|
updateinDB("crypto_balances", updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject,
|
||||||
user_data.trader_flo_address);
|
updateUserCryptoBalanceResponseObject.trader_flo_address);
|
||||||
if (localbitcoinplusplus.wallets.my_local_flo_address ==
|
if (localbitcoinplusplus.wallets.my_local_flo_address ==
|
||||||
updateUserCryptoBalanceResponseObject.trader_flo_address) {
|
updateUserCryptoBalanceResponseObject.trader_flo_address) {
|
||||||
displayBalances(updateUserCryptoBalanceResponseObject.trader_flo_address);
|
displayBalances(updateUserCryptoBalanceResponseObject.trader_flo_address);
|
||||||
@ -17620,7 +17607,8 @@
|
|||||||
} else {
|
} else {
|
||||||
showMessage(`WARNING: Failed to update balance in your DB. Please refresh.`);
|
showMessage(`WARNING: Failed to update balance in your DB. Please refresh.`);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "addNewKbucketNode":
|
case "addNewKbucketNode":
|
||||||
@ -18165,7 +18153,7 @@
|
|||||||
buyOrders_data.supernodePubKey);
|
buyOrders_data.supernodePubKey);
|
||||||
if (isDataSignedBySuperNode === true) {
|
if (isDataSignedBySuperNode === true) {
|
||||||
|
|
||||||
let getPrimarySuObj = await localbitcoinplusplus.kademlia.determineClosestSupernode(res_obj[0].trader_flo_address);
|
let getPrimarySuObj = await localbitcoinplusplus.kademlia.determineClosestSupernode(buyOrders_data.trader_flo_address);
|
||||||
const primarySupernode = getPrimarySuObj[0].data.id;
|
const primarySupernode = getPrimarySuObj[0].data.id;
|
||||||
const backup_server_db_instance = localbitcoinplusplus.newBackupDatabase.db[primarySupernode];
|
const backup_server_db_instance = localbitcoinplusplus.newBackupDatabase.db[primarySupernode];
|
||||||
|
|
||||||
@ -18192,7 +18180,7 @@
|
|||||||
.verify(sellOrders_data.data_hash, sellOrders_data.supernode_sign,
|
.verify(sellOrders_data.data_hash, sellOrders_data.supernode_sign,
|
||||||
sellOrders_data.supernodePubKey);
|
sellOrders_data.supernodePubKey);
|
||||||
if (isDataSignedBySuperNode === true) {
|
if (isDataSignedBySuperNode === true) {
|
||||||
let getPrimarySuObj = await localbitcoinplusplus.kademlia.determineClosestSupernode(res_obj[0].trader_flo_address);
|
let getPrimarySuObj = await localbitcoinplusplus.kademlia.determineClosestSupernode(sellOrders_data.trader_flo_address);
|
||||||
const primarySupernode = getPrimarySuObj[0].data.id;
|
const primarySupernode = getPrimarySuObj[0].data.id;
|
||||||
const backup_server_db_instance = localbitcoinplusplus.newBackupDatabase.db[primarySupernode];
|
const backup_server_db_instance = localbitcoinplusplus.newBackupDatabase.db[primarySupernode];
|
||||||
|
|
||||||
@ -18331,6 +18319,8 @@
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "trade_balance_updates":
|
case "trade_balance_updates":
|
||||||
|
|
||||||
|
if(!localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(res_obj.nodePubKey)) return;
|
||||||
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
||||||
const trade_balance_res = res_obj.params[0];
|
const trade_balance_res = res_obj.params[0];
|
||||||
// Verify data
|
// Verify data
|
||||||
@ -18705,9 +18695,12 @@
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "updateUserCryptoBalanceRequest":
|
case "updateUserCryptoBalanceRequest":
|
||||||
|
if (localbitcoinplusplus.master_configurations.supernodesPubKeys
|
||||||
|
.includes(res_obj.nodePubKey)) {
|
||||||
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
||||||
|
|
||||||
let updateUserCryptoBalanceResponseObject = res_obj.params[0];
|
let updateUserCryptoBalanceResponseObject = res_obj.params[0];
|
||||||
|
console.log(res_obj.params[0]);
|
||||||
|
|
||||||
if(typeof res_obj.params[0].trader_flo_address !="string") return;
|
if(typeof res_obj.params[0].trader_flo_address !="string") return;
|
||||||
localbitcoinplusplus.kademlia.determineClosestSupernode(res_obj.params[0].trader_flo_address)
|
localbitcoinplusplus.kademlia.determineClosestSupernode(res_obj.params[0].trader_flo_address)
|
||||||
@ -18721,20 +18714,14 @@
|
|||||||
throw new Error(backup_db_error_msg);
|
throw new Error(backup_db_error_msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
let SuPubKey = backup_server_db_instance.backup_readDB('userPublicData', updateUserCryptoBalanceResponseObject.trader_flo_address)
|
|
||||||
.then(user_data => {
|
|
||||||
if (typeof user_data !== "object" || user_data.supernode_flo_public_key.length <
|
|
||||||
1)
|
|
||||||
throw new Error(`No such user exists.`);
|
|
||||||
let updateUserCryptoBalanceResponseString = JSON.stringify(
|
let updateUserCryptoBalanceResponseString = JSON.stringify(
|
||||||
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject);
|
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject);
|
||||||
let isBalanceLegit = RM_WALLET.verify(updateUserCryptoBalanceResponseString,
|
let isBalanceLegit = RM_WALLET.verify(updateUserCryptoBalanceResponseString,
|
||||||
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObjectSign,
|
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObjectSign,
|
||||||
user_data.supernode_flo_public_key
|
res_obj.nodePubKey
|
||||||
);
|
);
|
||||||
if (isBalanceLegit) {
|
if (isBalanceLegit) {
|
||||||
backup_server_db_instance.backup_updateinDB("crypto_balances", updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject,
|
backup_server_db_instance.backup_updateinDB("crypto_balances", updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject);
|
||||||
user_data.trader_flo_address);
|
|
||||||
if (localbitcoinplusplus.wallets.my_local_flo_address ==
|
if (localbitcoinplusplus.wallets.my_local_flo_address ==
|
||||||
updateUserCryptoBalanceResponseObject.trader_flo_address) {
|
updateUserCryptoBalanceResponseObject.trader_flo_address) {
|
||||||
displayBalances(updateUserCryptoBalanceResponseObject.trader_flo_address);
|
displayBalances(updateUserCryptoBalanceResponseObject.trader_flo_address);
|
||||||
@ -18745,8 +18732,9 @@
|
|||||||
showMessage(`WARNING: Failed to update balance in your DB. Please refresh.`);
|
showMessage(`WARNING: Failed to update balance in your DB. Please refresh.`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user