fixed error in crypto deposit send tx function

This commit is contained in:
Abhishek Sinha 2020-05-17 20:17:16 +05:30
parent 03713e8561
commit 81e49df964

View File

@ -10,7 +10,7 @@
<div id="event_log" class="hide"> <div id="event_log" class="hide">
<header class="flex"> <header class="flex">
<h3>Event Log</h3> <h3>Event Log</h3>
<svg viewBox="0 0 64 64" onclick="closeMessage()"> <svg viewBox="0 0 64 64" id="closeMessageBtn">
<title>Close</title> <title>Close</title>
<line x1="0" y1="0" x2="64" y2="64"/> <line x1="0" y1="0" x2="64" y2="64"/>
<line class="a" x1="64" y1="0" x2="0" y2="64"/> <line class="a" x1="64" y1="0" x2="0" y2="64"/>
@ -31,7 +31,7 @@
<div id="confirmation" class="popup"> <div id="confirmation" class="popup">
<p></p> <p></p>
<div> <div>
<button class="hover" onclick="hidePopup()">Cancel</button> <button class="hover hidePopupClass">Cancel</button>
<button class="hover">Ok</button> <button class="hover">Ok</button>
</div> </div>
</div> </div>
@ -124,7 +124,7 @@
</svg> </svg>
</div> </div>
</label> </label>
<svg class="icon" viewBox="0 0 64 64" onclick="displayMessages()"> <svg class="icon" viewBox="0 0 64 64" id="displayMessagesBtn">
<title>Console</title> <title>Console</title>
<rect x="0" y="0" width="64" height="64" rx="6"/> <rect x="0" y="0" width="64" height="64" rx="6"/>
<polyline points="14.6 16.3 30.3 32 14.6 47.7"/> <polyline points="14.6 16.3 30.3 32 14.6 47.7"/>
@ -132,7 +132,7 @@
</svg> </svg>
<div id="notifiation" class="dropdown"> <div id="notifiation" class="dropdown">
<span> <span>
<svg class="icon" viewBox="0 0 50.49 64" onclick="showNotifications()"> <svg class="icon" viewBox="0 0 50.49 64" id="showNotificationsBtn">
<title>Notifications</title> <title>Notifications</title>
<path d="M51.47,53.09A3.9,3.9,0,0,0,56,50l.42-2.3a2.56,2.56,0,0,0-1-2.44c-3.18-2.56-3.58-7.27-3-10.54.74-4.07,1.7-9.3,1.72-9.46,2-11.08-1.62-17.7-7.6-21.52A18.74,18.74,0,0,0,32.75,1.17C25.81,2.61,20.05,7.51,18,18.6c0,.16-1,5.38-1.74,9.45-.6,3.27-2.64,7.54-6.52,8.81A2.54,2.54,0,0,0,8,38.8l-.42,2.3a3.91,3.91,0,0,0,3.14,4.54Z" transform="translate(-6.75 0)"/> <path d="M51.47,53.09A3.9,3.9,0,0,0,56,50l.42-2.3a2.56,2.56,0,0,0-1-2.44c-3.18-2.56-3.58-7.27-3-10.54.74-4.07,1.7-9.3,1.72-9.46,2-11.08-1.62-17.7-7.6-21.52A18.74,18.74,0,0,0,32.75,1.17C25.81,2.61,20.05,7.51,18,18.6c0,.16-1,5.38-1.74,9.45-.6,3.27-2.64,7.54-6.52,8.81A2.54,2.54,0,0,0,8,38.8l-.42,2.3a3.91,3.91,0,0,0,3.14,4.54Z" transform="translate(-6.75 0)"/>
<path d="M25.23,53.38c0,.18,0,.36,0,.54A9.3,9.3,0,0,0,43.39,56.7Z" transform="translate(-6.75 0)"/> <path d="M25.23,53.38c0,.18,0,.36,0,.54A9.3,9.3,0,0,0,43.39,56.7Z" transform="translate(-6.75 0)"/>
@ -142,7 +142,7 @@
<div id="notification_panel" class="dropdown-content hide"> <div id="notification_panel" class="dropdown-content hide">
<header> <header>
<h3>Notifications</h3> <h3>Notifications</h3>
<h5 id="clear_all_notifications" onclick="clearAllNotifications()">Clear all</h5> <h5 id="clearAllNotificationsBtn">Clear all</h5>
</header> </header>
<div id="notification_container"></div> <div id="notification_container"></div>
<h4 class="empty-state">Nothing to see here</h4> <h4 class="empty-state">Nothing to see here</h4>
@ -153,9 +153,9 @@
<div id="left" class="bottom-margin grid"> <div id="left" class="bottom-margin grid">
<div id="exchange" class="card"> <div id="exchange" class="card">
<ul id="switcher_header" class="grid"> <ul id="switcher_header" class="grid">
<li tabindex="0" onclick="showSection(this, 'asset_section')" class="active exchange-btn" title="Buy or sell crypto assets">Trade</li> <li tabindex="0" id="show_asset_section" class="active exchange-btn" title="Buy or sell crypto assets">Trade</li>
<li tabindex="0" onclick="showSection(this, 'crypto_section')" class="exchange-btn" title="Deposit or withdraw crypto assets">Crypto</li> <li tabindex="0" id="show_crypto_section" class="exchange-btn" title="Deposit or withdraw crypto assets">Crypto</li>
<li tabindex="0" onclick="showSection(this, 'cash_section')" class="exchange-btn" title="Deposit or withdraw cash">Cash</li> <li tabindex="0" id="show_cash_section" class="exchange-btn" title="Deposit or withdraw cash">Cash</li>
</ul> </ul>
<div id="switcher_body"> <div id="switcher_body">
<div id="asset_section" class="exchange-section grid"> <div id="asset_section" class="exchange-section grid">
@ -407,7 +407,7 @@
<div class="popup-container hide"> <div class="popup-container hide">
<div id="buy_crypto_popup" class="popup"> <div id="buy_crypto_popup" class="popup">
<div class="container-header bottom-margin"> <div class="container-header bottom-margin">
<svg class="back-arrow" onclick="hidePopup()" viewBox="0 0 31.24 56.83"> <svg class="back-arrow hidePopupClass" viewBox="0 0 31.24 56.83">
<title>Close this popup</title> <title>Close this popup</title>
<polyline points="29.83,1.41 2.83,28.41 29.83,55.41 "/> <polyline points="29.83,1.41 2.83,28.41 29.83,55.41 "/>
</svg> </svg>
@ -430,7 +430,7 @@
<div class="popup-container hide"> <div class="popup-container hide">
<div id="sell_crypto_popup" class="popup"> <div id="sell_crypto_popup" class="popup">
<div class="container-header bottom-margin"> <div class="container-header bottom-margin">
<svg class="back-arrow" onclick="hidePopup()" viewBox="0 0 31.24 56.83"> <svg class="back-arrow hidePopupClass" viewBox="0 0 31.24 56.83">
<title>Close this popup</title> <title>Close this popup</title>
<polyline points="29.83,1.41 2.83,28.41 29.83,55.41 "/> <polyline points="29.83,1.41 2.83,28.41 29.83,55.41 "/>
</svg> </svg>
@ -454,12 +454,12 @@
<div class="popup-container hide"> <div class="popup-container hide">
<div id="send_crypto_popup" class="popup"> <div id="send_crypto_popup" class="popup">
<div class="container-header bottom-margin"> <div class="container-header bottom-margin">
<svg class="back-arrow" onclick="hidePopup()" viewBox="0 0 31.24 56.83"> <svg class="back-arrow hidePopupClass" viewBox="0 0 31.24 56.83">
<title>Close this popup</title> <title>Close this popup</title>
<polyline points="29.83,1.41 2.83,28.41 29.83,55.41 "/> <polyline points="29.83,1.41 2.83,28.41 29.83,55.41 "/>
</svg> </svg>
<h3>Send Crypto</h3> <h3>Send Crypto</h3>
<div class="action" onclick="sendCrypto(this)"> <div class="action" id="sendCryptoBtn">
<button class="btn" type="submit" disabled> <button class="btn" type="submit" disabled>
Send Send
</button> </button>
@ -527,7 +527,7 @@
<h5> Send crypto to address</h5> <h5> Send crypto to address</h5>
<div class="grid grid-2 copy-row"> <div class="grid grid-2 copy-row">
<h3 class="breakable" id="server_deposit_crypto_addr">Waiting for Server's response...</h3> <h3 class="breakable" id="server_deposit_crypto_addr">Waiting for Server's response...</h3>
<svg class="copy-icon" onclick="copyToClipboard(this.parentNode, '0')" viewBox="0 0 54 64"> <svg class="copy-icon" id="copyToClipboardBtn" viewBox="0 0 54 64">
<title>Copy</title> <title>Copy</title>
<path d="M53,0H22.14a6,6,0,0,0-6,6v5H11a6,6,0,0,0-6,6V58a6,6,0,0,0,6,6H41.86a6,6,0,0,0,6-6V53H53a6,6,0,0,0,6-6V6A6,6,0,0,0,53,0ZM43.89,58a2,2,0,0,1-2,2H11a2,2,0,0,1-2-2V17.06a2,2,0,0,1,2-2H41.86a2,2,0,0,1,2,2ZM55,46.94a2,2,0,0,1-2,2H47.89V17.06a6,6,0,0,0-6-6H20.11V6a2,2,0,0,1,2-2H53a2,2,0,0,1,2,2Z" transform="translate(-5)"/> <path d="M53,0H22.14a6,6,0,0,0-6,6v5H11a6,6,0,0,0-6,6V58a6,6,0,0,0,6,6H41.86a6,6,0,0,0,6-6V53H53a6,6,0,0,0,6-6V6A6,6,0,0,0,53,0ZM43.89,58a2,2,0,0,1-2,2H11a2,2,0,0,1-2-2V17.06a2,2,0,0,1,2-2H41.86a2,2,0,0,1,2,2ZM55,46.94a2,2,0,0,1-2,2H47.89V17.06a6,6,0,0,0-6-6H20.11V6a2,2,0,0,1,2-2H53a2,2,0,0,1,2,2Z" transform="translate(-5)"/>
</svg> </svg>
@ -549,7 +549,7 @@
<div class="popup-container hide"> <div class="popup-container hide">
<div id="withdraw_crypto_popup" class="popup"> <div id="withdraw_crypto_popup" class="popup">
<div class="container-header bottom-margin"> <div class="container-header bottom-margin">
<svg class="back-arrow" onclick="hidePopup()" viewBox="0 0 31.24 56.83"> <svg class="back-arrow hidePopupClass" viewBox="0 0 31.24 56.83">
<title>Close this popup</title> <title>Close this popup</title>
<polyline points="29.83,1.41 2.83,28.41 29.83,55.41 "/> <polyline points="29.83,1.41 2.83,28.41 29.83,55.41 "/>
</svg> </svg>
@ -579,7 +579,7 @@
<div class="popup-container hide"> <div class="popup-container hide">
<div id="deposit_cash_popup" class="popup"> <div id="deposit_cash_popup" class="popup">
<div class="container-header bottom-margin"> <div class="container-header bottom-margin">
<svg class="back-arrow" onclick="hidePopup()" viewBox="0 0 31.24 56.83"> <svg class="back-arrow hidePopupClass" viewBox="0 0 31.24 56.83">
<title>Close this popup</title> <title>Close this popup</title>
<polyline points="29.83,1.41 2.83,28.41 29.83,55.41 "/> <polyline points="29.83,1.41 2.83,28.41 29.83,55.41 "/>
</svg> </svg>
@ -607,7 +607,7 @@
<div class="popup-container hide"> <div class="popup-container hide">
<div id="withdraw_cash_popup" class="popup"> <div id="withdraw_cash_popup" class="popup">
<div class="container-header bottom-margin"> <div class="container-header bottom-margin">
<svg class="back-arrow" onclick="hidePopup()" viewBox="0 0 31.24 56.83"> <svg class="back-arrow hidePopupClass" viewBox="0 0 31.24 56.83">
<title>Close this popup</title> <title>Close this popup</title>
<polyline points="29.83,1.41 2.83,28.41 29.83,55.41 "/> <polyline points="29.83,1.41 2.83,28.41 29.83,55.41 "/>
</svg> </svg>
@ -11575,6 +11575,7 @@
(function() { (function() {
let localbitcoinplusplus = {}; let localbitcoinplusplus = {};
function BitBang() { function BitBang() {
//SECTION: INITIALIZATION //SECTION: INITIALIZATION
localbitcoinplusplus = { localbitcoinplusplus = {
wallets: {}, wallets: {},
@ -12182,14 +12183,20 @@
#!#tradableAsset1=BTC,FLO,BTC_TEST,FLO_TEST#!#tradableAsset2=INR,USD, #!#tradableAsset1=BTC,FLO,BTC_TEST,FLO_TEST#!#tradableAsset2=INR,USD,
#!#validTradingAmount=10,50,100,#!#btcTradeMargin=5000 #!#validTradingAmount=10,50,100,#!#btcTradeMargin=5000
#!#MaxBackups=1 #!#MaxBackups=1
#!#waitTime={"normaldelay":180000, "exportdelay":300000, "syncdelay":600000, "hugedelay":1200000} #!#waitTime={"normaldelay":60000, "exportdelay":60000, "syncdelay":60000, "hugedelay":60000}
#!#ordersLife={"trade":300000, "cryptoDeposit":900000, "cryptoWithdraw":300000, "cashDeposit":900000, "cashWithdraw":900000} #!#ordersLife={"trade":300000, "cryptoDeposit":900000, "cryptoWithdraw":300000, "cashDeposit":900000, "cashWithdraw":900000}
#!#miners_fee={"btc":0.0005, "flo":0.001} #!#miners_fee={"btc":0.0005, "flo":0.001}
#!#supernodesPubKeys=026FCC6CFF6EB3A39E54BEB6E13FC2F02C3A93F4767AA80E49E7E876443F95AE5F,0349B08AA1ABDCFFB6D78CD7C949665AD2FF065EA02B3C6C47A5E9592C9A1C6BCB #!#supernodesPubKeys=026FCC6CFF6EB3A39E54BEB6E13FC2F02C3A93F4767AA80E49E7E876443F95AE5F,0349B08AA1ABDCFFB6D78CD7C949665AD2FF065EA02B3C6C47A5E9592C9A1C6BCB,
039B4AA00DBFC0A6631DE6DA83526611A0E6B857D3579DF840BBDEAE8B6898E3B6,0315C3A20FE7096CC2E0F81A80D5F1A687B8F9EFA65242A0B0881E1BA3EE7D7D53,
03C8E3836C9A77E2AF03D4265D034BA85732738919708EAF6A16382195AE796EDF,03F7493F11B8E44B9798CD434D20FBE7FA34B9779D144984889D11A17C56A18742
#!#specialNodes=02348523EB008BD37BF297AA360757062CB9D153C371EE727349A02F0B67910613,03C38E6523D6A2C45E00E60DC072E4D4340007F8A0026F134DCBBC670E4C44D31C #!#specialNodes=02348523EB008BD37BF297AA360757062CB9D153C371EE727349A02F0B67910613,03C38E6523D6A2C45E00E60DC072E4D4340007F8A0026F134DCBBC670E4C44D31C
#!#cashiers={"032871A74D2DDA9D0DE7135F58B5BD2D7F679D2CCA20EA7909466D1A6912DF4022":{"upi":"johnDoe@upi", "currencies":["INR"], "is_live":false}, #!#cashiers={"032871A74D2DDA9D0DE7135F58B5BD2D7F679D2CCA20EA7909466D1A6912DF4022":{"upi":"johnDoe@upi", "currencies":["INR"], "is_live":false},
"03DB4A12EB543B293DDBB0CE314C46C36D6761294AFBB7264A6D78F710FFD97CF0":{"upi":"janeDoe@upi", "currencies":["INR", "USD"], "is_live":false}} "03DB4A12EB543B293DDBB0CE314C46C36D6761294AFBB7264A6D78F710FFD97CF0":{"upi":"janeDoe@upi", "currencies":["INR", "USD"], "is_live":false}}
#!#ShamirsMaxShares=8#!#supernodeSeeds={ #!#ShamirsMaxShares=8#!#supernodeSeeds={
"ranchimall1":{"ip":"127.0.0.1:9111","kbucketId":"oZxHcbSf1JC8t5GjutopWYXs7C6Fe9p7ps"},
"ranchimall2":{"ip":"127.0.0.1:9112","kbucketId":"oTWjPupy3Z7uMdPcu5uXd521HBkcsLuSuM"},
"ranchimall3":{"ip":"127.0.0.1:9113","kbucketId":"odYA6KagmbokSh9GY7yAfeTUZRtZLwecY1"},
"ranchimall4":{"ip":"127.0.0.1:9114","kbucketId":"oJosrve9dBv2Hj2bfncxv2oEpTysg3Wejv"},
"ranchimall5":{"ip":"127.0.0.1:9115","kbucketId":"oMhv5sAzqg77sYHxmUGZWKRrVo4P4JQduS"}, "ranchimall5":{"ip":"127.0.0.1:9115","kbucketId":"oMhv5sAzqg77sYHxmUGZWKRrVo4P4JQduS"},
"ranchimall6":{"ip":"127.0.0.1:9116","kbucketId":"oV1wCeWca3VawbBTfUGKA7Vd368PATnKAx"}}`; "ranchimall6":{"ip":"127.0.0.1:9116","kbucketId":"oV1wCeWca3VawbBTfUGKA7Vd368PATnKAx"}}`;
///return callback(localStorage.lppconf); ///return callback(localStorage.lppconf);
@ -20333,7 +20340,7 @@
} }
Promise.all(utxo_list_req).then(all_utxos => { Promise.all(utxo_list_req).then(all_utxos => {
if (all_utxos.length > 0) { if (all_utxos.length>0) {
try { try {
const utxo_list = [].concat(...all_utxos); const utxo_list = [].concat(...all_utxos);
utxo_list.sort((a, b) => b.confirmations - a.confirmations); utxo_list.sort((a, b) => b.confirmations - a.confirmations);
@ -21423,6 +21430,13 @@
} }
} }
var hidePopupClass = document.getElementsByClassName("hidePopupClass");
Array.from(hidePopupClass).forEach(function(element) {
element.addEventListener("click", hidePopup);
});
function setAttributes(el, attrs) { function setAttributes(el, attrs) {
for (var key in attrs) { for (var key in attrs) {
el.setAttribute(key, attrs[key]); el.setAttribute(key, attrs[key]);
@ -21491,6 +21505,7 @@
}, 6000) }, 6000)
} }
const showNotificationsBtn = document.getElementById('showNotificationsBtn');
function showNotifications() { function showNotifications() {
let notificationPanel = document.getElementById('notification_panel'); let notificationPanel = document.getElementById('notification_panel');
currentCount = 0; currentCount = 0;
@ -21501,10 +21516,13 @@
notificationPanel.classList.add('hide') notificationPanel.classList.add('hide')
} }
} }
showNotificationsBtn.addEventListener('click', showNotifications);
const clearAllNotificationsBtn = document.getElementById('clearAllNotificationsBtn');
function clearAllNotifications() { function clearAllNotifications() {
document.getElementById('notification_container').innerHTML = ''; document.getElementById('notification_container').innerHTML = '';
} }
clearAllNotificationsBtn.addEventListener('click', clearAllNotifications);
// displays a popup for asking permission. Use this instead of JS confirm // displays a popup for asking permission. Use this instead of JS confirm
let askConfirmation = function (message) { let askConfirmation = function (message) {
@ -21548,7 +21566,10 @@
} }
} }
function copyToClipboard(parent, childIndex) { const copyToClipboardBtn = document.getElementById('copyToClipboardBtn');
function copyToClipboard() {
let parent = this.parentNode;
let childIndex = '0';
let input = document.createElement('textarea'), let input = document.createElement('textarea'),
toast = document.getElementById('textCopied'); toast = document.getElementById('textCopied');
input.setAttribute('readonly', ''); input.setAttribute('readonly', '');
@ -21563,11 +21584,32 @@
toast.classList.add('hide'); toast.classList.add('hide');
}, 2000) }, 2000)
} }
copyToClipboardBtn.addEventListener('click', copyToClipboard);
let allExchangeSections = document.querySelectorAll('.exchange-section'), let allExchangeSections = document.querySelectorAll('.exchange-section'),
allExchangeBtns = document.querySelectorAll('.exchange-btn'); allExchangeBtns = document.querySelectorAll('.exchange-btn');
allExchangeBtns.forEach((btn) => {
switch (btn.id) {
case "show_asset_section":
btn.addEventListener("click", function() {
showSection(this, 'asset_section');
});
break;
case "show_crypto_section":
btn.addEventListener("click", function() {
showSection(this, 'crypto_section');
});
break
case "show_cash_section":
btn.addEventListener("click", function() {
showSection(this, 'cash_section');
});
break;
}
})
function showSection(thisBtn, elem) { function showSection(thisBtn, elem) {
let element = document.getElementById(elem) let element = document.getElementById(elem)
allExchangeSections.forEach((section) => { allExchangeSections.forEach((section) => {
@ -21709,7 +21751,9 @@
} }
} }
function sendCrypto(btn) { const sendCryptoBtn = document.getElementById('sendCryptoBtn');
function sendCrypto() {
let btn = this;
let parentPopup = btn.closest('.popup'), let parentPopup = btn.closest('.popup'),
send_crypto_type = document.querySelector("input[name='crypto']:checked").value, send_crypto_type = document.querySelector("input[name='crypto']:checked").value,
utxo_addr_input = parentPopup.querySelector("input[name='senderFloId']").value, utxo_addr_input = parentPopup.querySelector("input[name='senderFloId']").value,
@ -21746,9 +21790,9 @@
} }
}); });
} }
sendCryptoBtn.addEventListener('click', sendCrypto);
//show or hide element group from a group //show or hide element group from a group
function showElement(elem, classGroup) { function showElement(elem, classGroup) {
let allGroups = document.querySelectorAll(`.${classGroup}`), let allGroups = document.querySelectorAll(`.${classGroup}`),
thisElement = elem; thisElement = elem;
@ -21763,6 +21807,7 @@
// new displayMeesage and closeMessage functions. please remove old functions from script // new displayMeesage and closeMessage functions. please remove old functions from script
let eventLog = document.getElementById("event_log"); let eventLog = document.getElementById("event_log");
const displayMessagesBtn = document.getElementById('displayMessagesBtn');
function displayMessages() { function displayMessages() {
eventLog.classList.remove('hide') eventLog.classList.remove('hide')
eventLog.classList.add('no-transformations') eventLog.classList.add('no-transformations')
@ -21771,11 +21816,14 @@
closeMessage() closeMessage()
} }
} }
displayMessagesBtn.addEventListener('click', displayMessages);
function closeMessage() { function closeMessage() {
eventLog.classList.add('hide') eventLog.classList.add('hide')
eventLog.classList.remove('no-transformations') eventLog.classList.remove('no-transformations')
} }
const closeMessageBtn = document.getElementById('closeMessageBtn');
closeMessageBtn.addEventListener('click', closeMessage);
//Show tips when loading screen is shown //Show tips when loading screen is shown
let tips = [ let tips = [
@ -22451,8 +22499,8 @@
.master_configurations.supernodesPubKeys.length; .master_configurations.supernodesPubKeys.length;
const old_sk = supernodeKBucket.toArray(); const old_sk = supernodeKBucket.toArray();
const old_sk_id = sk.map(m=>m.data.id); const old_sk_id = old_sk.map(m=>m.data.id);
let old_idx = sk_id.indexOf(localbitcoinplusplus.wallets.my_local_flo_address); let old_idx = old_sk_id.indexOf(localbitcoinplusplus.wallets.my_local_flo_address);
if(old_idx<0) throw new Error('Negative index in Supernode Kbucket array.'); if(old_idx<0) throw new Error('Negative index in Supernode Kbucket array.');
limit_function_calls(async function () { limit_function_calls(async function () {
@ -29925,14 +29973,14 @@
sendersFloId = parentPopup.querySelector("input[name='senderFloId']").value, sendersFloId = parentPopup.querySelector("input[name='senderFloId']").value,
sendersPrivKey = parentPopup.querySelector("input[name='senderPrivateKey']").value, sendersPrivKey = parentPopup.querySelector("input[name='senderPrivateKey']").value,
asset_type = document.querySelector("input[name='crypto']:checked").value; asset_type = document.querySelector("input[name='crypto']:checked").value;
let tradeAmountSelect = document.getElementById('trade_amount_select');
let tradeAmount = helper_functions.truncateDecimals(tradeAmountSelect.value);
if (depositCryptoButtonClicked === 1) { if (depositCryptoButtonClicked === 1) {
document.getElementById('server_deposit_crypto_addr').textContent = `Waiting for servers response...` document.getElementById('server_deposit_crypto_addr').textContent = `Waiting for servers response...`
showElement('confirm_deposit_btn_section', 'deposit-crypto-group'); showElement('confirm_deposit_btn_section', 'deposit-crypto-group');
//first time clicked //first time clicked
depositCryptoButton.firstElementChild.textContent = 'Send from here' depositCryptoButton.firstElementChild.textContent = 'Send from here'
let parentPopup = this.closest('.popup'), let parentPopup = this.closest('.popup');
tradeAmountSelect = document.getElementById('trade_amount_select');
let tradeAmount = helper_functions.truncateDecimals(tradeAmountSelect.value);
let fiatCurrency = localStorage.getItem('defaultCurrency'); let fiatCurrency = localStorage.getItem('defaultCurrency');
if ( if (
@ -29993,7 +30041,7 @@
asset_type, asset_type,
[sendersPrivKey], [sendersPrivKey],
receiver_address, receiver_address,
0.01, tradeAmount,
sendersFloId, sendersFloId,
function (crypto_sent_resp) { function (crypto_sent_resp) {
(async function validateDepositedCrypto() { (async function validateDepositedCrypto() {
@ -30009,6 +30057,10 @@
let txdata = ''; let txdata = '';
notify(`Waiting for deposit txid ${resp_txid} for at least 3 confirmations.
Please do not close or refresh the window until the process completes.`);
await localbitcoinplusplus.actions.delay(60000);
if (asset_type === 'BTC') { if (asset_type === 'BTC') {
txdata = await helper_functions txdata = await helper_functions
.ajaxGet(`${localbitcoinplusplus.server.btc_mainnet}/api/tx/${resp_txid}`); .ajaxGet(`${localbitcoinplusplus.server.btc_mainnet}/api/tx/${resp_txid}`);
@ -30022,11 +30074,10 @@
txdata = await helper_functions txdata = await helper_functions
.ajaxGet(`${localbitcoinplusplus.server.flo_testnet}/api/tx/${resp_txid}`); .ajaxGet(`${localbitcoinplusplus.server.flo_testnet}/api/tx/${resp_txid}`);
} }
notify(`Waiting for deposit txid ${resp_txid} for at least 3 confirmations.
Please do not close or refresh the window until the process completes.`);
await localbitcoinplusplus.actions.delay(60000); if (typeof txdata !== "object"
if (typeof txdata.txid !== "string" || typeof txdata == "null"
|| typeof txdata.txid !== "string"
|| typeof txdata.confirmations !== "number" || typeof txdata.confirmations !== "number"
|| txdata.confirmations < 3) { || txdata.confirmations < 3) {
notify(`Waiting for deposit txid ${resp_txid} for at least 3 confirmations. notify(`Waiting for deposit txid ${resp_txid} for at least 3 confirmations.
@ -30050,6 +30101,9 @@
// NOTIFY DEPOSITED CRYPTO CONFIRMATION // NOTIFY DEPOSITED CRYPTO CONFIRMATION
const refresh_crypto_status_btn = document.getElementById("cnf_crypto_deposit"); const refresh_crypto_status_btn = document.getElementById("cnf_crypto_deposit");
refresh_crypto_status_btn.addEventListener("click", cnf_crypto_deposit); refresh_crypto_status_btn.addEventListener("click", cnf_crypto_deposit);
const second_confirm_deposit_btn = document.getElementById('second-confirm_deposit_btn');
second_confirm_deposit_btn.addEventListener("click", cnf_crypto_deposit);
}; };
const withdrawCrypto = function (userFLOaddress = "") { const withdrawCrypto = function (userFLOaddress = "") {
@ -30063,13 +30117,13 @@
get_crypto_svg_selection_html('withdraw_assets_type', withdraw_crypto_div); get_crypto_svg_selection_html('withdraw_assets_type', withdraw_crypto_div);
withdrawCryptoButton.addEventListener("click", function (params) { withdrawCryptoButton.addEventListener("click", function (params) {
disableBtn('withdrawCryptoButton'); this.getElementsByTagName('button')[0].disabled = true;
let parentPopup = this.closest('.popup'); let parentPopup = this.closest('.popup');
let asset_type = document.querySelector("input[name='crypto']:checked").value; let asset_type = document.querySelector("input[name='crypto']:checked").value;
let receivinAddress = document.getElementById('withdraw_recving_addr').value let receivinAddress = document.getElementById('withdraw_recving_addr').value
let withdraw_amount_box = document.getElementById('crypto_withdraw_amount') let withdraw_amount_box = document.getElementById('crypto_withdraw_amount')
if (receivinAddress == null || receivinAddress.trim() == "") { if (receivinAddress == null || receivinAddress.trim() == "") {
enableBtn('withdrawCryptoButton') this.getElementsByTagName('button')[0].disabled = false;
err_msg = `You must specify a valid ${asset_type} address to continue.`; err_msg = `You must specify a valid ${asset_type} address to continue.`;
notify(err_msg, 'error'); notify(err_msg, 'error');
throw new Error(err_msg); throw new Error(err_msg);
@ -30375,23 +30429,31 @@
let explorer; let explorer;
let decimal = 100000000; let decimal = 100000000;
const miner_fee_obj = JSON.parse(
localbitcoinplusplus.master_configurations.miners_fee
);
let miners_fee = 0.0003;
let crypto_diff = localbitcoinplusplus.master_configurations.btcTradeMargin; let crypto_diff = localbitcoinplusplus.master_configurations.btcTradeMargin;
switch (trader_deposits.product) { switch (trader_deposits.product) {
case "BTC": case "BTC":
explorer = localbitcoinplusplus.server.btc_mainnet; explorer = localbitcoinplusplus.server.btc_mainnet;
miners_fee = miner_fee_obj.btc;
break; break;
case "BTC_TEST": case "BTC_TEST":
explorer = localbitcoinplusplus.server.btc_testnet; explorer = localbitcoinplusplus.server.btc_testnet;
miners_fee = miner_fee_obj.btc;
break; break;
case "FLO": case "FLO":
explorer = localbitcoinplusplus.server.flo_mainnet; explorer = localbitcoinplusplus.server.flo_mainnet;
crypto_diff = helper_functions.truncateDecimals(localbitcoinplusplus.master_configurations.btcTradeMargin / decimal); crypto_diff = helper_functions.truncateDecimals(localbitcoinplusplus.master_configurations.btcTradeMargin / decimal);
decimal = 1; decimal = 1;
miners_fee = miner_fee_obj.flo;
break; break;
case "FLO_TEST": case "FLO_TEST":
explorer = localbitcoinplusplus.server.flo_testnet; explorer = localbitcoinplusplus.server.flo_testnet;
crypto_diff = helper_functions.truncateDecimals(localbitcoinplusplus.master_configurations.btcTradeMargin / decimal); crypto_diff = helper_functions.truncateDecimals(localbitcoinplusplus.master_configurations.btcTradeMargin / decimal);
decimal = 1; decimal = 1;
miners_fee = miner_fee_obj.flo;
break; break;
default: default:
break; break;
@ -30405,33 +30467,34 @@
console.log(balance); console.log(balance);
/************************ Case of dispute *****************/ /************************ Case of dispute *****************/
if ( // if (
trader_deposits.depositing_amount - balance > crypto_diff // trader_deposits.depositing_amount - balance > miners_fee
) { // ) {
console.log( // console.log(
trader_deposits.depositing_amount, // trader_deposits.depositing_amount,
trader_deposits.bitcoinToBePaid, // trader_deposits.bitcoinToBePaid,
balance, // balance,
crypto_diff // miners_fee
); // );
let more_depositing_crypto_amount = helper_functions.truncateDecimals(trader_deposits.depositing_amount) - helper_functions.truncateDecimals(balance); // let more_depositing_crypto_amount = helper_functions.truncateDecimals(trader_deposits.depositing_amount) - helper_functions.truncateDecimals(balance);
err_msg = `Incomplete Crypto Deposit Error: You claimed to send ${trader_deposits.depositing_amount} ${trader_deposits.product} but // err_msg = `Incomplete Crypto Deposit Error: You claimed to send ${trader_deposits.depositing_amount} ${trader_deposits.product} but
deposited only ${balance} ${trader_deposits.product}. Please send more ${more_depositing_crypto_amount} ${trader_deposits.product} // deposited only ${balance} ${trader_deposits.product}. Please send more ${more_depositing_crypto_amount} ${trader_deposits.product}
to ${trader_deposits.btc_address}`; // to ${trader_deposits.btc_address}`;
err_response = { // err_response = {
user_flo_addr: trader_deposits.trader_flo_address, // user_flo_addr: trader_deposits.trader_flo_address,
msg: err_msg // msg: err_msg
} // }
reactor.dispatchEvent('message_for_user', err_response); // reactor.dispatchEvent('message_for_user', err_response);
console.warn("User sent less cryptos"); // console.warn("User sent less cryptos");
return false; // return false;
} else { // } else {
//Deposit successful. Update user balance and status to 2. Its Private key can be //Deposit successful. Update user balance and status to 2. Its Private key can be
// now given to a random trader // now given to a random trader
trader_deposits.status = 2; trader_deposits.status = 2;
trader_deposits.bitcoinToBePaid = balance;
const trader_deposit_updated = await _updateinDB( const trader_deposit_updated = await _updateinDB(
"deposit", "deposit",
trader_deposits, trader_deposits,
@ -30521,7 +30584,7 @@
}); });
} }
); );
} //}
} }
}); });
} catch (error) { } catch (error) {