updated code for improved cashier functions
This commit is contained in:
parent
c820c7a9fc
commit
22f3b74d06
@ -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));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13459,90 +13459,137 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onMessageDisplay(responseName, responseData) {
|
function onMessageDisplay(responseName, responseData) {
|
||||||
switch (responseName) {
|
try {
|
||||||
case "list_of_cashier_latest_pending_cash_deposits":
|
switch (responseName) {
|
||||||
(async function() {
|
case "list_of_cashier_latest_pending_cash_deposits":
|
||||||
let failed_confirms_in_deposits = await readAllDB('failed_deposit_confirms');
|
(async function() {
|
||||||
let failed_confirms_in_deposits_ids = failed_confirms_in_deposits.map(m=>m.deposit_id);
|
let failed_confirms_in_deposits = await readAllDB('failed_deposit_confirms');
|
||||||
// console.log(failed_confirms_in_deposits_ids);
|
let failed_confirms_in_deposits_ids = failed_confirms_in_deposits.map(m=>m.deposit_id);
|
||||||
// if(failed_confirms_in_deposits_ids.length>0) {
|
// console.log(failed_confirms_in_deposits_ids);
|
||||||
// alert("There are some failed deposit requests in DB. Please contact the admin.");
|
// if(failed_confirms_in_deposits_ids.length>0) {
|
||||||
// }
|
// alert("There are some failed deposit requests in DB. Please contact the admin.");
|
||||||
let deposit_promises = [];
|
// }
|
||||||
let t = ``;
|
|
||||||
let deposits_table = document.getElementById("deposits_list");
|
|
||||||
//deposits_table.innerHTML = '';
|
|
||||||
for (const m of responseData.responseData.data) {
|
|
||||||
|
|
||||||
let su_res = await localbitcoinplusplus.kademlia.determineClosestSupernode(m.trader_flo_address);
|
let all_cloud_registred_deposits = await floCloudAPI.requestApplicationData(
|
||||||
let closestSupernode = su_res[0].data.id;
|
{receiverID: myFloID, type:"exchange_cash_deposits"});
|
||||||
t += `<tr id='tr_${m.id}'>`;
|
|
||||||
t += `<td> ${m.user_upi} </td>`;
|
if(typeof all_cloud_registred_deposits=="string") {
|
||||||
t += `<td> ${m.trader_flo_address} </td>`;
|
all_cloud_registred_deposits = JSON.parse(all_cloud_registred_deposits);
|
||||||
t += `<td> ${m.depositing_amount} </td>`;
|
}
|
||||||
t += `<td> ${m.currency} </td>`;
|
console.log(all_cloud_registred_deposits);
|
||||||
t += `<td> ${m.timestamp} </td>`;
|
|
||||||
if(m.status===1) {
|
let registered_deposit_ids = [];
|
||||||
// This deposit, token transfer was done but supernode was not informed
|
for (const registered_deposit_data in all_cloud_registred_deposits) {
|
||||||
if(failed_confirms_in_deposits_ids.includes(m.id)) {
|
if (all_cloud_registred_deposits.hasOwnProperty(registered_deposit_data)) {
|
||||||
t += `<td> <button type="button" value="${m.id}" class="btn btn-danger">Failed to inform Supernode!</button>
|
const registered_deposit = all_cloud_registred_deposits[registered_deposit_data].message;
|
||||||
</td>`;
|
registered_deposit_ids.push(registered_deposit.id);
|
||||||
} else {
|
}
|
||||||
t += `<td> <button type="button" value="${m.id}" class="btn btn-info cnf_deposits">Deposit Received!</button>
|
}
|
||||||
<input type="hidden" id="depositSpan${m.id}" value="${closestSupernode}_${responseData.responseData.requesting_supernode}">
|
|
||||||
</td>`;
|
let deposit_promises = [];
|
||||||
|
let t = ``;
|
||||||
|
let deposits_table = document.getElementById("deposits_list");
|
||||||
|
//deposits_table.innerHTML = '';
|
||||||
|
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 closestSupernode = su_res[0].data.id;
|
||||||
|
t += `<tr id='tr_${m.id}'>`;
|
||||||
|
t += `<td> ${m.user_upi} </td>`;
|
||||||
|
t += `<td> ${m.trader_flo_address} </td>`;
|
||||||
|
t += `<td> ${m.depositing_amount} </td>`;
|
||||||
|
t += `<td> ${m.currency} </td>`;
|
||||||
|
t += `<td> ${m.timestamp} </td>`;
|
||||||
|
if(m.status===1) {
|
||||||
|
// This deposit, token transfer was done but supernode was not informed
|
||||||
|
if(failed_confirms_in_deposits_ids.includes(m.id)) {
|
||||||
|
t += `<td> <button type="button" value="${m.id}" class="btn btn-danger">Failed to inform Supernode!</button>
|
||||||
|
</td>`;
|
||||||
|
} else {
|
||||||
|
t += `<td> <button type="button" value="${m.id}" class="btn btn-info cnf_deposits">Deposit Received!</button>
|
||||||
|
<input type="hidden" id="depositSpan${m.id}" value="${closestSupernode}_${responseData.responseData.requesting_supernode}">
|
||||||
|
</td>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if(m.status===2) {
|
||||||
|
t += `<td> <button type="button" value="${m.id}" class="btn btn-success">Success!</button>
|
||||||
|
</td>`;
|
||||||
|
}
|
||||||
|
t += `</tr>`;
|
||||||
|
deposit_promises.push(addDB('deposits', m));
|
||||||
|
}
|
||||||
|
deposits_table.insertAdjacentHTML("beforeend", t);
|
||||||
|
confirmDepositReceivedFromUser();
|
||||||
|
})();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "list_of_cashier_latest_pending_cash_withdrawals":
|
||||||
|
(async function() {
|
||||||
|
let withdraw_promises = [];
|
||||||
|
let v = ``;
|
||||||
|
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 = '';
|
||||||
|
for (const m of responseData.responseData.data) {
|
||||||
|
|
||||||
|
if(!registered_withdraws_ids.includes(m.id)) {
|
||||||
|
floCloudAPI.sendApplicationData(m, type="exchange_cash_withdrawals", {receiverID: myFloID});
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if(m.status===2) {
|
const user_upi = localbitcoinplusplus.encrypt.decryptMessage(
|
||||||
t += `<td> <button type="button" value="${m.id}" class="btn btn-success">Success!</button>
|
m.receivinAddress.secret,
|
||||||
</td>`;
|
m.receivinAddress.senderPublicKeyString
|
||||||
|
);
|
||||||
|
let su_res = await localbitcoinplusplus.kademlia.determineClosestSupernode(m.trader_flo_address);
|
||||||
|
let closestSupernode = su_res[0].data.id;
|
||||||
|
|
||||||
|
v += `<tr>`;
|
||||||
|
v += `<td> ${user_upi} </td>`;
|
||||||
|
v += `<td> ${m.trader_flo_address} </td>`;
|
||||||
|
v += `<td> ${m.withdraw_amount} </td>`;
|
||||||
|
v += `<td> ${m.currency} </td>`;
|
||||||
|
v += `<td> ${m.token_transfer_txid} </td>`;
|
||||||
|
if(m.status===1) {
|
||||||
|
v += `<td> <button type="button" value="${m.id}" class="btn btn-info cnf_withdrawal">Money Transferred!</button>
|
||||||
|
<input type="hidden" id="withdrawSpan${m.id}" value="${closestSupernode}_${responseData.responseData.requesting_supernode}">
|
||||||
|
</td>`;
|
||||||
|
} else if(m.status===2) {
|
||||||
|
v += `<td> <button type="button" value="${m.id}" class="btn btn-success">Success!</button>
|
||||||
|
</td>`;
|
||||||
|
}
|
||||||
|
v += `</tr>`;
|
||||||
|
withdraw_promises.push(addDB('withdraws', m));
|
||||||
}
|
}
|
||||||
t += `</tr>`;
|
withdraws_table.insertAdjacentHTML("beforeend", v);
|
||||||
deposit_promises.push(addDB('deposits', m));
|
confirmCashierTransferredMoneyToWithdrawer();
|
||||||
}
|
})();
|
||||||
deposits_table.insertAdjacentHTML("beforeend", t);
|
|
||||||
confirmDepositReceivedFromUser();
|
|
||||||
})();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "list_of_cashier_latest_pending_cash_withdrawals":
|
default:
|
||||||
(async function() {
|
break;
|
||||||
let withdraw_promises = [];
|
}
|
||||||
let v = ``;
|
} catch(e) {
|
||||||
let withdraws_table = document.getElementById("withdraws_list");
|
console.error(e);
|
||||||
//withdraws_table.innerHTML = '';
|
|
||||||
for (const m of responseData.responseData.data) {
|
|
||||||
const user_upi = localbitcoinplusplus.encrypt.decryptMessage(
|
|
||||||
m.receivinAddress.secret,
|
|
||||||
m.receivinAddress.senderPublicKeyString
|
|
||||||
);
|
|
||||||
let su_res = await localbitcoinplusplus.kademlia.determineClosestSupernode(m.trader_flo_address);
|
|
||||||
let closestSupernode = su_res[0].data.id;
|
|
||||||
|
|
||||||
v += `<tr>`;
|
|
||||||
v += `<td> ${user_upi} </td>`;
|
|
||||||
v += `<td> ${m.trader_flo_address} </td>`;
|
|
||||||
v += `<td> ${m.withdraw_amount} </td>`;
|
|
||||||
v += `<td> ${m.currency} </td>`;
|
|
||||||
v += `<td> ${m.token_transfer_txid} </td>`;
|
|
||||||
if(m.status===1) {
|
|
||||||
v += `<td> <button type="button" value="${m.id}" class="btn btn-info cnf_withdrawal">Money Transferred!</button>
|
|
||||||
<input type="hidden" id="withdrawSpan${m.id}" value="${closestSupernode}_${responseData.responseData.requesting_supernode}">
|
|
||||||
</td>`;
|
|
||||||
} else if(m.status===2) {
|
|
||||||
v += `<td> <button type="button" value="${m.id}" class="btn btn-success">Success!</button>
|
|
||||||
</td>`;
|
|
||||||
}
|
|
||||||
v += `</tr>`;
|
|
||||||
withdraw_promises.push(addDB('withdraws', m));
|
|
||||||
}
|
|
||||||
withdraws_table.insertAdjacentHTML("beforeend", v);
|
|
||||||
confirmCashierTransferredMoneyToWithdrawer();
|
|
||||||
})();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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 {
|
||||||
|
|||||||
64461
index.html
64461
index.html
File diff suppressed because one or more lines are too long
12100
system_status.html
Normal file
12100
system_status.html
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user