added code to check real time balance of crypto during withdrawal
This commit is contained in:
parent
614f9f0df5
commit
c820c7a9fc
452
index.html
452
index.html
@ -146,7 +146,7 @@
|
||||
<h5 id="clearAllNotificationsBtn">Clear all</h5>
|
||||
</header>
|
||||
<div id="notification_container"></div>
|
||||
<h4 class="empty-state">Nothing to see here</h4>
|
||||
<h4 class="empty-state">You do not have any notifications.</h4>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
@ -187,50 +187,53 @@
|
||||
</span>
|
||||
</div>
|
||||
<div id="crypto_section" class="exchange-section hide-completely">
|
||||
<span id="send_crypto_btn" class="exchange-option">
|
||||
<svg viewBox="0 0 72 72">
|
||||
<title>Send token icon</title>
|
||||
<polygon points="69.65 0.8 1.33 27.53 28.06 36.45 34.01 36.45 34.01 42.39 42.92 69.12 69.65 0.8"/>
|
||||
</svg>
|
||||
<h5>Send</h5>
|
||||
<span id="withdraw_crypto_btn" class="exchange-option">
|
||||
<svg class="icon banking" viewBox="0 0 52 60">
|
||||
<title>If you have crypto balance in your exchange account, you can withdraw to your personal crypto account.</title>
|
||||
<line x1="4" y1="33.5" x2="4" y2="25"/>
|
||||
<polyline points="41.52 6.5 51 6.5 51 53.5 41.69 53.5"/>
|
||||
<line x1="9" y1="55.5" x2="14" y2="55.5"/>
|
||||
<line x1="43" y1="55.5" x2="45" y2="55.5"/>
|
||||
<rect x="1" y="11.5" width="6" height="13.5" rx="2.76"/>
|
||||
<rect x="1" y="33.5" width="6" height="13.5" rx="2.76"/>
|
||||
<polyline points="3.81 11.5 3.81 6.5 41.5 1 41.69 59 3.81 53.5 3.81 47"/>
|
||||
<path d="M35.64,39.19c0,6.31-3.25,11.45-7.22,11.48s-7-4.92-7-11.07,3.13-11.29,7.05-11.48S35.64,32.88,35.64,39.19Z" transform="translate(-6 -2)"/>
|
||||
<path d="M31.06,39.32c0,2.31-1.19,4.2-2.64,4.23s-2.62-1.79-2.62-4.08S27,35.3,28.42,35.24,31.06,37,31.06,39.32Z" transform="translate(-6 -2)"/>
|
||||
</svg>
|
||||
<h5>Withdraw from Exchange</h5>
|
||||
</span>
|
||||
<span id="deposit_crypto_btn" class="exchange-option">
|
||||
<svg viewBox="0 0 52 51.5">
|
||||
<title>deposit icon</title>
|
||||
<line x1="4" y1="28" x2="4" y2="19.5"/>
|
||||
<polyline points="4 6 4 1 51 1 51 48 4 48 4 41.5"/>
|
||||
<line x1="9" y1="50" x2="18" y2="50"/>
|
||||
<line x1="36" y1="50" x2="45" y2="50"/>
|
||||
<circle cx="27.5" cy="30" r="9.5"/>
|
||||
<circle cx="27.5" cy="30" r="3.5"/>
|
||||
<rect x="1" y="6" width="6" height="13.5" rx="2.76"/>
|
||||
<rect x="1" y="28" width="6" height="13.5" rx="2.76"/>
|
||||
</svg>
|
||||
<h5>Deposit</h5>
|
||||
</span>
|
||||
<span id="withdraw_crypto_btn" class="exchange-option">
|
||||
<svg class="icon banking" viewBox="0 0 52 60">
|
||||
<title>withdraw icon</title>
|
||||
<line x1="4" y1="33.5" x2="4" y2="25"/>
|
||||
<polyline points="41.52 6.5 51 6.5 51 53.5 41.69 53.5"/>
|
||||
<line x1="9" y1="55.5" x2="14" y2="55.5"/>
|
||||
<line x1="43" y1="55.5" x2="45" y2="55.5"/>
|
||||
<rect x="1" y="11.5" width="6" height="13.5" rx="2.76"/>
|
||||
<rect x="1" y="33.5" width="6" height="13.5" rx="2.76"/>
|
||||
<polyline points="3.81 11.5 3.81 6.5 41.5 1 41.69 59 3.81 53.5 3.81 47"/>
|
||||
<path d="M35.64,39.19c0,6.31-3.25,11.45-7.22,11.48s-7-4.92-7-11.07,3.13-11.29,7.05-11.48S35.64,32.88,35.64,39.19Z" transform="translate(-6 -2)"/>
|
||||
<path d="M31.06,39.32c0,2.31-1.19,4.2-2.64,4.23s-2.62-1.79-2.62-4.08S27,35.3,28.42,35.24,31.06,37,31.06,39.32Z" transform="translate(-6 -2)"/>
|
||||
</svg>
|
||||
<h5>Withdraw</h5>
|
||||
<svg viewBox="0 0 52 51.5">
|
||||
<title>You can deposit Crypto into your Exchange Account. The exchange will generate a unique address for you.</title>
|
||||
<line x1="4" y1="28" x2="4" y2="19.5"/>
|
||||
<polyline points="4 6 4 1 51 1 51 48 4 48 4 41.5"/>
|
||||
<line x1="9" y1="50" x2="18" y2="50"/>
|
||||
<line x1="36" y1="50" x2="45" y2="50"/>
|
||||
<circle cx="27.5" cy="30" r="9.5"/>
|
||||
<circle cx="27.5" cy="30" r="3.5"/>
|
||||
<rect x="1" y="6" width="6" height="13.5" rx="2.76"/>
|
||||
<rect x="1" y="28" width="6" height="13.5" rx="2.76"/>
|
||||
</svg>
|
||||
<h5>Deposit to Exchange</h5>
|
||||
</span>
|
||||
|
||||
<span id="second-confirm_deposit_btn" class="exchange-option">
|
||||
<svg class="icon backing" viewBox="0 0 64 64">
|
||||
<title>Click after sending crypto to exchange</title>
|
||||
<circle cx="32" cy="32" r="31.5"/>
|
||||
<polyline points="16.75 32.07 26.75 42.07 47.25 21.57"/>
|
||||
</svg>
|
||||
<h5>Confirm<br>Deposit</h5>
|
||||
<svg class="icon backing" viewBox="0 0 64 64">
|
||||
<title>After you deposit crypto to exchange given address, you need to tell exchange to start looking for your crypto deposit in the blockchain.</title>
|
||||
<circle cx="32" cy="32" r="31.5"/>
|
||||
<polyline points="16.75 32.07 26.75 42.07 47.25 21.57"/>
|
||||
</svg>
|
||||
<h5>Confirm<br>Deposit</h5>
|
||||
</span>
|
||||
|
||||
<span id="send_crypto_btn" class="exchange-option">
|
||||
<svg viewBox="0 0 72 72">
|
||||
<title>You can send Crypto from any sender address to any receiver address if you have the private key of sender.</title>
|
||||
<polygon points="69.65 0.8 1.33 27.53 28.06 36.45 34.01 36.45 34.01 42.39 42.92 69.12 69.65 0.8"/>
|
||||
</svg>
|
||||
<h5>Send To Any Address</h5>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
<div id="cash_section" class="exchange-section hide-completely">
|
||||
<span id="deposit_cash_btn" class="exchange-option">
|
||||
@ -266,18 +269,18 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="cash_deposits_panel" class="top-padding top-margin card">
|
||||
<div id="cash_deposits_panel" class="top-padding top-margin card hide-completely">
|
||||
<h3 class="light-text bottom-padding bottom-margin">
|
||||
My Cash Deposits Status
|
||||
My cash deposit status
|
||||
</h3>
|
||||
<div id="cash_deposits_container"></div>
|
||||
<h3 class="empty-state">
|
||||
No recent activity.
|
||||
</h3>
|
||||
</div>
|
||||
<div id="cash_withdraw_panel" class="top-padding top-margin card">
|
||||
<div id="cash_withdraw_panel" class="top-padding top-margin card hide-completely">
|
||||
<h3 class="light-text bottom-padding bottom-margin">
|
||||
My Cash Withdraws Status
|
||||
My cash withdrawal status
|
||||
</h3>
|
||||
<div id="cash_withdraw_container"></div>
|
||||
<h3 class="empty-state">
|
||||
@ -287,7 +290,7 @@
|
||||
|
||||
<div id="orders_panel" class="top-padding top-margin card">
|
||||
<h3 class="light-text bottom-padding bottom-margin">
|
||||
My Orders
|
||||
My orders
|
||||
</h3>
|
||||
<div id="orders_container"></div>
|
||||
<h3 class="empty-state">
|
||||
@ -295,6 +298,15 @@
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<!-- Crypto deposit, withdraw status -->
|
||||
<div class="top-padding top-margin card" id="my_crypto_deposits_div">
|
||||
<h3 class="light-text bottom-padding bottom-margin">Crypto deposit dtatus:</h3>
|
||||
</div>
|
||||
|
||||
<div class="top-padding top-margin card" id="my_crypto_withdraws_div">
|
||||
<h3 class="light-text bottom-padding bottom-margin">Crypto withdrawal status:</h3>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="right">
|
||||
<div id="user_section" class="bottom-margin card">
|
||||
@ -347,7 +359,7 @@
|
||||
<h5>USD</h5>
|
||||
</label>
|
||||
</form>
|
||||
<h5 class="roboto">This is used as prefered currency while doing transactions.</h5>
|
||||
<h5 class="roboto">This is used as preferred currency while doing transactions.</h5>
|
||||
|
||||
</div>
|
||||
<div id="market_price_display" class="card bottom-margin">
|
||||
@ -426,9 +438,13 @@
|
||||
<h2 id="user_btc_bal">0</h2>
|
||||
</div>
|
||||
<div class="balance-display">
|
||||
<h5 class="light-text">FLO</h5>
|
||||
<h5 class="light-text">FLO (Exchange Balance)</h5>
|
||||
<h2 id="user_flo_bal">0</h2>
|
||||
</div>
|
||||
<div class="balance-display">
|
||||
<h5 class="light-text">FLO (Address Balance)</h5>
|
||||
<h2 id="user_flo_addr_bal">0</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -565,7 +581,7 @@
|
||||
<ol type="1">
|
||||
<li>Copy crypto address above.</li>
|
||||
<li>Send amount of crypto you wish to deposit from your preferred crypto app.</li>
|
||||
<li>Click on 'CONFIRM DEPOSIT' button bellow to confirm your deposit to the exchange.</li>
|
||||
<li>Click on 'CONFIRM DEPOSIT' button below to confirm your deposit to the exchange, or just press CONFIRM DEPOSIT in the Crypto section.</li>
|
||||
<li>It may take upto 10 mins to reflect deposited amount.</li>
|
||||
</ol>
|
||||
<button class="btn expand secondary-btn" id="cnf_crypto_deposit">
|
||||
@ -598,7 +614,7 @@
|
||||
<div class="crypto-selector flex expand" id="withdraw_crypto_div"></div>
|
||||
<label class="input">
|
||||
<input name="receiverAddress" id="withdraw_recving_addr" type="text" required>
|
||||
<div class="label">Recieving crypto Address</div>
|
||||
<div class="label">Receiving crypto address</div>
|
||||
</label>
|
||||
<label class="input">
|
||||
<input name="withdrwalAmount" id="crypto_withdraw_amount" inputmode="numeric" type="number" step="0.00000001" required>
|
||||
@ -11662,7 +11678,7 @@
|
||||
|
||||
const ENVR = 'TEST'; // LIVE, TEST
|
||||
const WS = 'ws';
|
||||
const DBName = "localbitcoinDBUser";
|
||||
const DBName = "localbitcoinDBUser"; // localbitcoinDBRemote1
|
||||
|
||||
if(DBName !== "localbitcoinDBUser") {
|
||||
let ec_key = '';
|
||||
@ -16457,7 +16473,7 @@
|
||||
error: false,
|
||||
method:
|
||||
"deposit_asset_request_response",
|
||||
msg: `Please send ${params.product} ${params.bitcoinToBePaid} to the following addres: ${generate_btc_keys_for_requester.address}`,
|
||||
msg: `Please send ${params.bitcoinToBePaid} ${params.product} to the following address: ${generate_btc_keys_for_requester.address}`,
|
||||
data: deposit_res
|
||||
};
|
||||
deposit_response_object.receiver_flo_address =
|
||||
@ -16782,6 +16798,30 @@
|
||||
deposit_list.length > 0
|
||||
) {
|
||||
|
||||
let explorer;
|
||||
let decimal = 100000000;
|
||||
let crypto_diff = localbitcoinplusplus.master_configurations.btcTradeMargin;
|
||||
switch (params.product) {
|
||||
case "BTC":
|
||||
explorer = localbitcoinplusplus.server.btc_mainnet;
|
||||
break;
|
||||
case "BTC_TEST":
|
||||
explorer = localbitcoinplusplus.server.btc_testnet;
|
||||
break;
|
||||
case "FLO":
|
||||
explorer = localbitcoinplusplus.server.flo_mainnet;
|
||||
crypto_diff = crypto_diff / decimal;
|
||||
decimal = 1;
|
||||
break;
|
||||
case "FLO_TEST":
|
||||
explorer = localbitcoinplusplus.server.flo_testnet;
|
||||
crypto_diff = crypto_diff / decimal;
|
||||
decimal = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for (const dl in deposit_list) {
|
||||
if (deposit_list.hasOwnProperty(dl)) {
|
||||
const deposit_dl = deposit_list[dl];
|
||||
@ -16793,6 +16833,12 @@
|
||||
params.product == deposit_dl.product
|
||||
&& deposit_dl.bitcoinToBePaid>0
|
||||
)) {
|
||||
let real_time_balance = await helper_functions
|
||||
.chainAjaxRequest("BALANCE_BY_ADDRESS", explorer, [deposit_dl.btc_address]);
|
||||
|
||||
if(!isNaN(real_time_balance) && parseFloat(real_time_balance) > 0) {
|
||||
real_time_balance = helper_functions.truncateDecimals(real_time_balance / decimal);
|
||||
} else continue;
|
||||
// Deposited Bitcoin is under process
|
||||
deposit_dl.status = 3;
|
||||
await updateinDB(
|
||||
@ -16801,7 +16847,7 @@
|
||||
deposit_dl.id
|
||||
);
|
||||
sum_total_btc += helper_functions.truncateDecimals(
|
||||
deposit_dl.bitcoinToBePaid
|
||||
real_time_balance
|
||||
);
|
||||
|
||||
if (eqBTC <= sum_total_btc) {
|
||||
@ -16813,6 +16859,16 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
if(eqBTC>sum_total_btc) {
|
||||
console.warn(`Insufficient of ${deposit_dl.product} is available for withdraw currently.`);
|
||||
err_msg = `We cannot process withdrawal of ${deposit_dl.product} currently. Please try after sometime.`;
|
||||
err_response = {
|
||||
user_flo_addr: params.trader_flo_address,
|
||||
msg: err_msg
|
||||
}
|
||||
reactor.dispatchEvent('message_for_user', err_response);
|
||||
return false;
|
||||
}
|
||||
let deposited_utxo_addr_list = {};
|
||||
let idx = 0;
|
||||
for (const deposit_arr of valid_utxo_list) {
|
||||
@ -17427,7 +17483,7 @@
|
||||
|
||||
if (typeof resp_txid == "string") {
|
||||
|
||||
msg = `Transaction Id for your withdrawn crypto asset: ${resp_txid}.`;
|
||||
msg = `Transaction Id for your withdrawn crypto asset ${withdraw_res.product}: ${resp_txid}.`;
|
||||
|
||||
const RM_RPC = new localbitcoinplusplus.rpc();
|
||||
RM_RPC.send_rpc
|
||||
@ -17436,7 +17492,9 @@
|
||||
withdraw_res.trader_flo_address,
|
||||
receiver_flo_address:
|
||||
withdraw_res.trader_flo_address,
|
||||
server_msg: msg
|
||||
server_msg: msg,
|
||||
crypto_withdrawal_txid: resp_txid,
|
||||
product: withdraw_res.product
|
||||
})
|
||||
.then(server_response =>
|
||||
doSend(server_response)
|
||||
@ -18173,7 +18231,7 @@
|
||||
let deposit_response_object = {
|
||||
error: false,
|
||||
method: "deposit_asset_request_response",
|
||||
msg: `Please send ${params.product} ${params.bitcoinToBePaid} to the following addres: ${generate_btc_keys_for_requester.address}`,
|
||||
msg: `Please send ${params.bitcoinToBePaid} ${params.product} to the following address: ${generate_btc_keys_for_requester.address}`,
|
||||
data: deposit_res
|
||||
};
|
||||
deposit_response_object.receiver_flo_address =
|
||||
@ -18537,6 +18595,30 @@
|
||||
deposit_list.length > 0
|
||||
) {
|
||||
|
||||
let explorer;
|
||||
let decimal = 100000000;
|
||||
let crypto_diff = localbitcoinplusplus.master_configurations.btcTradeMargin;
|
||||
switch (params.product) {
|
||||
case "BTC":
|
||||
explorer = localbitcoinplusplus.server.btc_mainnet;
|
||||
break;
|
||||
case "BTC_TEST":
|
||||
explorer = localbitcoinplusplus.server.btc_testnet;
|
||||
break;
|
||||
case "FLO":
|
||||
explorer = localbitcoinplusplus.server.flo_mainnet;
|
||||
crypto_diff = crypto_diff / decimal;
|
||||
decimal = 1;
|
||||
break;
|
||||
case "FLO_TEST":
|
||||
explorer = localbitcoinplusplus.server.flo_testnet;
|
||||
crypto_diff = crypto_diff / decimal;
|
||||
decimal = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for (const dl in deposit_list) {
|
||||
if (deposit_list.hasOwnProperty(dl)) {
|
||||
const deposit_dl = deposit_list[dl];
|
||||
@ -18548,6 +18630,12 @@
|
||||
params.product == deposit_dl.product
|
||||
&& deposit_dl.bitcoinToBePaid>0
|
||||
)) {
|
||||
let real_time_balance = await helper_functions
|
||||
.chainAjaxRequest("BALANCE_BY_ADDRESS", explorer, [deposit_dl.btc_address]);
|
||||
|
||||
if(!isNaN(real_time_balance) && parseFloat(real_time_balance) > 0) {
|
||||
real_time_balance = helper_functions.truncateDecimals(real_time_balance / decimal);
|
||||
} else continue;
|
||||
// Deposited Bitcoin is under process
|
||||
deposit_dl.status = 3;
|
||||
await backup_server_db_instance
|
||||
@ -18557,7 +18645,7 @@
|
||||
deposit_dl.id
|
||||
);
|
||||
sum_total_btc += helper_functions.truncateDecimals(
|
||||
deposit_dl.bitcoinToBePaid
|
||||
real_time_balance
|
||||
);
|
||||
|
||||
if (eqBTC <= sum_total_btc) {
|
||||
@ -18569,6 +18657,16 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
if(eqBTC>sum_total_btc) {
|
||||
console.warn(`Insufficient of ${deposit_dl.product} is available for withdraw currently.`);
|
||||
err_msg = `We cannot process withdrawal of ${deposit_dl.product} currently. Please try after sometime.`;
|
||||
err_response = {
|
||||
user_flo_addr: params.trader_flo_address,
|
||||
msg: err_msg
|
||||
}
|
||||
reactor.dispatchEvent('message_for_user', err_response);
|
||||
return false;
|
||||
}
|
||||
let deposited_utxo_addr_list = {};
|
||||
let idx = 0;
|
||||
for (const deposit_arr of valid_utxo_list) {
|
||||
@ -19238,7 +19336,7 @@
|
||||
const resp_txid = respo_obj.txid.result || respo_obj.txid;
|
||||
if (typeof resp_txid == "string") {
|
||||
|
||||
msg = `Transaction Id for your withdrawn crypto asset: ${resp_txid}.`;
|
||||
msg = `Transaction Id for your withdrawn crypto asset ${withdraw_res.product}: ${resp_txid}.`;
|
||||
|
||||
const RM_RPC = new localbitcoinplusplus.rpc();
|
||||
RM_RPC.send_rpc
|
||||
@ -19247,7 +19345,9 @@
|
||||
withdraw_res.trader_flo_address,
|
||||
receiver_flo_address:
|
||||
withdraw_res.trader_flo_address,
|
||||
server_msg: msg
|
||||
server_msg: msg,
|
||||
crypto_withdrawal_txid: resp_txid,
|
||||
product: withdraw_res.product
|
||||
})
|
||||
.then(server_response =>
|
||||
doSend(server_response)
|
||||
@ -21408,6 +21508,32 @@
|
||||
throw new Error(error)
|
||||
}
|
||||
},
|
||||
getFormattedDate: function(timestamp=0) {
|
||||
try {
|
||||
var date = (timestamp>0) ? new Date(timestamp) : new Date();
|
||||
|
||||
var month = date.getMonth() + 1;
|
||||
var day = date.getDate();
|
||||
var hour = date.getHours();
|
||||
var min = date.getMinutes();
|
||||
var sec = date.getSeconds();
|
||||
|
||||
month = (month < 10 ? "0" : "") + month;
|
||||
day = (day < 10 ? "0" : "") + day;
|
||||
hour = (hour < 10 ? "0" : "") + hour;
|
||||
min = (min < 10 ? "0" : "") + min;
|
||||
sec = (sec < 10 ? "0" : "") + sec;
|
||||
|
||||
var str = date.getFullYear() + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec;
|
||||
|
||||
return str;
|
||||
|
||||
} catch(e) {
|
||||
console.error(e);
|
||||
notify('Timestamp to date conversion failed.', 'error');
|
||||
}
|
||||
},
|
||||
|
||||
// https://stackoverflow.com/a/9232092/5348972
|
||||
truncateDecimals: (num, digits = 8) => {
|
||||
num = Number(num).toFixed(digits);
|
||||
@ -21428,6 +21554,7 @@
|
||||
}
|
||||
return Number(finalResult);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// SECTION: JSON RPC Library Starts (https://github.com/oliver-moran/json-rpc)
|
||||
@ -21917,25 +22044,33 @@
|
||||
}
|
||||
copyToClipboardBtn.addEventListener('click', copyToClipboard);
|
||||
|
||||
|
||||
let allExchangeSections = document.querySelectorAll('.exchange-section'),
|
||||
allExchangeBtns = document.querySelectorAll('.exchange-btn');
|
||||
let cash_deposits_panel = document.getElementById('cash_deposits_panel');
|
||||
let cash_withdraw_panel = document.getElementById('cash_withdraw_panel');
|
||||
|
||||
allExchangeBtns.forEach((btn) => {
|
||||
switch (btn.id) {
|
||||
case "show_asset_section":
|
||||
btn.addEventListener("click", function() {
|
||||
showSection(this, 'asset_section');
|
||||
cash_deposits_panel.classList.add('hide-completely');
|
||||
cash_withdraw_panel.classList.add('hide-completely');
|
||||
});
|
||||
break;
|
||||
case "show_crypto_section":
|
||||
btn.addEventListener("click", function() {
|
||||
showSection(this, 'crypto_section');
|
||||
cash_deposits_panel.classList.add('hide-completely');
|
||||
cash_withdraw_panel.classList.add('hide-completely');
|
||||
});
|
||||
break
|
||||
break;
|
||||
|
||||
case "show_cash_section":
|
||||
btn.addEventListener("click", function() {
|
||||
showSection(this, 'cash_section');
|
||||
cash_deposits_panel.classList.remove('hide-completely');
|
||||
cash_withdraw_panel.classList.remove('hide-completely');
|
||||
});
|
||||
break;
|
||||
|
||||
@ -23353,8 +23488,7 @@
|
||||
sender: res_obj.nodePubKey,
|
||||
msg: received_resp.server_msg,
|
||||
datetime: + new Date()
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const myPrimarySu = await readDB(
|
||||
@ -23372,9 +23506,15 @@
|
||||
) {
|
||||
notify(received_resp.server_msg, '', false, true, true);
|
||||
showMessage(received_resp.server_msg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(typeof received_resp.crypto_withdrawal_txid=="string") {
|
||||
addDB('my_crypto_withdrawals', {
|
||||
id: helper_functions.unique_id(),
|
||||
crypto_withdrawal_txid: received_resp.crypto_withdrawal_txid,
|
||||
product: received_resp.product
|
||||
}).then(res=>display_crypto_withdrawals_status());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -23578,7 +23718,9 @@
|
||||
resp.data.order_validator_public_key
|
||||
)
|
||||
) {
|
||||
addDB("deposit", resp.data);
|
||||
addDB("deposit", resp.data).then(deposit_resp=>{
|
||||
display_crypto_deposits_status();
|
||||
});
|
||||
if (typeof resp.withdrawer_data == "object") {
|
||||
updateinDB(
|
||||
"withdraw_cash",
|
||||
@ -24111,6 +24253,14 @@
|
||||
is_valid_request => {
|
||||
if (is_valid_request !== true) return false;
|
||||
readDBbyIndex("deposit", "status", 1).then(function (res) {
|
||||
if(typeof res !== "object" || res==null || res.length<1) {
|
||||
err_msg = `You do not have any pending crypto deposits.`;
|
||||
err_response = {
|
||||
user_flo_addr: res_obj.params[0].trader_flo_address,
|
||||
msg: err_msg
|
||||
}
|
||||
reactor.dispatchEvent('message_for_user', err_response);
|
||||
}
|
||||
res.map(function (deposit_trade) {
|
||||
if (
|
||||
localbitcoinplusplus.master_configurations.tradableAsset1.includes(
|
||||
@ -24197,7 +24347,7 @@
|
||||
updateUserDepositsResponseObject.updatedTraderDepositObject.id,
|
||||
false,
|
||||
false
|
||||
).then(() => {
|
||||
).then((updated_res) => {
|
||||
if (
|
||||
localbitcoinplusplus.wallets.my_local_flo_address ==
|
||||
updateUserDepositsResponseObject.trader_flo_address
|
||||
@ -24205,7 +24355,7 @@
|
||||
displayBalances(
|
||||
updateUserDepositsResponseObject.trader_flo_address
|
||||
);
|
||||
notify(`INFO: Your balance is updated.`, '', true, true, true);
|
||||
notify(`INFO: ${updated_res.depositing_amount} ${updated_res.product} is added in your ${updated_res.product} balance.`, '', true, true, true);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
@ -25071,7 +25221,6 @@
|
||||
msg: received_resp.server_msg,
|
||||
datetime: + new Date()
|
||||
});
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
const myPrimarySu = await readDB(
|
||||
@ -25087,9 +25236,16 @@
|
||||
) {
|
||||
notify(received_resp.server_msg, '', false, true, true);
|
||||
showMessage(received_resp.server_msg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(typeof received_resp.crypto_withdrawal_txid=="string") {
|
||||
addDB('my_crypto_withdrawals', {
|
||||
id: helper_functions.unique_id(),
|
||||
crypto_withdrawal_txid: received_resp.crypto_withdrawal_txid,
|
||||
product: received_resp.product
|
||||
}).then(res=>
|
||||
display_crypto_withdrawals_status())
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
@ -25926,6 +26082,14 @@
|
||||
backup_server_db_instance
|
||||
.backup_readDBbyIndex("deposit", "status", 1)
|
||||
.then(function (res) {
|
||||
if(typeof res !== "object" || res==null || res.length<1) {
|
||||
err_msg = `You do not have any pending crypto deposits.`;
|
||||
err_response = {
|
||||
user_flo_addr: res_obj.params[0].trader_flo_address,
|
||||
msg: err_msg
|
||||
}
|
||||
reactor.dispatchEvent('message_for_user', err_response);
|
||||
}
|
||||
res.map(async function (deposit_trade) {
|
||||
if (
|
||||
localbitcoinplusplus.master_configurations.tradableAsset1.includes(
|
||||
@ -26017,7 +26181,7 @@
|
||||
updateUserDepositsResponseObject.updatedTraderDepositObject.id,
|
||||
false,
|
||||
false
|
||||
).then(() => {
|
||||
).then((updated_res) => {
|
||||
if (
|
||||
localbitcoinplusplus.wallets.my_local_flo_address ==
|
||||
updateUserDepositsResponseObject.trader_flo_address
|
||||
@ -26025,7 +26189,7 @@
|
||||
displayBalances(
|
||||
updateUserDepositsResponseObject.trader_flo_address
|
||||
);
|
||||
notify(`INFO: Your balance is updated.`, '', true, true, true);
|
||||
notify(`INFO: ${updated_res.depositing_amount} ${updated_res.product} is added in your ${updated_res.product} balance.`, '', true, true, true);
|
||||
}
|
||||
return true;
|
||||
})
|
||||
@ -27770,7 +27934,7 @@
|
||||
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
|
||||
true,
|
||||
false
|
||||
).then(() => {
|
||||
).then((updated_res) => {
|
||||
if (
|
||||
localbitcoinplusplus.wallets.my_local_flo_address ==
|
||||
updateUserCryptoBalanceResponseObject.trader_flo_address
|
||||
@ -27778,10 +27942,10 @@
|
||||
displayBalances(
|
||||
updateUserCryptoBalanceResponseObject.trader_flo_address
|
||||
);
|
||||
notify(`INFO: Your balance is updated.`, '', true, true, true);
|
||||
notify(`INFO: ${updated_res.depositing_amount} ${updated_res.product} is added in your ${updated_res.product} balance.`, '', true, true, true);
|
||||
}
|
||||
return true;
|
||||
})
|
||||
});
|
||||
} else {
|
||||
notify(
|
||||
`WARNING: Failed to update balance in your DB. Please refresh.`
|
||||
@ -28796,7 +28960,7 @@
|
||||
};
|
||||
|
||||
var db;
|
||||
const request = window.indexedDB.open(DBName, 2);
|
||||
const request = window.indexedDB.open(DBName, 3);
|
||||
|
||||
request.onerror = function (event) {
|
||||
//https://stackoverflow.com/questions/13972385/invalidstateerror-while-opening-indexeddb-in-firefox
|
||||
@ -29049,10 +29213,26 @@
|
||||
unique: false
|
||||
});
|
||||
}
|
||||
if (!db.objectStoreNames.contains("my_crypto_deposits")) {
|
||||
var objectStore = db.createObjectStore("my_crypto_deposits", {
|
||||
keyPath: "id"
|
||||
});
|
||||
objectStore.createIndex("depositing_address", "depositing_address", {
|
||||
unique: false
|
||||
});
|
||||
}
|
||||
if (!db.objectStoreNames.contains("my_crypto_withdrawals")) {
|
||||
var objectStore = db.createObjectStore("my_crypto_withdrawals", {
|
||||
keyPath: "id"
|
||||
});
|
||||
objectStore.createIndex("crypto_withdrawal_txid", "crypto_withdrawal_txid", {
|
||||
unique: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const exception_datastores = ['localbitcoinUser', 'ipTable', 'kBucketStore', 'myClosestSupernodes',
|
||||
'my_supernode_private_key_chunks'];
|
||||
'my_supernode_private_key_chunks', 'my_crypto_withdrawals'];
|
||||
|
||||
function signDBData(objectdata) {
|
||||
try {
|
||||
@ -30514,7 +30694,7 @@
|
||||
// SECTION: Balances Functions
|
||||
const displayBalances = flo_id => {
|
||||
if (typeof flo_id !== "string") return;
|
||||
showMessage(`Loading your balances.`);
|
||||
showMessage(`Loading your balance.`);
|
||||
const user_crypto_balances = readDBbyIndex(
|
||||
"crypto_balances",
|
||||
"trader_flo_address",
|
||||
@ -30531,7 +30711,7 @@
|
||||
let all_balances = balances[0].concat(balances[1]);
|
||||
if (all_balances.length == 0) {
|
||||
showMessage(`You don't have any balance. You can deposit crypto or fiat
|
||||
asset from DEPOSIT dection below.`);
|
||||
asset from DEPOSIT section below.`);
|
||||
}
|
||||
|
||||
for (const user_balance_data of all_balances) {
|
||||
@ -30549,10 +30729,14 @@
|
||||
|
||||
case "FLO":
|
||||
document.getElementById('user_flo_bal').innerText = helper_functions.truncateDecimals(value);
|
||||
helper_functions.chainAjaxRequest("BALANCE_BY_ADDRESS", localbitcoinplusplus.server.flo_mainnet, [flo_id])
|
||||
.then(val=>document.getElementById('user_flo_addr_bal').innerText = helper_functions.truncateDecimals(val));
|
||||
break;
|
||||
|
||||
case "FLO_TEST":
|
||||
document.getElementById('user_flo_bal').innerText = helper_functions.truncateDecimals(value);
|
||||
helper_functions.chainAjaxRequest("BALANCE_BY_ADDRESS", localbitcoinplusplus.server.flo_testnet, [flo_id])
|
||||
.then(val=>document.getElementById('user_flo_addr_bal').innerText = helper_functions.truncateDecimals(val));
|
||||
break;
|
||||
|
||||
case "INR":
|
||||
@ -30821,6 +31005,7 @@
|
||||
} else {
|
||||
cnf_crypto_deposit();
|
||||
notify(`Deposit txid ${resp_txid} confirmed.`, '', true);
|
||||
display_crypto_deposits_status();
|
||||
}
|
||||
|
||||
}
|
||||
@ -30902,6 +31087,95 @@
|
||||
|
||||
}
|
||||
|
||||
async function display_crypto_deposits_status() {
|
||||
try {
|
||||
const my_crypto_deposits = await readAllDB('deposit');
|
||||
let my_crypto_deposits_div = document.getElementById('my_crypto_deposits_div');
|
||||
my_crypto_deposits_div.innerHTML = '';
|
||||
let explorer;
|
||||
for (const my_deposit of my_crypto_deposits) {
|
||||
console.log(my_deposit.btc_address);
|
||||
switch (my_deposit.product) {
|
||||
case "BTC":
|
||||
explorer = localbitcoinplusplus.server.btc_mainnet;
|
||||
break;
|
||||
case "BTC_TEST":
|
||||
explorer = localbitcoinplusplus.server.btc_testnet;
|
||||
break;
|
||||
case "FLO":
|
||||
explorer = localbitcoinplusplus.server.flo_mainnet;
|
||||
break;
|
||||
case "FLO_TEST":
|
||||
explorer = localbitcoinplusplus.server.flo_testnet;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
helper_functions.chainAjaxRequest("BALANCE_BY_ADDRESS", explorer, [my_deposit.btc_address])
|
||||
.then(balance=>{
|
||||
let txt = '';
|
||||
if (!isNaN(balance) && parseFloat(balance) > 0) {
|
||||
console.log(my_deposit.btc_address, balance);
|
||||
txt = `Deposit of ${balance} ${my_deposit.product} to ${my_deposit.btc_address} ${my_deposit.product} address at time ${helper_functions.getFormattedDate(my_deposit.timestamp)} has been confirmed.`;
|
||||
} else {
|
||||
console.log(my_deposit.btc_address, 0);
|
||||
txt = `Deposit of ${balance} ${my_deposit.product} to ${my_deposit.btc_address} ${my_deposit.product} address at time ${helper_functions.getFormattedDate(my_deposit.timestamp)} is pending.`;
|
||||
}
|
||||
my_crypto_deposits_div.insertAdjacentHTML('beforeend', `<p>${txt}</p><br>`);
|
||||
});
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async function display_crypto_withdrawals_status() {
|
||||
try {
|
||||
const my_crypto_withdrawals = await readAllDB('my_crypto_withdrawals');
|
||||
let my_crypto_withdraws_div = document.getElementById('my_crypto_withdraws_div');
|
||||
my_crypto_withdraws_div.innerHTML = '';
|
||||
let explorer;
|
||||
for (const my_withdrawals of my_crypto_withdrawals) {
|
||||
console.log(my_withdrawals);
|
||||
console.log(my_withdrawals.crypto_withdrawal_txid);
|
||||
|
||||
switch (my_withdrawals.product) {
|
||||
case "BTC":
|
||||
explorer = localbitcoinplusplus.server.btc_mainnet;
|
||||
break;
|
||||
case "BTC_TEST":
|
||||
explorer = localbitcoinplusplus.server.btc_testnet;
|
||||
break;
|
||||
case "FLO":
|
||||
explorer = localbitcoinplusplus.server.flo_mainnet;
|
||||
break;
|
||||
case "FLO_TEST":
|
||||
explorer = localbitcoinplusplus.server.flo_testnet;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
let txt = ``;
|
||||
helper_functions.chainAjaxRequest("TX_DETAIL", explorer, [my_withdrawals.crypto_withdrawal_txid])
|
||||
.then(my_withdraw=>{
|
||||
console.log(my_withdraw); // confirmations, txid
|
||||
if(typeof my_withdraw !=="object" || typeof my_withdraw.txid !=="string") return false;
|
||||
if(my_withdraw.confirmations<1) {
|
||||
txt = `FLO withdrawal is requested with transaction ID ${my_withdraw.txid} at time ${helper_functions.getFormattedDate(my_withdraw.blocktime)} with amount ${my_withdraw.valueOut}.`;
|
||||
} else {
|
||||
txt = `FLO withdrawal is confirmed with transaction ID ${my_withdraw.txid} at time ${helper_functions.getFormattedDate(my_withdraw.blocktime)} with amount ${my_withdraw.valueOut}.`;
|
||||
}
|
||||
my_crypto_withdraws_div.insertAdjacentHTML('beforeend',`<p>${txt}</p>`);
|
||||
});
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
notify('Failed to display some withdraw transaction details.', 'error')
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
// SECTION: Deposit/Withdraw Cash
|
||||
function depositWithdrawFiat(userFLOaddress = "") {
|
||||
const RM_TRADE = new localbitcoinplusplus.trade();
|
||||
@ -31171,13 +31445,29 @@
|
||||
typeof localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY !==
|
||||
"string"
|
||||
)
|
||||
return false;
|
||||
{
|
||||
err_msg = `validateDepositedBTCBalance failed: Invalid private or public key.`;
|
||||
err_response = {
|
||||
user_flo_addr: res_obj.params[0].trader_flo_address,
|
||||
msg: err_msg
|
||||
}
|
||||
reactor.dispatchEvent('message_for_user', err_response);
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
!localbitcoinplusplus.master_configurations.tradableAsset1.includes(
|
||||
trader_deposits.product
|
||||
)
|
||||
)
|
||||
return false;
|
||||
{
|
||||
err_msg = `validateDepositedBTCBalance failed: Invalid asset.`;
|
||||
err_response = {
|
||||
user_flo_addr: res_obj.params[0].trader_flo_address,
|
||||
msg: err_msg
|
||||
}
|
||||
reactor.dispatchEvent('message_for_user', err_response);
|
||||
return false;
|
||||
}
|
||||
let _readDB = readDB;
|
||||
let _readDBbyIndex = readDBbyIndex;
|
||||
let _updateinDB = updateinDB;
|
||||
@ -31408,8 +31698,8 @@
|
||||
}
|
||||
rawFile.send(null);
|
||||
}
|
||||
// }
|
||||
// return BitBang();
|
||||
//}
|
||||
// return BitBang();
|
||||
//})()
|
||||
</script>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user