diff --git a/index.html b/index.html index 901f024..bd06955 100644 --- a/index.html +++ b/index.html @@ -4,1539 +4,7 @@ Local Bitcoin++ - +
@@ -1620,7 +88,7 @@
- @@ -2035,7 +503,7 @@ Close this popup -

Deposit Crypto

+

Deposit Crypto

-
Send crypto to this address:
+
Send crypto to this address:

Waiting for Server's response...

@@ -18274,6 +16742,7 @@ deposit_dl.product ) && params.product == deposit_dl.product + && deposit_dl.bitcoinToBePaid>0 )) { // Deposited Bitcoin is under process deposit_dl.status = 3; @@ -18894,7 +17363,31 @@ console.log(res); try { if (typeof res == "object") { - let msg = ""; + let msg = ""; + let emsg = ''; + let respo_obj = JSON.parse(res.txid); + if((typeof respo_obj.txid!=="string" + && typeof respo_obj.txid.result!=="string") + && res.error==true) { + emsg = 'Failed to send Transaction.'; + if(typeof res.msg == "string") { + emsg = res.msg; + } + console.error(emsg); + RM_RPC.send_rpc + .call(this, "supernode_message", { + trader_flo_address: + withdraw_res.trader_flo_address, + receiver_flo_address: + withdraw_res.trader_flo_address, + server_msg: emsg + }) + .then(server_response => + doSend(server_response) + ); + throw new Error(emsg); + } + if ( typeof res.txid == "string" && res.txid.length > 0 @@ -20049,6 +18542,7 @@ deposit_dl.product ) && params.product == deposit_dl.product + && deposit_dl.bitcoinToBePaid>0 )) { // Deposited Bitcoin is under process deposit_dl.status = 3; @@ -20716,6 +19210,29 @@ try { if (typeof res == "object") { let msg = ""; + let emsg = ''; + let respo_obj = JSON.parse(res.txid); + if((typeof respo_obj.txid!=="string" + && typeof respo_obj.txid.result!=="string") + && res.error==true) { + emsg = 'Failed to send Transaction.'; + if(typeof res.msg == "string") { + emsg = res.msg; + } + console.error(emsg); + RM_RPC.send_rpc + .call(this, "supernode_message", { + trader_flo_address: + withdraw_res.trader_flo_address, + receiver_flo_address: + withdraw_res.trader_flo_address, + server_msg: emsg + }) + .then(server_response => + doSend(server_response) + ); + throw new Error(emsg); + } if ( typeof res.txid == "string" && res.txid.length > 0 @@ -22095,6 +20612,8 @@ callback, custom_floData = "" ) { + try { + let blockchain_explorer; let miners_fee = 0.0003; const miner_fee_obj = JSON.parse( @@ -22117,7 +20636,7 @@ if (typeof blockchain_explorer !== "string") { notify( `WARNING: Please select cryptocurrency/fiat value from select bar.`, 'error' - ); + , 'error'); return false; } @@ -22133,11 +20652,12 @@ } Promise.all(utxo_list_req).then(all_utxos => { + all_utxos = all_utxos.filter(f=>![undefined, null].includes(f)); if (all_utxos.length>0) { try { const utxo_list = [].concat(...all_utxos); utxo_list.sort((a, b) => b.confirmations - a.confirmations); - let btc_eq_receiving_amount = receiving_amount; + let btc_eq_receiving_amount = Number(receiving_amount); let trx = bitjs[crypto_type].transaction(); let sum = 0; @@ -22171,12 +20691,15 @@ // Output cannot be greater than input if (sum < btc_eq_receiving_amount) { - btc_eq_receiving_amount = sum; + //btc_eq_receiving_amount = sum; + throw new Error( + `Error: Insufficient balance (${sum}) in exchange. Please try again later.` + ); } if (btc_eq_receiving_amount - miners_fee <= 0) throw new Error( - `Error: btc_eq_receiving_amount cannot be less than miners_fee.` + `Error: Receiving amount cannot be less than miners_fee.` ); btc_eq_receiving_amount = btc_eq_receiving_amount - miners_fee; @@ -22221,12 +20744,15 @@ if (http.status == 200) { console.log(http.responseText); let response_obj = { + error: false, signedTxHash: signedTxHash, txid: http.responseText }; callback(response_obj); } else { let response_obj = { + error: true, + msg: 'Explorer returned Empty Txid', signedTxHash: signedTxHash, txid: "" }; @@ -22236,6 +20762,8 @@ }; http.onerror = function () { let response_obj = { + error: true, + msg: `http sending error`, signedTxHash: signedTxHash, txid: "" }; @@ -22243,14 +20771,37 @@ }; http.send(params); } catch (error) { - showMessage(error); - throw new Error(error); + console.error(error); + let response_obj = { + error: true, + msg: error, + signedTxHash: "", + txid: "" + }; + callback(response_obj); } } catch (error) { - throw new Error(error); + console.error(error); + let response_obj = { + error: true, + msg: error, + signedTxHash: "", + txid: "" + }; + callback(response_obj); } } - }) + }); + } catch(e) { + console.error(error); + let response_obj = { + error: true, + msg: error, + signedTxHash: "", + txid: "" + }; + callback(response_obj); + } }, /*Finds the best buy sell id match for a trade*/ createTradePipes(trading_currency = "USD", backup_db = "") { @@ -22765,6 +21316,9 @@ try { //await the response of the fetch call let response = await fetch(url); + if (!response.ok) { + throw new Error('Network response was not ok'); + } //proceed once the first promise is resolved. let data = await response.json(); //proceed only when the second promise is resolved @@ -23473,7 +22027,7 @@ if (counter === radioGroups) radioStatus = true; else - radioStatus = true; + radioStatus = false; if (inputStatus && radioStatus) return true else @@ -23607,13 +22161,23 @@ console.log(res); if (typeof res == "object") { try { + let resp_txid = ''; + let msg = ''; let resp_obj = JSON.parse(res.txid); - let resp_txid = resp_obj.txid.result || resp_obj.txid; - let msg = `Transaction Id for your deposited crypto asset: ${resp_txid}`; + if((typeof resp_obj.txid!=="string" + && typeof resp_obj.txid.result!=="string") + && res.error==true) { + if(typeof res.msg == "string") { + msg = res.msg; + } + } else { + resp_txid = resp_obj.txid.result || resp_obj.txid; + msg = `Transaction Id for your deposited crypto asset: ${resp_txid}`; + } showMessage(msg); notify(msg); btnLoading(btn, 'stop') - hidePopup() + hidePopup(); return true; } catch (error) { console.warn(error); @@ -32088,7 +30652,7 @@ let tradeAmount = helper_functions.truncateDecimals(tradeAmountSelect.value); if (depositCryptoButtonClicked === 1) { document.getElementById('server_deposit_crypto_addr').textContent = `Waiting for servers response...` - document.getElementById('deposit_crypto_h3').textContent = `Deposit ${tradeAmount} ${asset_type} to below address.` + document.getElementById('deposit_crypto_h5').textContent = `Deposit ${tradeAmount} ${asset_type} to below address.` showElement('confirm_deposit_btn_section', 'deposit-crypto-group'); //first time clicked depositCryptoButton.firstElementChild.textContent = 'Send from here' @@ -32156,6 +30720,17 @@ tradeAmount, sendersFloId, function (crypto_sent_resp) { + let emsg = ''; + let respo_obj = JSON.parse(crypto_sent_resp.txid); + if((typeof respo_obj.txid!=="string" + && typeof respo_obj.txid.result!=="string") + && crypto_sent_resp.error==true) { + emsg = 'Failed to send Transaction.'; + if(typeof crypto_sent_resp.msg == "string") { + emsg = crypto_sent_resp.msg; + } + return notify(emsg, 'error', true, true, true); + } (async function validateDepositedCrypto() { if (typeof crypto_sent_resp == "object") { let msg = ""; @@ -32170,7 +30745,8 @@ 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.`); + Please do not close or refresh the window until the process completes.`, + '', true, false, false); await localbitcoinplusplus.actions.delay(60000); if (asset_type === 'BTC') { @@ -32193,7 +30769,8 @@ || typeof txdata.confirmations !== "number" || txdata.confirmations < 3) { notify(`Waiting for deposit txid ${resp_txid} for at least 3 confirmations. - Please do not close or refresh the window until the process completes.`); + Please do not close or refresh the window until the process completes.`, + '', true, false, false); validateDepositedCrypto(); } else { cnf_crypto_deposit(); @@ -32417,6 +30994,7 @@ localbitcoinplusplus.master_configurations.tradableAsset1 ) ); + parenthtml.innerHTML = ''; for (var i = 0; i < sendCryptoArray.length; i++) { let selectCryptoHtml = ``; selectCryptoHtml += `