added tables to show processed requests in cashier ops
This commit is contained in:
parent
3b93e116b3
commit
abd2b83f37
@ -252,6 +252,25 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h4 class="alert alert-light" role="alert">
|
||||||
|
Processed Cash Deposits
|
||||||
|
</h4>
|
||||||
|
<div id="processed_cash_deposits_list"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h4 class="alert alert-light" role="alert">
|
||||||
|
Processed Cash Withdraws
|
||||||
|
</h4>
|
||||||
|
<div id="processed_cash_withdraws_list"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
@ -11390,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') {
|
||||||
@ -13411,10 +13430,11 @@
|
|||||||
(async function() {
|
(async function() {
|
||||||
let failed_confirms_in_deposits = await readAllDB('failed_deposit_confirms');
|
let failed_confirms_in_deposits = await readAllDB('failed_deposit_confirms');
|
||||||
let failed_confirms_in_deposits_ids = failed_confirms_in_deposits.map(m=>m.deposit_id);
|
let failed_confirms_in_deposits_ids = failed_confirms_in_deposits.map(m=>m.deposit_id);
|
||||||
console.log(failed_confirms_in_deposits_ids);
|
// console.log(failed_confirms_in_deposits_ids);
|
||||||
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 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 = '';
|
||||||
@ -13443,6 +13463,7 @@
|
|||||||
</td>`;
|
</td>`;
|
||||||
}
|
}
|
||||||
t += `</tr>`;
|
t += `</tr>`;
|
||||||
|
deposit_promises.push(addDB('deposits', m));
|
||||||
}
|
}
|
||||||
deposits_table.insertAdjacentHTML("beforeend", t);
|
deposits_table.insertAdjacentHTML("beforeend", t);
|
||||||
confirmDepositReceivedFromUser();
|
confirmDepositReceivedFromUser();
|
||||||
@ -13451,6 +13472,7 @@
|
|||||||
|
|
||||||
case "list_of_cashier_latest_pending_cash_withdrawals":
|
case "list_of_cashier_latest_pending_cash_withdrawals":
|
||||||
(async function() {
|
(async function() {
|
||||||
|
let withdraw_promises = [];
|
||||||
let v = ``;
|
let v = ``;
|
||||||
let withdraws_table = document.getElementById("withdraws_list");
|
let withdraws_table = document.getElementById("withdraws_list");
|
||||||
//withdraws_table.innerHTML = '';
|
//withdraws_table.innerHTML = '';
|
||||||
@ -13477,6 +13499,7 @@
|
|||||||
</td>`;
|
</td>`;
|
||||||
}
|
}
|
||||||
v += `</tr>`;
|
v += `</tr>`;
|
||||||
|
withdraw_promises.push(addDB('withdraws', m));
|
||||||
}
|
}
|
||||||
withdraws_table.insertAdjacentHTML("beforeend", v);
|
withdraws_table.insertAdjacentHTML("beforeend", v);
|
||||||
confirmCashierTransferredMoneyToWithdrawer();
|
confirmCashierTransferredMoneyToWithdrawer();
|
||||||
@ -13873,7 +13896,8 @@
|
|||||||
|
|
||||||
const depositorInfo = document.getElementById(`tr_${deposit_id}`);
|
const depositorInfo = document.getElementById(`tr_${deposit_id}`);
|
||||||
const depositorInfoVals = depositorInfo.getElementsByTagName('td');
|
const depositorInfoVals = depositorInfo.getElementsByTagName('td');
|
||||||
const token_transfer_statement = `transfer ${depositorInfoVals[2].innerText} rupee# on behalf of ${depositorInfoVals[1].innerText}`;
|
const depositing_amount = Number(depositorInfoVals[2].innerText);
|
||||||
|
const token_transfer_statement = `transfer ${depositing_amount} rupee# on behalf of ${depositorInfoVals[1].innerText}`;
|
||||||
const tx_amount = 0.01;
|
const tx_amount = 0.01;
|
||||||
|
|
||||||
if(typeof websocket_name!=="string" || typeof requesting_supernode!=="string") return;
|
if(typeof websocket_name!=="string" || typeof requesting_supernode!=="string") return;
|
||||||
@ -13881,8 +13905,9 @@
|
|||||||
const confirmTx = confirm(token_transfer_statement);
|
const confirmTx = confirm(token_transfer_statement);
|
||||||
if(!confirmTx) return;
|
if(!confirmTx) return;
|
||||||
|
|
||||||
// Get the closest Supernode alive for this user
|
const deposit_req = await readDB('deposits', deposit_id);
|
||||||
|
|
||||||
|
// Get the closest Supernode alive for this user
|
||||||
let closestSuList = await localbitcoinplusplus.kademlia
|
let closestSuList = await localbitcoinplusplus.kademlia
|
||||||
.determineClosestSupernode(websocket_name,
|
.determineClosestSupernode(websocket_name,
|
||||||
localbitcoinplusplus.master_configurations.supernodesPubKeys.length);
|
localbitcoinplusplus.master_configurations.supernodesPubKeys.length);
|
||||||
@ -13922,7 +13947,6 @@
|
|||||||
}
|
}
|
||||||
if (typeof flo_txid!=="string" || flo_txid.length < 1) return;
|
if (typeof flo_txid!=="string" || flo_txid.length < 1) return;
|
||||||
|
|
||||||
|
|
||||||
let req_body = {
|
let req_body = {
|
||||||
trader_flo_address:
|
trader_flo_address:
|
||||||
localbitcoinplusplus.wallets.my_local_flo_address,
|
localbitcoinplusplus.wallets.my_local_flo_address,
|
||||||
@ -13945,6 +13969,8 @@
|
|||||||
.flo_api_testnet}/api/v1.0/getTransactionDetails/${flo_txid}`;
|
.flo_api_testnet}/api/v1.0/getTransactionDetails/${flo_txid}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deposit_req.token_transfer_txid = flo_txid;
|
||||||
|
|
||||||
let n=1;
|
let n=1;
|
||||||
(async function validateTxidInBlockchain() {
|
(async function validateTxidInBlockchain() {
|
||||||
// Validate Flo txid
|
// Validate Flo txid
|
||||||
@ -13958,7 +13984,10 @@
|
|||||||
) {
|
) {
|
||||||
RM_RPC.send_rpc
|
RM_RPC.send_rpc
|
||||||
.call(this, "cashier_confirms_user_cash_deposit", req_body)
|
.call(this, "cashier_confirms_user_cash_deposit", req_body)
|
||||||
.then(resp => doSend(websocket_conn, resp));
|
.then(resp => doSend(websocket_conn, resp))
|
||||||
|
|
||||||
|
deposit_req.token_transfer_success = true;
|
||||||
|
updateinDB('deposits', deposit_req);
|
||||||
|
|
||||||
btn.classList.remove('cnf_deposits');
|
btn.classList.remove('cnf_deposits');
|
||||||
btn.classList.remove('btn-info');
|
btn.classList.remove('btn-info');
|
||||||
@ -13968,12 +13997,23 @@
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if(n<=20) {
|
} else if(n<=20) {
|
||||||
validateTxidInBlockchain();
|
validateTxidInBlockchain();
|
||||||
n++;
|
n++;
|
||||||
} else {
|
} else {
|
||||||
// Failed to validate token transfer. Save in local db
|
// Failed to validate token transfer. Save in local db
|
||||||
await addDB('failed_deposit_confirms', req_body, req_body.flo_txid);
|
await addDB('failed_deposit_confirms', req_body, req_body.flo_txid);
|
||||||
|
|
||||||
|
// Txid could not be validated
|
||||||
|
req_body.failed_deposit_txid_cnf = true;
|
||||||
|
req_body.amount_deposited = depositing_amount;
|
||||||
|
|
||||||
|
RM_RPC.send_rpc
|
||||||
|
.call(this, "cashier_confirms_user_cash_deposit", req_body)
|
||||||
|
.then(resp => doSend(websocket_conn, resp));
|
||||||
|
|
||||||
|
deposit_req.token_transfer_success = false;
|
||||||
|
updateinDB('deposits', deposit_req);
|
||||||
|
|
||||||
btn.classList.remove('cnf_deposits');
|
btn.classList.remove('cnf_deposits');
|
||||||
btn.classList.remove('btn-info');
|
btn.classList.remove('btn-info');
|
||||||
btn.classList.add('btn-danger');
|
btn.classList.add('btn-danger');
|
||||||
@ -14041,6 +14081,10 @@
|
|||||||
})
|
})
|
||||||
.then(resp => doSend(websocket_conn, resp));
|
.then(resp => doSend(websocket_conn, resp));
|
||||||
|
|
||||||
|
const withdraw_req = await readDB('withdraws', withdraw_id);
|
||||||
|
withdraw_req.upi_txid = upi_txid;
|
||||||
|
await updateinDB('withdraws', withdraw_req);
|
||||||
|
|
||||||
btn.classList.remove('cnf_withdrawal');
|
btn.classList.remove('cnf_withdrawal');
|
||||||
btn.classList.remove('btn-info');
|
btn.classList.remove('btn-info');
|
||||||
btn.classList.add('btn-success');
|
btn.classList.add('btn-success');
|
||||||
@ -14052,6 +14096,52 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function display_processed_deposits() {
|
||||||
|
try {
|
||||||
|
const all_deposits = await readAllDB('deposits');
|
||||||
|
let t = `<ul>`;
|
||||||
|
for (const ad of all_deposits) {
|
||||||
|
if(ad.token_transfer_txid !=="string") continue;
|
||||||
|
t += `<li>User UPI: ${ad.user_upi}</li>`;
|
||||||
|
t += `<li>Time: ${ad.timestamp}</li>`;
|
||||||
|
t += `<li>Amount: ${ad.depositing_amount}</li>`;
|
||||||
|
t += `<li>Currency: ${ad.currency}</li>`;
|
||||||
|
t += `<li>Token Transfer Id: ${ad.token_transfer_txid}</li>`;
|
||||||
|
t += `<li>Token Transfer Success: ${ad.token_transfer_success}</li>`;
|
||||||
|
t += `<li></li>`;
|
||||||
|
}
|
||||||
|
t += `</ul>`;
|
||||||
|
const processed_cash_deposits_list = document.getElementById('processed_cash_deposits_list');
|
||||||
|
processed_cash_deposits_list.innerHTML = t;
|
||||||
|
|
||||||
|
} catch(e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function display_processed_withdraws() {
|
||||||
|
try {
|
||||||
|
const all_withdraws = await readAllDB('withdraws');
|
||||||
|
let t = `<ul>`;
|
||||||
|
for (const ad of all_withdraws) {
|
||||||
|
if(ad.upi_txid !=="string") continue;
|
||||||
|
t += `<li>Cashier UPI TXID: ${ad.upi_txid}</li>`;
|
||||||
|
t += `<li>Time: ${ad.timestamp}</li>`;
|
||||||
|
t += `<li>Amount: ${ad.withdraw_amount}</li>`;
|
||||||
|
t += `<li>Currency: ${ad.currency}</li>`;
|
||||||
|
t += `<li>Supernode Token Transfer Id: ${ad.token_transfer_txid}</li>`;
|
||||||
|
t += `<li></li>`;
|
||||||
|
}
|
||||||
|
t += `</ul>`;
|
||||||
|
|
||||||
|
const processed_cash_withdraws_list = document.getElementById('processed_cash_withdraws_list');
|
||||||
|
processed_cash_withdraws_list.innerHTML = t;
|
||||||
|
|
||||||
|
} catch(e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function transferTokensManually() {
|
async function transferTokensManually() {
|
||||||
try {
|
try {
|
||||||
send_tokens_btn.onclick = function() {
|
send_tokens_btn.onclick = function() {
|
||||||
|
|||||||
56
index.html
56
index.html
@ -15138,6 +15138,10 @@
|
|||||||
function removeWhiteSpaces(text = '') {
|
function removeWhiteSpaces(text = '') {
|
||||||
return text.replace(/\s/g, '');
|
return text.replace(/\s/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeNewLines(text = '') {
|
||||||
|
return text.replace(/[\n\r]/g, '');
|
||||||
|
}
|
||||||
// log event in the console
|
// log event in the console
|
||||||
function LogEvent(msg) {
|
function LogEvent(msg) {
|
||||||
log.textContent += "> " + msg + "\n";
|
log.textContent += "> " + msg + "\n";
|
||||||
@ -19592,29 +19596,37 @@
|
|||||||
|| user_deposit_req === null) return;
|
|| user_deposit_req === null) return;
|
||||||
|
|
||||||
let txidUrlDeposit = '';
|
let txidUrlDeposit = '';
|
||||||
if (ENVR === "LIVE") {
|
let amount_deposited;
|
||||||
txidUrlDeposit = localbitcoinplusplus.server.flo_api_mainnet;
|
|
||||||
|
if(typeof params.failed_deposit_txid_cnf!=="boolean") {
|
||||||
|
|
||||||
|
if (ENVR === "LIVE") {
|
||||||
|
txidUrlDeposit = localbitcoinplusplus.server.flo_api_mainnet;
|
||||||
|
} else {
|
||||||
|
txidUrlDeposit = localbitcoinplusplus.server.flo_api_testnet;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate Flo txid
|
||||||
|
const validate_flo_txid = await helper_functions.chainAjaxRequest("TOKEN_TX_DETAIL", txidUrlDeposit, [params.flo_txid]);
|
||||||
|
|
||||||
|
if (typeof validate_flo_txid !== "object"
|
||||||
|
|| typeof validate_flo_txid.transactionDetails !== "object"
|
||||||
|
|| typeof validate_flo_txid.transactionDetails.floData !== "string"
|
||||||
|
|| validate_flo_txid.transactionDetails.floData.length < 5 // without ':text'
|
||||||
|
)
|
||||||
|
throw new Error(`Error: Txid ${params.flo_txid} not found in Blockchain.`);
|
||||||
|
|
||||||
|
/** IMP: CHECK WHETHER VIN IS A VALID SUPERNODE FLO ID HERE **/
|
||||||
|
const cashiers_pub_keys = Object.keys(JSON.parse(localbitcoinplusplus.master_configurations.cashiers));
|
||||||
|
const cashiers_flo_keys = Object.values(cashiers_pub_keys).map(m => bitjs[localbitcoinplusplus.BASE_BLOCKCHAIN].pubkey2address(m));
|
||||||
|
if (!cashiers_flo_keys.includes(validate_flo_txid.transactionDetails.vin[0].addr)) return;
|
||||||
|
|
||||||
|
amount_deposited = Number(validate_flo_txid.transactionDetails.floData.match(/\d+/g)[0]);
|
||||||
|
} else if(typeof Number(params.amount_deposited)=="number" && Number(params.amount_deposited)>0) {
|
||||||
|
amount_deposited = Number(params.amount_deposited);
|
||||||
} else {
|
} else {
|
||||||
txidUrlDeposit = localbitcoinplusplus.server.flo_api_testnet;
|
throw new Error('No amount found in Deposit Id Cashier confirmation: '+params.deposit_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate Flo txid
|
|
||||||
const validate_flo_txid = await helper_functions.chainAjaxRequest("TOKEN_TX_DETAIL", txidUrlDeposit, [params.flo_txid]);
|
|
||||||
|
|
||||||
if (typeof validate_flo_txid !== "object"
|
|
||||||
|| typeof validate_flo_txid.transactionDetails !== "object"
|
|
||||||
|| typeof validate_flo_txid.transactionDetails.floData !== "string"
|
|
||||||
|| validate_flo_txid.transactionDetails.floData.length < 5 // without ':text'
|
|
||||||
)
|
|
||||||
throw new Error(`Error: Txid ${params.flo_txid} not found in Blockchain.`);
|
|
||||||
|
|
||||||
/** IMP: CHECK WHETHER VIN IS A VALID SUPERNODE FLO ID HERE **/
|
|
||||||
const cashiers_pub_keys = Object.keys(JSON.parse(localbitcoinplusplus.master_configurations.cashiers));
|
|
||||||
const cashiers_flo_keys = Object.values(cashiers_pub_keys).map(m => bitjs[localbitcoinplusplus.BASE_BLOCKCHAIN].pubkey2address(m));
|
|
||||||
if (!cashiers_flo_keys.includes(validate_flo_txid.transactionDetails.vin[0].addr)) return;
|
|
||||||
|
|
||||||
let amount_deposited = Number(validate_flo_txid.transactionDetails.floData.match(/\d+/g)[0]);
|
|
||||||
|
|
||||||
// Update balances datastore
|
// Update balances datastore
|
||||||
const user_cash_id = `${user_deposit_req.trader_flo_address}_${user_deposit_req.currency}`;
|
const user_cash_id = `${user_deposit_req.trader_flo_address}_${user_deposit_req.currency}`;
|
||||||
const get_user_balance = await _readDB('cash_balances', user_cash_id);
|
const get_user_balance = await _readDB('cash_balances', user_cash_id);
|
||||||
@ -20690,7 +20702,7 @@
|
|||||||
if (custom_floData.length > 0) {
|
if (custom_floData.length > 0) {
|
||||||
sendFloData = custom_floData;
|
sendFloData = custom_floData;
|
||||||
}
|
}
|
||||||
sendFloData = removeWhiteSpaces(sendFloData);
|
sendFloData = removeNewLines(sendFloData);
|
||||||
if (crypto_type == "FLO" || crypto_type == "FLO_TEST") {
|
if (crypto_type == "FLO" || crypto_type == "FLO_TEST") {
|
||||||
trx.addflodata(sendFloData); // flochange .. create this function
|
trx.addflodata(sendFloData); // flochange .. create this function
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user