added code to get pending deposits from supernode by cashier
This commit is contained in:
parent
a66b57c3cf
commit
59460a84b7
@ -5,11 +5,50 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Handling Cash Payments For Localbitcoinplusplus</title>
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
||||
|
||||
<!-- Bootstrap CSS -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
||||
|
||||
<!-- Bootstrap sticky-footer-navbar.css -->
|
||||
<style>
|
||||
/* Sticky footer styles
|
||||
-------------------------------------------------- */
|
||||
html {
|
||||
position: relative;
|
||||
min-height: 100%;
|
||||
}
|
||||
body {
|
||||
/* Margin bottom by footer height */
|
||||
margin-bottom: 60px;
|
||||
}
|
||||
.footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
/* Set the fixed height of the footer here */
|
||||
height: 60px;
|
||||
line-height: 60px; /* Vertically center the text there */
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
<!-- Optional theme -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
|
||||
|
||||
/* Custom page CSS
|
||||
-------------------------------------------------- */
|
||||
/* Not required for template or sticky footer method. */
|
||||
|
||||
body > .container {
|
||||
padding: 60px 15px 0;
|
||||
}
|
||||
|
||||
.footer > .container {
|
||||
padding-right: 15px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
code {
|
||||
font-size: 80%;
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
.sidenav {
|
||||
position: fixed;
|
||||
@ -27,33 +66,115 @@
|
||||
background: #eee;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.myInput {
|
||||
background-image: url('/css/searchicon.png'); /* Add a search icon to input */
|
||||
background-position: 10px 12px; /* Position the search icon */
|
||||
background-repeat: no-repeat; /* Do not repeat the icon image */
|
||||
width: 100%; /* Full-width */
|
||||
font-size: 16px; /* Increase font-size */
|
||||
padding: 12px 20px 12px 40px; /* Add some padding */
|
||||
border: 1px solid #ddd; /* Add a grey border */
|
||||
margin-bottom: 12px; /* Add some space below the input */
|
||||
}
|
||||
|
||||
.myTable {
|
||||
border-collapse: collapse; /* Collapse borders */
|
||||
width: 100%; /* Full-width */
|
||||
border: 1px solid #ddd; /* Add a grey border */
|
||||
font-size: 18px; /* Increase font-size */
|
||||
}
|
||||
|
||||
.myTable th, .myTable td {
|
||||
text-align: left; /* Left-align text */
|
||||
padding: 12px; /* Add padding */
|
||||
}
|
||||
|
||||
.myTable tr {
|
||||
/* Add a bottom border to all table rows */
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.myTable tr.header, .myTable tr:hover {
|
||||
/* Add a grey background color to the table header and on hover */
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="sidenav">
|
||||
<div class="w3-sidebar w3-bar-block" style="display:none" id="mySidebar">
|
||||
<div onclick="closeMessage()" class="w3-bar-item w3-button w3-large bg-black">Close</div>
|
||||
<pre id="log">Event information log
|
||||
=====================
|
||||
</pre>
|
||||
</div>
|
||||
<div class="w3-button w3-teal w3-xlarge" onclick="displayMessages()">☰</div>
|
||||
</div>
|
||||
<header>
|
||||
<!-- Fixed navbar -->
|
||||
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
|
||||
<a class="navbar-brand" href="#">Fixed navbar</a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarCollapse">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Link</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Disabled</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div id="conn_info"></div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<!-- Begin page content -->
|
||||
<main role="main" class="container">
|
||||
|
||||
<div id="supernode_seeds_div"></div>
|
||||
<div id="flo_keys_div"></div>
|
||||
<div class="sidenav">
|
||||
<div class="w3-sidebar w3-bar-block" style="display:none" id="mySidebar">
|
||||
<div onclick="closeMessage()" class="w3-bar-item w3-button w3-large bg-black">Close</div>
|
||||
<pre id="log">Event information log
|
||||
=====================
|
||||
</pre>
|
||||
</div>
|
||||
<div class="w3-button w3-teal w3-xlarge" onclick="displayMessages()">☰</div>
|
||||
</div>
|
||||
|
||||
<h1 class="mt-5">Ranchi Mall Cash Handling Page</h1>
|
||||
<p class="lead">This page is to be used by <code>Ranchi Mall Cashiers</code> as a tool to manage cash deposits and withdraws.</p>
|
||||
|
||||
<div class="row" id="supernode_seeds_div"></div>
|
||||
<div class="row" id="flo_keys_div"></div>
|
||||
<div class="row" id="pending_deposits_list"></div>
|
||||
|
||||
<!-- Pending Deposits -->
|
||||
<div class="row">
|
||||
<div class="alert alert-light" role="alert">
|
||||
Cash Deposit Requests List
|
||||
</div>
|
||||
<input type="text" id="searchbar_deposits" class="myInput" onkeyup="search_deposits()" placeholder="Search anything">
|
||||
|
||||
<div id="action_buttons">
|
||||
<button type="button" class="btn btn-outline-primary" id="fetch_deposits">Load Pending Deposits</button>
|
||||
<button type="button" class="btn btn-outline-secondary">Secondary</button>
|
||||
<button type="button" class="btn btn-outline-success">Success</button>
|
||||
<button type="button" class="btn btn-outline-danger">Danger</button>
|
||||
<button type="button" class="btn btn-outline-warning">Warning</button>
|
||||
<button type="button" class="btn btn-outline-info">Info</button>
|
||||
<button type="button" class="btn btn-outline-light">Light</button>
|
||||
<button type="button" class="btn btn-outline-dark">Dark</button>
|
||||
</div>
|
||||
<table id="deposits_list" class="myTable">
|
||||
<tr class="header">
|
||||
<th>UPI Id</th>
|
||||
<th>FLO Id</th>
|
||||
<th>Depositing Amount</th>
|
||||
<th>Currency</th>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="row" id="action_buttons">
|
||||
<button type="button" class="btn btn-outline-primary" id="fetch_deposits">Load Pending Deposits</button>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<span class="text-muted">Place sticky footer content here.</span>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script type="text/javascript">
|
||||
//crypto-sha256-hmac.js
|
||||
@ -9764,26 +9885,27 @@
|
||||
fetch_configs: function (callback) {
|
||||
this.floAddress = localbitcoinplusplus.RM_FLO_SENDING_ADDR;
|
||||
this.parse_flo_comments(function (floData) {
|
||||
let RMAssets = floData.slice(5);
|
||||
let RMAssets = floData.slice(5).replace(/ /g,'');
|
||||
|
||||
// remove this line later
|
||||
// btcTradeMargin is tolerable difference between Crypto trader should deposit and cryptos he actually deposited
|
||||
RMAssets =
|
||||
`masterFLOPubKey=029EF7838D4D103E62262394B5417E8ABFD75539D19E61CA5FD0C2051B69B29910
|
||||
#!#tradableAsset1=BTC,FLO,BTC_TEST,FLO_TEST#!#tradableAsset2=INR,USD,
|
||||
#!#validTradingAmount=10,50,100,#!#btcTradeMargin=5000
|
||||
#!#MaxBackups=2
|
||||
#!#miners_fee={"btc":0.0003, "flo":0.0003}
|
||||
#!#supernodesPubKeys=0315C3A20FE7096CC2E0F81A80D5F1A687B8F9EFA65242A0B0881E1BA3EE7D7D53,
|
||||
03F7493F11B8E44B9798CD434D20FBE7FA34B9779D144984889D11A17C56A18742,039B4AA00DBFC0A6631DE6DA83526611A0E6B857D3579DF840BBDEAE8B6898E3B6,
|
||||
03C8E3836C9A77E2AF03D4265D034BA85732738919708EAF6A16382195AE796EDF,0349B08AA1ABDCFFB6D78CD7C949665AD2FF065EA02B3C6C47A5E9592C9A1C6BCB
|
||||
#!#externalFiles={"d3js":"58f54395efa8346e8e94d12609770f66b916897e7f4e05f6c98780cffa5c70a3"},
|
||||
#!#ShamirsMaxShares=8#!#supernodeSeeds={"ranchimall1":{"ip":"127.0.0.1","port":"9111","kbucketId":"oZxHcbSf1JC8t5GjutopWYXs7C6Fe9p7ps"},
|
||||
"ranchimall2":{"ip":"127.0.0.1","port":"9112","kbucketId":"oTWjPupy3Z7uMdPcu5uXd521HBkcsLuSuM"},
|
||||
"ranchimall3":{"ip":"127.0.0.1","port":"9113","kbucketId":"odYA6KagmbokSh9GY7yAfeTUZRtZLwecY1"},
|
||||
"ranchimall4":{"ip":"127.0.0.1","port":"9114","kbucketId":"oJosrve9dBv2Hj2bfncxv2oEpTysg3Wejv"},
|
||||
"ranchimall5":{"ip":"127.0.0.1","port":"9115","kbucketId":"oMhv5sAzqg77sYHxmUGZWKRrVo4P4JQduS"}}`;
|
||||
|
||||
`masterFLOPubKey=029EF7838D4D103E62262394B5417E8ABFD75539D19E61CA5FD0C2051B69B29910
|
||||
#!#tradableAsset1=BTC,FLO,BTC_TEST,FLO_TEST#!#tradableAsset2=INR,USD,
|
||||
#!#validTradingAmount=10,50,100,#!#btcTradeMargin=5000
|
||||
#!#MaxBackups=2
|
||||
#!#miners_fee={"btc":0.0003, "flo":0.0003}
|
||||
#!#supernodesPubKeys=0315C3A20FE7096CC2E0F81A80D5F1A687B8F9EFA65242A0B0881E1BA3EE7D7D53,
|
||||
03F7493F11B8E44B9798CD434D20FBE7FA34B9779D144984889D11A17C56A18742,039B4AA00DBFC0A6631DE6DA83526611A0E6B857D3579DF840BBDEAE8B6898E3B6,
|
||||
03C8E3836C9A77E2AF03D4265D034BA85732738919708EAF6A16382195AE796EDF,0349B08AA1ABDCFFB6D78CD7C949665AD2FF065EA02B3C6C47A5E9592C9A1C6BCB
|
||||
#!#externalFiles={"d3js":"58f54395efa8346e8e94d12609770f66b916897e7f4e05f6c98780cffa5c70a3"}
|
||||
#!#cashiers={"032871A74D2DDA9D0DE7135F58B5BD2D7F679D2CCA20EA7909466D1A6912DF4022":"johnDoe@upi"}
|
||||
#!#ShamirsMaxShares=8#!#supernodeSeeds={"ranchimall1":{"ip":"127.0.0.1","port":"9111","kbucketId":"oZxHcbSf1JC8t5GjutopWYXs7C6Fe9p7ps"},
|
||||
"ranchimall2":{"ip":"127.0.0.1","port":"9112","kbucketId":"oTWjPupy3Z7uMdPcu5uXd521HBkcsLuSuM"},
|
||||
"ranchimall3":{"ip":"127.0.0.1","port":"9113","kbucketId":"odYA6KagmbokSh9GY7yAfeTUZRtZLwecY1"},
|
||||
"ranchimall4":{"ip":"127.0.0.1","port":"9114","kbucketId":"oJosrve9dBv2Hj2bfncxv2oEpTysg3Wejv"},
|
||||
"ranchimall5":{"ip":"127.0.0.1","port":"9115","kbucketId":"oMhv5sAzqg77sYHxmUGZWKRrVo4P4JQduS"}}`;
|
||||
|
||||
let floAssetsArray = RMAssets.split('#!#');
|
||||
|
||||
if (floAssetsArray.length > 0 && typeof floAssetsArray[0] !== undefined &&
|
||||
@ -9792,13 +9914,18 @@
|
||||
try {
|
||||
floAssetsArray.map(function (assets_string) {
|
||||
let k = assets_string.split('=');
|
||||
if (k[1].indexOf(',') > 0) {
|
||||
|
||||
if (k[1].indexOf(',') > 0 && k[1].indexOf('{') == -1) {
|
||||
k[1] = k[1].split(',')
|
||||
.map(val => !isNaN(val) ? parseFloat(val) : val.trim())
|
||||
.filter(v => ![null, "", undefined, NaN].includes(v));
|
||||
.map(val => !isNaN(val) ? parseFloat(val) : val.trim())
|
||||
.filter(v => ![null, "", undefined, NaN].includes(v));
|
||||
} else if (!isNaN(k[1])) {
|
||||
k[1] = parseFloat(k[1]);
|
||||
}
|
||||
if (typeof k[1]=="string" && k[1].indexOf('{') >= 0) {
|
||||
k[1] = JSON.parse(k[1].replace(/ /g,''));
|
||||
}
|
||||
|
||||
return Object.defineProperty(localbitcoinplusplus.master_configurations,
|
||||
k[0], {
|
||||
value: k[1],
|
||||
@ -9808,6 +9935,7 @@
|
||||
});
|
||||
});
|
||||
deepFreeze(localbitcoinplusplus.master_configurations);
|
||||
console.log(localbitcoinplusplus);
|
||||
return callback(localbitcoinplusplus);
|
||||
} catch (error) {
|
||||
console.error('FATAL ERROR: Failed to fetch master configuration: ', error);
|
||||
@ -10004,11 +10132,9 @@
|
||||
|
||||
if (typeof params[0].receiver_flo_address == "string") {
|
||||
request.globalParams.receiverFloId = params[0].receiver_flo_address;
|
||||
if (typeof request.globalParams.receiversList == "object") {
|
||||
if(typeof request.globalParams["receiversList"] !== "object") request.globalParams["receiversList"] = [];
|
||||
if (!request.globalParams.receiversList.includes(params[0].receiver_flo_address)) {
|
||||
request.globalParams.receiversList.push(params[0].receiver_flo_address);
|
||||
}
|
||||
if(typeof request.globalParams["receiversList"] !== "object") request.globalParams["receiversList"] = [];
|
||||
if (!request.globalParams.receiversList.includes(params[0].receiver_flo_address)) {
|
||||
request.globalParams.receiversList.push(params[0].receiver_flo_address);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10147,10 +10273,9 @@
|
||||
},
|
||||
restoreSupernodeKBucket: function() {
|
||||
return new Promise((resolve, reject)=>{
|
||||
const supernodeSeeds = localbitcoinplusplus.master_configurations.supernodeSeeds;
|
||||
if (typeof supernodeSeeds !== "object") reject("Failed to get supernode seeds.");
|
||||
let supernodeSeedsObj = JSON.parse(supernodeSeeds);
|
||||
|
||||
const supernodeSeedsObj = localbitcoinplusplus.master_configurations.supernodeSeeds;
|
||||
if (typeof supernodeSeedsObj !== "object") reject("Failed to get supernode seeds.");
|
||||
|
||||
Object.entries(supernodeSeedsObj).map(seedObj=>{
|
||||
let kbuck = this.addNewUserNodeInKbucket("FLO_TEST", seedObj[1].kbucketId,
|
||||
{ id: seedObj[1].kbucketId }, supernodeKBucket);
|
||||
@ -10515,7 +10640,11 @@
|
||||
= m.kbucketId;
|
||||
});
|
||||
});
|
||||
console.info(`INFO: Connected succesfully to ${evt.srcElement.url}.`)
|
||||
console.info(`INFO: Connected succesfully to ${evt.srcElement.url}.`);
|
||||
let conn_info = document.getElementById('conn_info');
|
||||
conn_info.innerHTML = `<div class="alert alert-success" role="alert">
|
||||
INFO: Connected to ${evt.srcElement.url} Supernode.
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function onClose(event) {
|
||||
@ -10530,10 +10659,11 @@
|
||||
|
||||
async function onMessage(evt) {
|
||||
var response = evt.data || evt;
|
||||
console.log('RESPONSE: ' + response);
|
||||
|
||||
|
||||
let is_message_for_cashier = response.search('__FOR__CASHIER__');
|
||||
if (!is_message_for_cashier) return;
|
||||
if (is_message_for_cashier<0) return;
|
||||
|
||||
console.log('RESPONSE: ' + response);
|
||||
|
||||
var res_pos = response.indexOf('{');
|
||||
if (res_pos >= 0) {
|
||||
@ -10568,8 +10698,24 @@
|
||||
const RM_RPC = new localbitcoinplusplus.rpc;
|
||||
|
||||
switch (res_obj.method) {
|
||||
case "":
|
||||
|
||||
case "list_of_cashier_latest_pending_cash_deposits":
|
||||
|
||||
const resp_data = res_obj.params[0];
|
||||
if(typeof resp_data.data == "object" && resp_data.data.length>0) {
|
||||
const deposits_table = document.getElementById('deposits_list');
|
||||
let t = ``;
|
||||
resp_data.data.map(m=>{
|
||||
t += `<tr>`;
|
||||
t += `<td> ${m.cashier_upi} </td>`;
|
||||
t += `<td> ${m.trader_flo_address} </td>`;
|
||||
t += `<td> ${m.depositing_amount} </td>`;
|
||||
t += `<td> ${m.currency} </td>`;
|
||||
t += `</tr>`;
|
||||
});
|
||||
deposits_table.insertAdjacentHTML('beforeend', t);
|
||||
} else {
|
||||
showMessage(`INFO: No pending deposits found.`)
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -10766,9 +10912,7 @@
|
||||
// Connect to Supernode
|
||||
function loadSupernodesConnectUi() {
|
||||
|
||||
const supernodeSeeds = localbitcoinplusplus.master_configurations.supernodeSeeds;
|
||||
if (typeof supernodeSeeds !== "object") return showMessage("Failed to get supernode list.");
|
||||
let supernodeSeedsObj = JSON.parse(supernodeSeeds);
|
||||
let supernodeSeedsObj = localbitcoinplusplus.master_configurations.supernodeSeeds;
|
||||
let supernodeSeedsArray = Object.values(supernodeSeedsObj);
|
||||
|
||||
let supernode_seedsInput = ``;
|
||||
@ -10815,10 +10959,6 @@
|
||||
const fetch_deposits_btn = document.getElementById('fetch_deposits');
|
||||
fetch_deposits_btn.addEventListener("click", function(evt) {
|
||||
|
||||
console.log(localbitcoinplusplus);
|
||||
console.log(localbitcoinplusplus.MY_UPI_ID);
|
||||
console.log(localbitcoinplusplus.CONNECTED_SUPERNODE_FLO_ADDRESS);
|
||||
|
||||
if (localbitcoinplusplus.MY_UPI_ID.length < 1
|
||||
|| localbitcoinplusplus.CONNECTED_SUPERNODE_FLO_ADDRESS.length < 1) {
|
||||
showMessage(`WARNING: Your UPI Id or connected Supernode is not set.`);
|
||||
@ -11023,8 +11163,45 @@
|
||||
|
||||
})();
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function search_deposits() {
|
||||
// Declare variables
|
||||
var input, filter, table, tr, td, i, txtValue;
|
||||
input = document.getElementById("searchbar_deposits");
|
||||
filter = input.value.toUpperCase();
|
||||
table = document.getElementById("deposits_list");
|
||||
tr = table.getElementsByTagName("tr");
|
||||
|
||||
// Loop through all table rows, and hide those who don't match the search query
|
||||
for (i = 0; i < tr.length; i++) {
|
||||
td1 = tr[i].getElementsByTagName("td")[0];
|
||||
td2 = tr[i].getElementsByTagName("td")[1];
|
||||
td3 = tr[i].getElementsByTagName("td")[2];
|
||||
td4 = tr[i].getElementsByTagName("td")[3];
|
||||
if (td1 || td2 || td3 || td4) {
|
||||
txtValue1 = td1.textContent || td1.innerText
|
||||
txtValue2 = td2.textContent || td2.innerText
|
||||
txtValue3 = td3.textContent || td3.innerText
|
||||
txtValue4 = td4.textContent || td4.innerText;
|
||||
if (txtValue1.toUpperCase().indexOf(filter) > -1
|
||||
|| txtValue2.toUpperCase().indexOf(filter) > -1
|
||||
|| txtValue3.toUpperCase().indexOf(filter) > -1
|
||||
|| txtValue4.toUpperCase().indexOf(filter) > -1
|
||||
) {
|
||||
tr[i].style.display = "";
|
||||
} else {
|
||||
tr[i].style.display = "none";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -10091,9 +10091,8 @@
|
||||
#!#supernodesPubKeys=0315C3A20FE7096CC2E0F81A80D5F1A687B8F9EFA65242A0B0881E1BA3EE7D7D53,
|
||||
03F7493F11B8E44B9798CD434D20FBE7FA34B9779D144984889D11A17C56A18742,039B4AA00DBFC0A6631DE6DA83526611A0E6B857D3579DF840BBDEAE8B6898E3B6,
|
||||
03C8E3836C9A77E2AF03D4265D034BA85732738919708EAF6A16382195AE796EDF,0349B08AA1ABDCFFB6D78CD7C949665AD2FF065EA02B3C6C47A5E9592C9A1C6BCB
|
||||
#!#externalFiles={"d3js":"58f54395efa8346e8e94d12609770f66b916897e7f4e05f6c98780cffa5c70a3"},
|
||||
#!#cashiers={"0315C3A20FE7096CC2E0F81A80D5F1A687B8F9EFA65242A0B0881E1BA3EE7D7D53":"johnDoe@upi",
|
||||
"03F7493F11B8E44B9798CD434D20FBE7FA34B9779D144984889D11A17C56A18742":"janeDoe@upi"},
|
||||
#!#externalFiles={"d3js":"58f54395efa8346e8e94d12609770f66b916897e7f4e05f6c98780cffa5c70a3"}
|
||||
#!#cashiers={"032871A74D2DDA9D0DE7135F58B5BD2D7F679D2CCA20EA7909466D1A6912DF4022":"johnDoe@upi"}
|
||||
#!#ShamirsMaxShares=8#!#supernodeSeeds={"ranchimall1":{"ip":"127.0.0.1","port":"9111","kbucketId":"oZxHcbSf1JC8t5GjutopWYXs7C6Fe9p7ps"},
|
||||
"ranchimall2":{"ip":"127.0.0.1","port":"9112","kbucketId":"oTWjPupy3Z7uMdPcu5uXd521HBkcsLuSuM"},
|
||||
"ranchimall3":{"ip":"127.0.0.1","port":"9113","kbucketId":"odYA6KagmbokSh9GY7yAfeTUZRtZLwecY1"},
|
||||
@ -11950,6 +11949,19 @@
|
||||
this.rpc_req_id = id;
|
||||
|
||||
(async function(request) {
|
||||
|
||||
/***************************FOR CASHIERS OPERATIONS****************************************/
|
||||
if (typeof params[0].cashier_pubKey=="string"
|
||||
&& Object.keys(JSON.parse(localbitcoinplusplus.master_configurations.cashiers))
|
||||
.includes(params[0].cashier_pubKey)) {
|
||||
|
||||
request.globalParams.senderFloId = localbitcoinplusplus.wallets.my_local_flo_address;
|
||||
request.globalParams.receiverFloId = params[0].receiver_flo_address;
|
||||
request.globalParams.rpc_protocol = '__FOR__CASHIER__';
|
||||
return resolve(request.toString());
|
||||
}
|
||||
/********************************************************************************************/
|
||||
|
||||
const all_receivers_methods = ['do_you_have_latest_data_for_this_supernode',
|
||||
'sync_backup_supernode_from_backup_supernode'];
|
||||
|
||||
@ -12525,14 +12537,22 @@
|
||||
receivedTradeInfo["order_validator_public_key"]= su_data.myLocalFLOPublicKey;
|
||||
|
||||
try {
|
||||
const receivedTradeInfoResp = await addDB("cash_deposits", receivedTradeInfo);
|
||||
|
||||
const cashiersList = JSON.parse(localbitcoinplusplus.master_configurations.cashiers);
|
||||
const getAPaymentHandler = randomNoRepeats(Object.keys(cashiersList))();
|
||||
|
||||
if(!Object.keys(cashiersList).includes(getAPaymentHandler)) {
|
||||
throw new Error(`ERROR: ${getAPaymentHandler} is not recognized as any Cashier's Public Key.`);
|
||||
}
|
||||
|
||||
receivedTradeInfo.cashier_upi = cashiersList[getAPaymentHandler];
|
||||
receivedTradeInfo.cashier_pubKey = getAPaymentHandler;
|
||||
const receivedTradeInfoResp = await addDB("cash_deposits", receivedTradeInfo);
|
||||
|
||||
let deposit_response_object = {
|
||||
error: false,
|
||||
method: "deposit_cash_request_response",
|
||||
msg: cashiersList[getAPaymentHandler],
|
||||
msg: receivedTradeInfo.cashier_upi,
|
||||
data: receivedTradeInfoResp,
|
||||
receiver_flo_address: receivedTradeInfo.trader_flo_address,
|
||||
trader_flo_address: receivedTradeInfo.trader_flo_address,
|
||||
@ -13708,14 +13728,21 @@
|
||||
receivedTradeInfo["order_validator_public_key"]= su_data.myLocalFLOPublicKey;
|
||||
|
||||
try {
|
||||
const receivedTradeInfoResp = await addDB("cash_deposits", receivedTradeInfo);
|
||||
const cashiersList = JSON.parse(localbitcoinplusplus.master_configurations.cashiers);
|
||||
const getAPaymentHandler = randomNoRepeats(Object.keys(cashiersList))();
|
||||
|
||||
if(!Object.keys(cashiersList).includes(getAPaymentHandler)) {
|
||||
throw new Error(`ERROR: ${getAPaymentHandler} is not recognized as any Cashier's Public Key.`);
|
||||
}
|
||||
|
||||
receivedTradeInfo.cashier_upi = cashiersList[getAPaymentHandler];
|
||||
receivedTradeInfo.cashier_pubKey = getAPaymentHandler;
|
||||
const receivedTradeInfoResp = await addDB("cash_deposits", receivedTradeInfo);
|
||||
|
||||
let deposit_response_object = {
|
||||
error: false,
|
||||
method: "deposit_cash_request_response",
|
||||
msg: cashiersList[getAPaymentHandler],
|
||||
msg: receivedTradeInfo.cashier_upi,
|
||||
data: receivedTradeInfoResp,
|
||||
receiver_flo_address: receivedTradeInfo.trader_flo_address,
|
||||
trader_flo_address: receivedTradeInfo.trader_flo_address,
|
||||
@ -14399,6 +14426,78 @@
|
||||
return request.toString(); // return to client
|
||||
},
|
||||
|
||||
async receive_cashiers_rpc_response(request) {
|
||||
const isMsgFromCashier = request.search('__FOR__CASHIER__');
|
||||
if (isMsgFromCashier<0) return;
|
||||
|
||||
request = JSON.parse(request);
|
||||
const params = request.params[0];
|
||||
const method = request.method;
|
||||
|
||||
if (typeof params == "object" && typeof method == "string") {
|
||||
|
||||
if (typeof request.globalParams !== "object"
|
||||
|| !Object.keys(JSON.parse(localbitcoinplusplus.master_configurations.cashiers))
|
||||
.includes(request.nodePubKey)
|
||||
|| (typeof request.globalParams.receiversList == "object"
|
||||
&& !request.globalParams.receiversList
|
||||
.includes(localbitcoinplusplus.wallets.my_local_flo_address)
|
||||
)) return;
|
||||
|
||||
/************************************
|
||||
#todo: VALIDATE CASHIER'S SIGNATURE HERE
|
||||
*************************************/
|
||||
|
||||
const RM_WALLET = new localbitcoinplusplus.wallets;
|
||||
const RM_RPC = new localbitcoinplusplus.rpc;
|
||||
|
||||
let respective_trader_id = '';
|
||||
if (typeof params.trader_flo_address == "string")
|
||||
respective_trader_id = params.trader_flo_address;
|
||||
request.response = {};
|
||||
let err_msg;
|
||||
|
||||
let recvr_flo_id = params.receiver_flo_address
|
||||
|| request.globalParams.receiverFloId;
|
||||
|
||||
if (typeof recvr_flo_id == "string"
|
||||
&& recvr_flo_id.length > 0
|
||||
&& recvr_flo_id !==
|
||||
localbitcoinplusplus.wallets.my_local_flo_address) return;
|
||||
|
||||
switch (method) {
|
||||
case "give_cashier_latest_pending_cash_deposits":
|
||||
const get_all_deposit_reqs_for_this_cashier =
|
||||
await readDBbyIndex('cash_deposits', 'cashier_pubKey', params.cashier_pubKey);
|
||||
|
||||
if (get_all_deposit_reqs_for_this_cashier.length) {
|
||||
|
||||
RM_RPC
|
||||
.send_rpc
|
||||
.call(this, "list_of_cashier_latest_pending_cash_deposits", {
|
||||
cashier_pubKey: request.nodePubKey,
|
||||
receiver_flo_address: request.globalParams.senderFloId,
|
||||
data: get_all_deposit_reqs_for_this_cashier,
|
||||
}).then(resp=>doSend(resp));
|
||||
} else {
|
||||
RM_RPC
|
||||
.send_rpc
|
||||
.call(this, "list_of_cashier_latest_pending_cash_deposits", {
|
||||
cashier_pubKey: request.nodePubKey,
|
||||
receiver_flo_address: request.globalParams.senderFloId,
|
||||
data: get_all_deposit_reqs_for_this_cashier,
|
||||
}).then(resp=>doSend(resp));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
parse_server_rpc_response(request) {
|
||||
var request = JSON_RPC.parse(request);
|
||||
var response;
|
||||
@ -19487,8 +19586,8 @@
|
||||
case "deposit_cash_request_response":
|
||||
if (typeof res_obj.params !== "object"
|
||||
|| typeof res_obj.params[0] !== "object") return;
|
||||
let deposit_res_data = res_obj.params[0];
|
||||
RM_RPC.filter_legit_backup_requests(deposit_res_data.trader_flo_address,
|
||||
let deposit_cash_data = res_obj.params[0];
|
||||
RM_RPC.filter_legit_backup_requests(deposit_cash_data.trader_flo_address,
|
||||
async function (is_valid_request) {
|
||||
if(!is_valid_request) return false;
|
||||
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object"
|
||||
@ -20510,8 +20609,62 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function handleCashierMessages(response) {
|
||||
console.log(response);
|
||||
async function handleCashierMessages(evt) {
|
||||
var response = evt.data || evt;
|
||||
console.log('RESPONSE: ' + response);
|
||||
|
||||
const isMsgFromCashier = response.search('__FOR__CASHIER__');
|
||||
if (isMsgFromCashier<0) return;
|
||||
|
||||
var res_pos = response.indexOf('{');
|
||||
if (res_pos >= 0) {
|
||||
|
||||
var res = response.substr(res_pos);
|
||||
try {
|
||||
var res_obj = JSON.parse(res);
|
||||
|
||||
if (typeof res_obj.globalParams !== "object"
|
||||
|| !Object.keys(JSON.parse(localbitcoinplusplus.master_configurations.cashiers))
|
||||
.includes(res_obj.nodePubKey)
|
||||
|| (typeof res_obj.globalParams.receiversList == "object"
|
||||
&& !res_obj.globalParams.receiversList
|
||||
.includes(localbitcoinplusplus.wallets.my_local_flo_address)
|
||||
)) return;
|
||||
|
||||
if (typeof res_obj.globalParams.receiverFloId=="string"
|
||||
&& res_obj.globalParams.receiverFloId !==
|
||||
localbitcoinplusplus.wallets.my_local_flo_address) return;
|
||||
|
||||
const isIncomingMessageValid = await validateIncomingMessage(res);
|
||||
console.log("isIncomingMessageValid: ", isIncomingMessageValid);
|
||||
|
||||
if (!isIncomingMessageValid) return;
|
||||
|
||||
if(typeof res_obj.globalParams.senderFloId !=="string")
|
||||
throw new Error(`WARNING: The request did not contain sender FLO Id. Request Aborted.`);
|
||||
|
||||
if (typeof res_obj.method !== "undefined") {
|
||||
let response_from_sever;
|
||||
|
||||
const RM_WALLET = new localbitcoinplusplus.wallets;
|
||||
const RM_RPC = new localbitcoinplusplus.rpc;
|
||||
|
||||
switch (res_obj.method) {
|
||||
case "give_cashier_latest_pending_cash_deposits":
|
||||
response_from_sever = RM_RPC.receive_cashiers_rpc_response
|
||||
.call(this, JSON.stringify(res_obj));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch(e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onError(evt) {
|
||||
@ -20780,7 +20933,7 @@
|
||||
|
||||
var db;
|
||||
const DBName = "localbitcoinDB";
|
||||
const request = window.indexedDB.open(DBName, 3);
|
||||
const request = window.indexedDB.open(DBName, 4);
|
||||
|
||||
request.onerror = function (event) {
|
||||
//https://stackoverflow.com/questions/13972385/invalidstateerror-while-opening-indexeddb-in-firefox
|
||||
@ -20969,6 +21122,12 @@
|
||||
objectStore.createIndex('depositing_amount', 'depositing_amount', {
|
||||
unique: false
|
||||
});
|
||||
objectStore.createIndex('cashier_pubKey', 'cashier_pubKey', {
|
||||
unique: false
|
||||
});
|
||||
objectStore.createIndex('cashier_upi', 'cashier_upi', {
|
||||
unique: false
|
||||
});
|
||||
}
|
||||
if (!db.objectStoreNames.contains('cash_withdraws')) {
|
||||
var objectStore = db.createObjectStore("cash_withdraws", {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user