updated code for improved cashier functions

This commit is contained in:
Abhishek Sinha 2020-09-26 14:22:18 +05:30
parent c820c7a9fc
commit 22f3b74d06
4 changed files with 47151 additions and 29701 deletions

View File

@ -11409,8 +11409,8 @@
enumerable: false enumerable: false
}); });
const ENVR = 'LIVE'; // LIVE, TEST const ENVR = 'TEST'; // LIVE, TEST
const WS = 'wss'; const WS = 'ws';
const DBName = "paymentsHandlerDBRemote"; const DBName = "paymentsHandlerDBRemote";
if(ENVR === 'LIVE') { if(ENVR === 'LIVE') {
@ -13792,7 +13792,19 @@
let supernodeSeedsArray = Object.values(supernodeSeedsObj); let supernodeSeedsArray = Object.values(supernodeSeedsObj);
supernodeSeedsArray.map(async wsUri => { supernodeSeedsArray.map(async wsUri => {
localbitcoinplusplus.supernode_conns[wsUri.kbucketId] = await initializeWebSocket (`${WS}://${wsUri.ip}`); localbitcoinplusplus.supernode_conns[wsUri.kbucketId] = await initializeWebSocket (`${WS}://${wsUri.ip}`);
startWebSocket(localbitcoinplusplus.supernode_conns[wsUri.kbucketId]);
await startWebSocket(localbitcoinplusplus.supernode_conns[wsUri.kbucketId]);
let req_body = {
trader_flo_address:
localbitcoinplusplus.wallets.my_local_flo_address,
is_live: true,
receiver_flo_address: wsUri.kbucketId
}
const server_con = localbitcoinplusplus.supernode_conns[wsUri.kbucketId];
RM_RPC.send_rpc
.call(this, 'cashier_is_live', req_body)
.then(resp => doSend(server_con, resp));
}); });
} }

View File

@ -13459,6 +13459,7 @@
} }
function onMessageDisplay(responseName, responseData) { function onMessageDisplay(responseName, responseData) {
try {
switch (responseName) { switch (responseName) {
case "list_of_cashier_latest_pending_cash_deposits": case "list_of_cashier_latest_pending_cash_deposits":
(async function() { (async function() {
@ -13468,12 +13469,32 @@
// if(failed_confirms_in_deposits_ids.length>0) { // if(failed_confirms_in_deposits_ids.length>0) {
// alert("There are some failed deposit requests in DB. Please contact the admin."); // alert("There are some failed deposit requests in DB. Please contact the admin.");
// } // }
let all_cloud_registred_deposits = await floCloudAPI.requestApplicationData(
{receiverID: myFloID, type:"exchange_cash_deposits"});
if(typeof all_cloud_registred_deposits=="string") {
all_cloud_registred_deposits = JSON.parse(all_cloud_registred_deposits);
}
console.log(all_cloud_registred_deposits);
let registered_deposit_ids = [];
for (const registered_deposit_data in all_cloud_registred_deposits) {
if (all_cloud_registred_deposits.hasOwnProperty(registered_deposit_data)) {
const registered_deposit = all_cloud_registred_deposits[registered_deposit_data].message;
registered_deposit_ids.push(registered_deposit.id);
}
}
let deposit_promises = []; let deposit_promises = [];
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) {
if(!registered_deposit_ids.includes(m.id))
floCloudAPI.sendApplicationData(m, type="exchange_cash_deposits", {receiverID: myFloID});
let su_res = await localbitcoinplusplus.kademlia.determineClosestSupernode(m.trader_flo_address); let su_res = await localbitcoinplusplus.kademlia.determineClosestSupernode(m.trader_flo_address);
let closestSupernode = su_res[0].data.id; let closestSupernode = su_res[0].data.id;
t += `<tr id='tr_${m.id}'>`; t += `<tr id='tr_${m.id}'>`;
@ -13510,8 +13531,31 @@
let withdraw_promises = []; let withdraw_promises = [];
let v = ``; let v = ``;
let withdraws_table = document.getElementById("withdraws_list"); let withdraws_table = document.getElementById("withdraws_list");
let all_cloud_registred_withdrawals = await floCloudAPI.requestApplicationData(
{receiverID: myFloID, type:"exchange_cash_withdrawals"});
if(typeof all_cloud_registred_withdrawals=="string") {
all_cloud_registred_withdrawals = JSON.parse(all_cloud_registred_withdrawals);
}
console.log(all_cloud_registred_withdrawals);
let registered_withdraws_ids = [];
for (const registered_withdraw_data in all_cloud_registred_withdraws) {
if (all_cloud_registred_withdraws.hasOwnProperty(registered_withdraw_data)) {
const registered_withdraw = all_cloud_registred_withdraws[registered_withdraw_data].message;
registered_withdraws_ids.push(registered_withdraw.id);
}
}
//withdraws_table.innerHTML = ''; //withdraws_table.innerHTML = '';
for (const m of responseData.responseData.data) { for (const m of responseData.responseData.data) {
if(!registered_withdraws_ids.includes(m.id)) {
floCloudAPI.sendApplicationData(m, type="exchange_cash_withdrawals", {receiverID: myFloID});
}
const user_upi = localbitcoinplusplus.encrypt.decryptMessage( const user_upi = localbitcoinplusplus.encrypt.decryptMessage(
m.receivinAddress.secret, m.receivinAddress.secret,
m.receivinAddress.senderPublicKeyString m.receivinAddress.senderPublicKeyString
@ -13544,6 +13588,9 @@
default: default:
break; break;
} }
} catch(e) {
console.error(e);
}
} }
async function onMessage(evt) { async function onMessage(evt) {
@ -13827,7 +13874,19 @@
let supernodeSeedsArray = Object.values(supernodeSeedsObj); let supernodeSeedsArray = Object.values(supernodeSeedsObj);
supernodeSeedsArray.map(async wsUri => { supernodeSeedsArray.map(async wsUri => {
localbitcoinplusplus.supernode_conns[wsUri.kbucketId] = await initializeWebSocket (`${WS}://${wsUri.ip}`); localbitcoinplusplus.supernode_conns[wsUri.kbucketId] = await initializeWebSocket (`${WS}://${wsUri.ip}`);
startWebSocket(localbitcoinplusplus.supernode_conns[wsUri.kbucketId]);
await startWebSocket(localbitcoinplusplus.supernode_conns[wsUri.kbucketId]);
let req_body = {
trader_flo_address:
localbitcoinplusplus.wallets.my_local_flo_address,
is_live: true,
receiver_flo_address: wsUri.kbucketId
}
const server_con = localbitcoinplusplus.supernode_conns[wsUri.kbucketId];
RM_RPC.send_rpc
.call(this, 'cashier_is_live', req_body)
.then(resp => doSend(server_con, resp));
}); });
} }
@ -14016,10 +14075,10 @@
let n=1; let n=1;
(async function validateTxidInBlockchain() { (async function validateTxidInBlockchain() {
// Validate Flo txid // Validate Flo txid
//await delay(60000); await delay(60000);
const validate_flo_txid = await helper_functions.ajaxGet(txidUrlDeposit); const validate_flo_txid = await helper_functions.ajaxGet(txidUrlDeposit);
console.log(validate_flo_txid); console.log(validate_flo_txid);
if(0 && typeof validate_flo_txid == "object" if(typeof validate_flo_txid == "object"
&& typeof validate_flo_txid.transactionDetails == "object" && typeof validate_flo_txid.transactionDetails == "object"
&& typeof validate_flo_txid.transactionDetails.floData == "string" && typeof validate_flo_txid.transactionDetails.floData == "string"
&& validate_flo_txid.transactionDetails.floData.length > 5 // without ':text' && validate_flo_txid.transactionDetails.floData.length > 5 // without ':text'
@ -14038,7 +14097,7 @@
return true; return true;
} else if(0 && n<=20) { } else if(n<=20) {
validateTxidInBlockchain(); validateTxidInBlockchain();
n++; n++;
} else { } else {

7259
index.html

File diff suppressed because one or more lines are too long

12100
system_status.html Normal file

File diff suppressed because it is too large Load Diff