improved cash deposit withdraw process to work in backup mode
This commit is contained in:
parent
6eb7d3632b
commit
3ed8daec02
@ -13434,7 +13434,7 @@
|
|||||||
}
|
}
|
||||||
let t = ``;
|
let t = ``;
|
||||||
let deposits_table = document.getElementById("deposits_list");
|
let deposits_table = document.getElementById("deposits_list");
|
||||||
deposits_table.innerHTML = '';
|
//deposits_table.innerHTML = '';
|
||||||
for (const m of responseData.responseData.data) {
|
for (const m of responseData.responseData.data) {
|
||||||
|
|
||||||
let su_res = await localbitcoinplusplus.kademlia.determineClosestSupernode(m.trader_flo_address);
|
let su_res = await localbitcoinplusplus.kademlia.determineClosestSupernode(m.trader_flo_address);
|
||||||
@ -13470,7 +13470,7 @@
|
|||||||
(async function() {
|
(async function() {
|
||||||
let v = ``;
|
let v = ``;
|
||||||
const withdraws_table = document.getElementById("withdraws_list");
|
const withdraws_table = document.getElementById("withdraws_list");
|
||||||
withdraws_table.innerHTML = '';
|
//withdraws_table.innerHTML = '';
|
||||||
for (const m of responseData.responseData.data) {
|
for (const m of responseData.responseData.data) {
|
||||||
const user_upi = localbitcoinplusplus.encrypt.decryptMessage(
|
const user_upi = localbitcoinplusplus.encrypt.decryptMessage(
|
||||||
m.receivinAddress.secret,
|
m.receivinAddress.secret,
|
||||||
@ -13804,7 +13804,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch Deposit or Withdraw requests
|
// Fetch Deposit or Withdraw requests
|
||||||
function send_deposit_withdraw_req(websocket_flo_id="", job="", parent_flo_id="") {
|
async function send_deposit_withdraw_req(websocket_flo_id="", job="") {
|
||||||
if (localbitcoinplusplus.MY_UPI_ID.length < 1) {
|
if (localbitcoinplusplus.MY_UPI_ID.length < 1) {
|
||||||
showMessage(
|
showMessage(
|
||||||
`WARNING: Your UPI Id is not set.`
|
`WARNING: Your UPI Id is not set.`
|
||||||
@ -13812,7 +13812,7 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const websocket_name = localbitcoinplusplus.supernode_conns[websocket_flo_id];
|
let websocket_name = localbitcoinplusplus.supernode_conns[websocket_flo_id];
|
||||||
if(typeof websocket_name!=="object") return;
|
if(typeof websocket_name!=="object") return;
|
||||||
|
|
||||||
if(job.length<1) return;
|
if(job.length<1) return;
|
||||||
@ -13826,16 +13826,28 @@
|
|||||||
receiver_flo_address: websocket_flo_id,
|
receiver_flo_address: websocket_flo_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
// For case where parent supernode is dead
|
req_body.parent_supernode = websocket_flo_id;
|
||||||
if(websocket_flo_id !== parent_flo_id && parent_flo_id.length>0) {
|
|
||||||
req_body.parent_supernode = parent_flo_id;
|
|
||||||
req_body.requesting_supernode = websocket_flo_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(parent_flo_id.length<1 || websocket_flo_id==parent_flo_id) {
|
// For case where parent supernode is dead
|
||||||
req_body.parent_supernode = websocket_flo_id;
|
if(localbitcoinplusplus.supernode_conns[websocket_flo_id].readyState!==1) {
|
||||||
req_body.requesting_supernode = websocket_flo_id;
|
const sn_list = await localbitcoinplusplus.kademlia.determineClosestSupernode(
|
||||||
}
|
"",
|
||||||
|
localbitcoinplusplus.master_configurations.MaxBackups,
|
||||||
|
supernodeKBucket,
|
||||||
|
websocket_flo_id
|
||||||
|
);
|
||||||
|
for (const sn of sn_list) {
|
||||||
|
if(sn.data.id !== websocket_flo_id &&
|
||||||
|
localbitcoinplusplus.supernode_conns[sn.data.id].readyState===1) {
|
||||||
|
|
||||||
|
req_body.requesting_supernode = sn.data.id;
|
||||||
|
websocket_name = localbitcoinplusplus.supernode_conns[sn.data.id];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
req_body.requesting_supernode = websocket_flo_id;
|
||||||
|
}
|
||||||
|
|
||||||
RM_RPC.send_rpc
|
RM_RPC.send_rpc
|
||||||
.call(this, job, req_body)
|
.call(this, job, req_body)
|
||||||
|
|||||||
192
index.html
192
index.html
@ -16236,6 +16236,12 @@
|
|||||||
.then(deposit_request_response =>
|
.then(deposit_request_response =>
|
||||||
doSend(deposit_request_response)
|
doSend(deposit_request_response)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Delete the request after 24 hours
|
||||||
|
localbitcoinplusplus.actions.delay(24 * 60 * 60 * 1000).then(function() {
|
||||||
|
removeinDB("cash_deposits", receivedTradeInfo.id);
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
@ -16650,8 +16656,7 @@
|
|||||||
);
|
);
|
||||||
const update_cash_balance_sign = RM_WALLET.sign(
|
const update_cash_balance_sign = RM_WALLET.sign(
|
||||||
update_cash_balance_hash,
|
update_cash_balance_hash,
|
||||||
localbitcoinplusplus.wallets
|
localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY
|
||||||
.MY_SUPERNODE_PRIVATE_KEY
|
|
||||||
);
|
);
|
||||||
|
|
||||||
update_cash_balance_obj.publicKey =
|
update_cash_balance_obj.publicKey =
|
||||||
@ -17935,46 +17940,107 @@
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case "deposit_cash_request":
|
case "deposit_cash_request":
|
||||||
console.info(`INFO: Cash deposits are prohibited in backup mode.`);
|
|
||||||
|
|
||||||
RM_RPC.filter_legit_backup_requests(
|
RM_RPC.filter_legit_backup_requests(
|
||||||
params.trader_flo_address,
|
params.trader_flo_address,
|
||||||
async function(is_valid_request) {
|
async function(is_valid_request) {
|
||||||
if (is_valid_request !== true) return false;
|
if (is_valid_request !== true) return false;
|
||||||
|
|
||||||
let receivedTradeInfo = { ...params };
|
// This code will only run for supernodes
|
||||||
|
if (
|
||||||
|
typeof params.depositing_amount !== "undefined" &&
|
||||||
|
localbitcoinplusplus.master_configurations.tradableAsset2.includes(
|
||||||
|
params.currency
|
||||||
|
) &&
|
||||||
|
typeof params.trader_flo_address == "string" &&
|
||||||
|
params.trader_flo_address.length > 0 &&
|
||||||
|
typeof params.user_upi == "string" &&
|
||||||
|
params.user_upi.length > 0
|
||||||
|
) {
|
||||||
|
params.id = helper_functions.unique_id();
|
||||||
|
params.status = 1;
|
||||||
|
let receivedTradeInfo = { ...params };
|
||||||
|
|
||||||
let receivedTradeInfoHash = Crypto.SHA256(
|
const su_data = await readDB("localbitcoinUser", "00-01");
|
||||||
JSON.stringify(receivedTradeInfo)
|
|
||||||
);
|
|
||||||
|
|
||||||
receivedTradeInfo["depositDataHash"] = receivedTradeInfoHash;
|
if (
|
||||||
receivedTradeInfo["order_validator_sign"] = RM_WALLET.sign(
|
typeof su_data == "object" &&
|
||||||
receivedTradeInfoHash,
|
typeof su_data.myLocalFLOPublicKey == "string" &&
|
||||||
localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY
|
su_data.myLocalFLOPublicKey.length > 0 &&
|
||||||
);
|
localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(
|
||||||
receivedTradeInfo["order_validator_public_key"] =
|
su_data.myLocalFLOPublicKey
|
||||||
localbitcoinplusplus.wallets.my_local_flo_public_key;
|
)
|
||||||
|
) {
|
||||||
|
let receivedTradeInfoHash = Crypto.SHA256(
|
||||||
|
JSON.stringify(receivedTradeInfo)
|
||||||
|
);
|
||||||
|
|
||||||
let deposit_response_object = {
|
receivedTradeInfo["depositDataHash"] = receivedTradeInfoHash;
|
||||||
error: true,
|
receivedTradeInfo["order_validator_sign"] = RM_WALLET.sign(
|
||||||
method: "deposit_cash_request_response",
|
receivedTradeInfoHash,
|
||||||
msg: "Primary server is temporarily down. For now you can only trade, deposit and withdraw cryptos.",
|
localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY
|
||||||
data: null,
|
);
|
||||||
receiver_flo_address: receivedTradeInfo.trader_flo_address,
|
receivedTradeInfo["order_validator_public_key"] = su_data.myLocalFLOPublicKey;
|
||||||
trader_flo_address: receivedTradeInfo.trader_flo_address
|
|
||||||
};
|
|
||||||
|
|
||||||
RM_RPC.send_rpc
|
try {
|
||||||
.call(
|
const cashiersList = JSON.parse(
|
||||||
this,
|
localbitcoinplusplus.master_configurations.cashiers
|
||||||
"deposit_cash_request_response",
|
);
|
||||||
deposit_response_object
|
const cashiersPubKeysArray = Object.keys(cashiersList);
|
||||||
)
|
const getAPaymentHandler = randomNoRepeats(cashiersPubKeysArray)();
|
||||||
.then(deposit_request_response =>
|
|
||||||
doSend(deposit_request_response)
|
if (!cashiersPubKeysArray.includes(
|
||||||
);
|
getAPaymentHandler
|
||||||
return true;
|
)
|
||||||
|
) {
|
||||||
|
err_msg = `ERROR: ${getAPaymentHandler} is not recognized as any Cashier's Public Key.`;
|
||||||
|
err_response = {
|
||||||
|
user_flo_addr: params.trader_flo_address,
|
||||||
|
msg: err_msg
|
||||||
|
}
|
||||||
|
reactor.dispatchEvent('message_for_user', err_response);
|
||||||
|
|
||||||
|
throw new Error(err_msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
receivedTradeInfo.cashier_upi = cashiersList[getAPaymentHandler];
|
||||||
|
receivedTradeInfo.cashier_pubKey = getAPaymentHandler;
|
||||||
|
const receivedTradeInfoResp = await backup_server_db_instance
|
||||||
|
.backup_addDB("cash_deposits", receivedTradeInfo);
|
||||||
|
|
||||||
|
let deposit_response_object = {
|
||||||
|
error: false,
|
||||||
|
method: "deposit_cash_request_response",
|
||||||
|
msg: receivedTradeInfo.cashier_upi,
|
||||||
|
data: receivedTradeInfoResp,
|
||||||
|
receiver_flo_address:
|
||||||
|
receivedTradeInfo.trader_flo_address,
|
||||||
|
trader_flo_address:
|
||||||
|
receivedTradeInfo.trader_flo_address
|
||||||
|
};
|
||||||
|
|
||||||
|
RM_RPC.send_rpc
|
||||||
|
.call(
|
||||||
|
this,
|
||||||
|
"deposit_cash_request_response",
|
||||||
|
deposit_response_object
|
||||||
|
)
|
||||||
|
.then(deposit_request_response =>
|
||||||
|
doSend(deposit_request_response)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Delete the request after 24 hours
|
||||||
|
localbitcoinplusplus.actions.delay(24 * 60 * 60 * 1000).then(function () {
|
||||||
|
backup_server_db_instance
|
||||||
|
.backup_removeinDB("cash_deposits", receivedTradeInfo.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
@ -18226,47 +18292,6 @@
|
|||||||
params.product
|
params.product
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
/***********************************************
|
|
||||||
* WITHDRAW OF CASH IS PROHIBITED IN BACKUP MODE*
|
|
||||||
************************************************/
|
|
||||||
let withdraw_request_db_object = {
|
|
||||||
trader_flo_address: params.trader_flo_address,
|
|
||||||
};
|
|
||||||
|
|
||||||
let withdraw_request_db_object_hash = Crypto.SHA256(
|
|
||||||
JSON.stringify(withdraw_request_db_object)
|
|
||||||
);
|
|
||||||
withdraw_request_db_object["withdrawDataHash"]
|
|
||||||
= withdraw_request_db_object_hash;
|
|
||||||
withdraw_request_db_object["order_validator_sign"]
|
|
||||||
= RM_WALLET.sign(
|
|
||||||
withdraw_request_db_object_hash,
|
|
||||||
localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY
|
|
||||||
);
|
|
||||||
withdraw_request_db_object["order_validator_public_key"]
|
|
||||||
= localbitcoinplusplus.wallets.my_local_flo_public_key;
|
|
||||||
|
|
||||||
// return back the response to client
|
|
||||||
withdraw_request_db_object.error = true;
|
|
||||||
withdraw_request_db_object.receiver_flo_address =
|
|
||||||
params.trader_flo_address;
|
|
||||||
withdraw_request_db_object.msg =
|
|
||||||
`INFO: The primary server is down and will be up soon. Currently,
|
|
||||||
you can only trade, deposit and withdraw Cryptos but not Cash.`;
|
|
||||||
RM_RPC.send_rpc
|
|
||||||
.call(
|
|
||||||
this,
|
|
||||||
"withdrawal_request_response",
|
|
||||||
withdraw_request_db_object
|
|
||||||
)
|
|
||||||
.then(
|
|
||||||
withdrawal_request_response =>
|
|
||||||
doSend(
|
|
||||||
withdrawal_request_response
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!localbitcoinplusplus.master_configurations.validTradingAmount.includes(
|
!localbitcoinplusplus.master_configurations.validTradingAmount.includes(
|
||||||
@ -19240,11 +19265,11 @@
|
|||||||
&& params.parent_supernode.length
|
&& params.parent_supernode.length
|
||||||
&& localbitcoinplusplus.wallets.my_local_flo_address
|
&& localbitcoinplusplus.wallets.my_local_flo_address
|
||||||
!== params.parent_supernode ) {
|
!== params.parent_supernode ) {
|
||||||
return false;
|
|
||||||
// const foreign_db =
|
const foreign_db =
|
||||||
// localbitcoinplusplus.newBackupDatabase.db[params.parent_supernode];
|
localbitcoinplusplus.newBackupDatabase.db[params.parent_supernode];
|
||||||
// if(typeof foreign_db !== "object") return;
|
if(typeof foreign_db !== "object") return;
|
||||||
// _readDBbyIndex = foreign_db.backup_readDBbyIndex.bind(foreign_db);
|
_readDBbyIndex = foreign_db.backup_readDBbyIndex.bind(foreign_db);
|
||||||
}
|
}
|
||||||
const get_all_deposit_reqs_for_this_cashier = await _readDBbyIndex(
|
const get_all_deposit_reqs_for_this_cashier = await _readDBbyIndex(
|
||||||
"cash_deposits",
|
"cash_deposits",
|
||||||
@ -26226,6 +26251,12 @@
|
|||||||
"cash_deposits",
|
"cash_deposits",
|
||||||
resp.data
|
resp.data
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Delete the request after 24 hours
|
||||||
|
localbitcoinplusplus.actions.delay(24 * 60 * 60 * 1000).then(function() {
|
||||||
|
backup_server_db_instance.backup_removeinDB("cash_deposits",
|
||||||
|
resp.data.id);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -26244,11 +26275,6 @@
|
|||||||
async function(is_valid_request) {
|
async function(is_valid_request) {
|
||||||
if (!is_valid_request) return false;
|
if (!is_valid_request) return false;
|
||||||
|
|
||||||
/*********************************************************
|
|
||||||
*** INFO: Cash Withdrawal is prohibited in backup mode.***
|
|
||||||
**********************************************************/
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
typeof res_obj.params == "object" &&
|
typeof res_obj.params == "object" &&
|
||||||
typeof res_obj.params[0] == "object"
|
typeof res_obj.params[0] == "object"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user