fixed various ui issues related to trade, deposit and withdraw

This commit is contained in:
Abhishek Sinha 2020-04-18 21:40:53 +05:30
parent 1e6dcd1904
commit b04ec508c7

View File

@ -1070,8 +1070,8 @@
} }
/*# sourceMappingURL=main.css.map */</style> /*# sourceMappingURL=main.css.map */</style>
<style> <style>
/* Server logs */ /* Server logs */
pre { pre {
max-height: 20em; max-height: 20em;
font-family: monospace; font-family: monospace;
font-size: 1em; font-size: 1em;
@ -1166,76 +1166,62 @@
<button class="hover">Ok</button> <button class="hover">Ok</button>
</div> </div>
</div> </div>
</div>
<div id="show_message" class="hide">
<svg id="error_icon" class="notification-icon hide-completely" viewBox="0 0 100 100">
<title>Error icon</title>
<path d="M50,0a50,50,0,1,0,50,50A50,50,0,0,0,50,0ZM46,27.18A.79.79,0,0,1,46.6,27h7.72a.79.79,0,0,1,.79.79l-1,28.76a.79.79,0,0,
1-.79.79H47.46a.77.77,0,0,1-.56-.23.73.73,0,0,1-.23-.56l-.86-28.76A.77.77,0,0,1,46,27.18Zm7.68,44.39A4.91,4.91,0,0,1,50,73.05a5.08,5.08,
0,0,1-5.21-5.21A5,5,0,0,1,50,62.63a5,5,0,0,1,3.73,1.45,5.18,5.18,0,0,1,1.42,3.76A5.11,5.11,0,0,1,53.72,71.57Z"/>
</svg>
<svg id="done_icon" class="notification-icon" viewBox="0 0 100 100">
<title>Done icon</title>
<path d="M50,0a50,50,0,1,0,50,50A50,50,0,0,0,50,0ZM80.85,32.37,40.3,72.92a1.24,1.24,0,0,1-1.75,0l-19.4-19.4a1.23,1.23,0,0,1,0-1.75l3.54-3.54a1.23,
1.23,0,0,1,1.74,0L38.55,62.35a1.24,1.24,0,0,0,1.75,0L75.57,27.08a1.23,1.23,0,0,1,1.74,0l3.54,3.54A1.23,1.23,0,0,1,80.85,32.37Z"/>
</svg>
<div>
<h5>Notification</h5>
<span id="notification_text">Message</span>
</div> </div>
<button id="hide_banner_btn"> <div id="show_message" class="hide">
<svg viewBox="0 0 50 50"> <svg id="error_icon" class="notification-icon hide-completely" viewBox="0 0 100 100">
<title>Close this notification</title> <title>Error icon</title>
<line x1="50" y1="0" x2="0" y2="50"/> <path d="M50,0a50,50,0,1,0,50,50A50,50,0,0,0,50,0ZM46,27.18A.79.79,0,0,1,46.6,27h7.72a.79.79,0,0,1,.79.79l-1,28.76a.79.79,0,0,
<line x1="0" y1="0" x2="50" y2="50"/> 1-.79.79H47.46a.77.77,0,0,1-.56-.23.73.73,0,0,1-.23-.56l-.86-28.76A.77.77,0,0,1,46,27.18Zm7.68,44.39A4.91,4.91,0,0,1,50,73.05a5.08,5.08,
0,0,1-5.21-5.21A5,5,0,0,1,50,62.63a5,5,0,0,1,3.73,1.45,5.18,5.18,0,0,1,1.42,3.76A5.11,5.11,0,0,1,53.72,71.57Z"/>
</svg> </svg>
</button> <svg id="done_icon" class="notification-icon" viewBox="0 0 100 100">
</div> <title>Done icon</title>
<!--<svg id="background" viewBox="0 0 2064.612 1967.514"> <path d="M50,0a50,50,0,1,0,50,50A50,50,0,0,0,50,0ZM80.85,32.37,40.3,72.92a1.24,1.24,0,0,1-1.75,0l-19.4-19.4a1.23,1.23,0,0,1,0-1.75l3.54-3.54a1.23,
<defs> 1.23,0,0,1,1.74,0L38.55,62.35a1.24,1.24,0,0,0,1.75,0L75.57,27.08a1.23,1.23,0,0,1,1.74,0l3.54,3.54A1.23,1.23,0,0,1,80.85,32.37Z"/>
<filter id="Rectangle_12" x="0" y="0" width="1502.184" height="1449.184" filterUnits="userSpaceOnUse"> </svg>
<feComposite in="SourceGraphic"/> <div>
</filter> <h5>Notification</h5>
</defs> <span id="notification_text">Message</span>
<rect id="Rectangle_4" data-name="Rectangle 4" width="1387" height="637" rx="60" transform="translate(71 1517.087) rotate(-45)" fill="#17bf65"/> </div>
<g transform="matrix(1, 0, 0, 1, 0, 0)" filter="url(#Rectangle_12)"> <button id="hide_banner_btn">
<rect id="Rectangle_12-2" data-name="Rectangle 12" width="1387" height="637" rx="60" transform="translate(521.43 6) rotate(45)" fill="#6decb9"/> <svg viewBox="0 0 50 50">
</g> <title>Close this notification</title>
<circle id="Ellipse_3" data-name="Ellipse 3" cx="34.5" cy="34.5" r="34.5" transform="translate(1502.612 769.248)" fill="#b2ffe8"/> <line x1="50" y1="0" x2="0" y2="50"/>
<circle id="Ellipse_2" data-name="Ellipse 2" cx="98" cy="98" r="98" transform="translate(1868.612 1036.248)" fill="#b2b2ff"/> <line x1="0" y1="0" x2="50" y2="50"/>
</svg>--> </svg>
</button>
<!--Sign in popup--> </div>
<div class="popup-container solid-background"> <!--Sign in popup-->
<div id="sign_in_popup" class="popup"> <div class="popup-container solid-background hide">
<div class="container-header"> <div id="sign_in_popup" class="popup">
<h1>Sign In</h1> <div class="container-header">
</div> <h1>Sign In</h1>
<p class="expand light-text">Welcome to RanchiMall Crypto exchange <b>Local Bitcoin++</b></p> </div>
<label class="input"> <p class="expand light-text">Welcome to RanchiMall Crypto exchange <b>Local Bitcoin++</b></p>
<input id="get_priv_key_field" type="password" required> <label class="input">
<div class="label">Private Key</div> <input id="get_priv_key_field" type="password" required>
</label> <div class="label">Private Key</div>
<div class="action expand" onclick="signIn(this)"> </label>
<button class="primary-btn expand" type="submit" disabled> <div class="action expand" id="signInBtn">
Sign In <button class="primary-btn expand" type="submit" disabled>
</button> Sign In
<svg viewBox="0 0 73 73" class="loader"> </button>
<path d="M72.5,36.5c0,19.88-16.12,36-36,36s-36-16.12-36-36s16.12-36,36-36S72.5,16.62,72.5,36.5"/> <svg viewBox="0 0 73 73" class="loader">
</svg> <path d="M72.5,36.5c0,19.88-16.12,36-36,36s-36-16.12-36-36s16.12-36,36-36S72.5,16.62,72.5,36.5"/>
</div> </svg>
<p class="light-text"> </div>
Don't have private key, get it from <a href="https://flo-webwallet.duckdns.org/" target="_blank">here</a>. <p class="light-text">
</p> Don't have private key, get it from <a href="https://flo-webwallet.duckdns.org/" target="_blank">here</a>.
<svg id="sign_in_illustration" viewBox="0 0 612 276.03"> </p>
<defs><style>.a{fill:#ee2a7b;}.b{fill:#9e1f63;}.c{fill:#da1c5c;}</style></defs> <svg id="sign_in_illustration" viewBox="0 0 612 276.03">
<title>Untitled-1</title> <defs><style>.a{fill:#ee2a7b;}.b{fill:#9e1f63;}.c{fill:#da1c5c;}</style></defs>
<polygon class="a" points="0 0 0 276.03 195.07 207.16 233.66 0 0 0"/> <title>Untitled-1</title>
<polygon class="b" points="114.09 0 117.19 27.93 356.1 132.63 536.42 0 114.09 0"/> <polygon class="a" points="0 0 0 276.03 195.07 207.16 233.66 0 0 0"/>
<polygon class="c" points="480.49 0 538.11 99.8 612 99.8 612 0 480.49 0"/> <polygon class="b" points="114.09 0 117.19 27.93 356.1 132.63 536.42 0 114.09 0"/>
</svg> <polygon class="c" points="480.49 0 538.11 99.8 612 99.8 612 0 480.49 0"/>
</div> </svg>
</div> </div>
</div>
<header id="main_header" class="flex"> <header id="main_header" class="flex">
<span class="expand"> <span class="expand">
@ -1460,7 +1446,7 @@
</svg> </svg>
<h3>Buy Crypto</h3> <h3>Buy Crypto</h3>
<div class="action" id="trade_buy_button"> <div class="action" id="trade_buy_button">
<button class="btn" type="submit" disabled> <button class="btn" type="submit">
Buy Buy
</button> </button>
<svg viewBox="0 0 73 73" class="loader"> <svg viewBox="0 0 73 73" class="loader">
@ -1474,11 +1460,6 @@
<div class="crypto-selector flex expand" id="selectListFiatBuy"></div> <div class="crypto-selector flex expand" id="selectListFiatBuy"></div>
<h5>Select Amount</h5> <h5>Select Amount</h5>
<div class="crypto-selector flex expand" id="selectListTradingAmountBuy"></div> <div class="crypto-selector flex expand" id="selectListTradingAmountBuy"></div>
<label class="input">
<input type="number" inputmode="numeric" required>
<div class="label">Buy worth of</div>
</label>
</div> </div>
</div> </div>
<div class="popup-container hide"> <div class="popup-container hide">
@ -1490,7 +1471,7 @@
</svg> </svg>
<h3>Sell Crypto</h3> <h3>Sell Crypto</h3>
<div class="action" id="trade_sell_button"> <div class="action" id="trade_sell_button">
<button class="btn" type="submit" disabled> <button class="btn" type="submit">
Sell Sell
</button> </button>
<svg viewBox="0 0 73 73" class="loader"> <svg viewBox="0 0 73 73" class="loader">
@ -1504,10 +1485,6 @@
<div class="crypto-selector flex expand" id="selectListFiatSell"></div> <div class="crypto-selector flex expand" id="selectListFiatSell"></div>
<h5>Select Amount</h5> <h5>Select Amount</h5>
<div class="crypto-selector flex expand" id="selectListTradingAmountSell"></div> <div class="crypto-selector flex expand" id="selectListTradingAmountSell"></div>
<label class="input">
<input type="number" inputmode="numeric" required>
<div class="label">Sell worth of</div>
</label>
</div> </div>
</div> </div>
<!-- Crypto section--> <!-- Crypto section-->
@ -1543,7 +1520,7 @@
<div class="label">Reciever's FLO ID</div> <div class="label">Reciever's FLO ID</div>
</label> </label>
<label class="input"> <label class="input">
<input name="amount" type="number" inputmode="numeric" required> <input name="amount" type="number" required>
<div class="label">Amount</div> <div class="label">Amount</div>
</label> </label>
</div> </div>
@ -1568,16 +1545,17 @@
<h5>Select Crypto</h5> <h5>Select Crypto</h5>
<div class="crypto-selector flex expand" id="deposit_crypto_div"></div> <div class="crypto-selector flex expand" id="deposit_crypto_div"></div>
<label class="input"> <label class="input">
<input id="trade_amount_select" type="number" inputmode="numeric" required> <input id="trade_amount_select" type="number" required>
<div class="label">Amount</div> <div class="label">Amount</div>
</label> </label>
<h5>Click After Sending Crypto To Exchange</h5> <h5>Click After Sending Crypto To Exchange</h5>
<div class="flex expand" id="cnf_crypto_deposit"></div> <div class="flex expand" id="cnf_crypto_deposit">
<label class="input"> <div class="action">
<input type="button"> <button class="btn">
<div class="label">Confirm Deposit</div> <div class="label">Confirm Deposit</div>
</label> </div>
</div> </div>
</div> </div>
<div class="popup-container hide"> <div class="popup-container hide">
<div id="withdraw_crypto_popup" class="popup"> <div id="withdraw_crypto_popup" class="popup">
@ -1588,7 +1566,7 @@
</svg> </svg>
<h3>Withdraw Crypto</h3> <h3>Withdraw Crypto</h3>
<div class="action" id="withdrawCryptoButton"> <div class="action" id="withdrawCryptoButton">
<button class="btn" type="submit" disabled> <button class="btn" type="submit">
withdraw withdraw
</button> </button>
<svg viewBox="0 0 73 73" class="loader"> <svg viewBox="0 0 73 73" class="loader">
@ -1603,7 +1581,7 @@
<div class="label">Recieving crypto Address</div> <div class="label">Recieving crypto Address</div>
</label> </label>
<label class="input"> <label class="input">
<input id="crypto_withdraw_amount" type="number" inputmode="numeric" required> <input id="crypto_withdraw_amount" type="number" required>
<div class="label">Amount</div> <div class="label">Amount</div>
</label> </label>
</div> </div>
@ -1631,7 +1609,7 @@
<div class="label">Depositer's UPI address</div> <div class="label">Depositer's UPI address</div>
</label> </label>
<label class="input"> <label class="input">
<input name="amount" type="number" inputmode="numeric" required> <input name="amount" type="number" required>
<div class="label">Amount</div> <div class="label">Amount</div>
</label> </label>
<h3 id="upiToAddress" class="hide-completely"></h3> <h3 id="upiToAddress" class="hide-completely"></h3>
@ -1659,7 +1637,7 @@
<div class="label">Recieving UPI address</div> <div class="label">Recieving UPI address</div>
</label> </label>
<label class="input"> <label class="input">
<input name="amount" type="number" name="hi" inputmode="numeric" required> <input name="amount" type="number" name="hi" required>
<div class="label">Amount</div> <div class="label">Amount</div>
</label> </label>
</div> </div>
@ -1678,12 +1656,13 @@
card.classList.add('order', 'grid', 'grid-2') card.classList.add('order', 'grid', 'grid-2')
currency === 'INR' ? currencySymbol = '₹' : currencySymbol = '$'; currency === 'INR' ? currencySymbol = '₹' : currencySymbol = '$';
card.innerHTML = `<div class="details"> card.innerHTML = `<div class="details">
<h3>${type}</h3> <h3>${type.toUpperCase()}</h3>
${product} worth ${currencySymbol}${price} ${product} worth ${currencySymbol}${price}
<h5>Trade Id</h5> <h5>Trade Id</h5>
<span class="breakable">${tradeId}</span> <span class="breakable">${tradeId}</span>
</div> </div>
<button id="${tradeId}" class="cancel-order">Cancel</button>`; <button id="${tradeId}-${localbitcoinplusplus.wallets.my_local_flo_address}-${type}"
class="cancel-order">Cancel</button>`;
return card; return card;
} }
} }
@ -1779,7 +1758,7 @@
currentTimeout = setTimeout(()=>{ currentTimeout = setTimeout(()=>{
banner.classList.add('hide') banner.classList.add('hide')
banner.classList.remove('no-transformations') banner.classList.remove('no-transformations')
}, 4000) }, 10000)
} }
// 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){
@ -1987,21 +1966,19 @@
console.log(res); console.log(res);
if (typeof res == "object") { if (typeof res == "object") {
try { try {
let resp_obj = JSON.parse(res.txid); let resp_obj = JSON.parse(res.txid);
let resp_txid = resp_obj.txid.result || resp_obj.txid; let resp_txid = resp_obj.txid.result || resp_obj.txid;
let msg = `Transaction Id for your deposited crypto asset: ${resp_txid}`; let msg = `Transaction Id for your deposited crypto asset: ${resp_txid}`;
notify(msg); showMessage(msg);
notify(msg);
msg = `Signed Raw Tx for your deposited crypto asset: ${res.signedTxHash}`; return true;
notify(msg);
return true;
} catch (error) { } catch (error) {
console.warn(error); console.warn(error);
notify(error); showMessage(error);
notify(error);
} }
} }
} });
);
setTimeout(() => { setTimeout(() => {
btnLoading(btn, 'stop') btnLoading(btn, 'stop')
@ -2010,19 +1987,6 @@
}, 1000) }, 1000)
} }
function signIn(btn){
let parentPopup = btn.closest('.popup');
btnLoading(btn, 'start')
//if operation completes{
setTimeout(() => {
btnLoading(btn, 'stop')
hidePopup(parentPopup)
notify('Signed In')
document.querySelector('main').classList.remove('hide-completely')
}, 1000)
//}
}
function refreshBalance(type, btn){ function refreshBalance(type, btn){
let newBalance ; let newBalance ;
@ -16561,50 +16525,62 @@
return false; return false;
}, },
manually_assign_my_private_key: function() { manually_assign_my_private_key: function() {
readDB("localbitcoinUser", "00-01") document.querySelector('main').classList.add('hide-completely')
.then(usr => { notify('Please provide your FLO private key to Sign in.');
if (typeof usr == "object" && usr.myLocalFLOAddress.length > 0) { showPopup('sign_in_popup');
const RM_WALLET = new localbitcoinplusplus.wallets(); const signInBtn = document.getElementById('signInBtn');
const pk_manual = prompt("Please enter your private key: "); signInBtn.onclick = function() {
let gen_new_keys = RM_WALLET.generateFloKeys(pk_manual); readDB("localbitcoinUser", "00-01")
if (gen_new_keys.address == usr.myLocalFLOAddress) { .then(usr => {
Object.defineProperty( if (typeof usr == "object" && usr.myLocalFLOAddress.length > 0) {
localbitcoinplusplus.wallets,
"MY_SUPERNODE_PRIVATE_KEY", const RM_WALLET = new localbitcoinplusplus.wallets();
{ //const pk_manual = prompt("Please enter your private key: ");
value: gen_new_keys.privateKeyWIF, const pk_manual = document.getElementById('get_priv_key_field').value;
writable: false, let gen_new_keys = RM_WALLET.generateFloKeys(pk_manual);
configurable: false, if (gen_new_keys.address == usr.myLocalFLOAddress) {
enumerable: false Object.defineProperty(
localbitcoinplusplus.wallets,
"MY_SUPERNODE_PRIVATE_KEY",
{
value: gen_new_keys.privateKeyWIF,
writable: false,
configurable: false,
enumerable: false
}
);
notify('Signed in successfully.')
document.querySelector('main').classList.remove('hide-completely')
hidePopup('sign_in_popup');
if (localbitcoinplusplus.is_ui_loaded == false) {
dataBaseUIOperations();
}
// Private key is built. Now execute private key dependent functions
const RM_WALLET = new localbitcoinplusplus.wallets;
const pubkey = RM_WALLET
.generateFloKeys(localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY)
.pubKeyHex
if (localbitcoinplusplus.master_configurations.supernodesPubKeys
.includes(pubkey)) {
reactor.dispatchEvent("user_flo_keys_active", pubkey);
}
Promise.resolve(true);
} else {
let mes = `WARNING: Failed to build your private key. You can reset keys and generate new keys from keys section below.`;
showMessage(mes);
Promise.reject(mes);
}
} }
); })
if (localbitcoinplusplus.is_ui_loaded == false) { .catch(e => {
dataBaseUIOperations(); let mes = `WARNING: Failed to build your private key. You can reset keys and generate new keys from keys section below.`;
} showMessage(mes);
Promise.reject(mes);
// Private key is built. Now execute private key dependent functions });
const RM_WALLET = new localbitcoinplusplus.wallets; }
const pubkey = RM_WALLET
.generateFloKeys(localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY)
.pubKeyHex
if(localbitcoinplusplus.master_configurations.supernodesPubKeys
.includes(pubkey)) {
reactor.dispatchEvent("user_flo_keys_active", pubkey);
}
Promise.resolve(true);
} else {
let mes = `WARNING: Failed to build your private key. You can reset keys and generate new keys from keys section below.`;
showMessage(mes);
Promise.reject(mes);
}
}
})
.catch(e => {
let mes = `WARNING: Failed to build your private key. You can reset keys and generate new keys from keys section below.`;
showMessage(mes);
Promise.reject(mes);
});
}, },
rebuild_my_private_key: function(transactionKey) { rebuild_my_private_key: function(transactionKey) {
const RM_WALLET = new localbitcoinplusplus.wallets(); const RM_WALLET = new localbitcoinplusplus.wallets();
@ -18169,15 +18145,21 @@
request.nodePubKey request.nodePubKey
) )
) { ) {
removeinDB(tradeDB, cancel_request.trade_id).then( removeinDB(tradeDB, cancel_request.trade_id).then(
id => { id => {
msg_response = {
user_flo_addr: cancel_request.trader_flo_address,
msg: `Order id ${cancel_request.trade_id} is deleted.`
}
reactor.dispatchEvent('message_for_user', msg_response);
}
).catch(e=>{
msg_response = { msg_response = {
user_flo_addr: cancel_request.trader_flo_address, user_flo_addr: cancel_request.trader_flo_address,
msg: `Order id ${cancel_request.trade_id} is deleted.` msg: `Failed to delete Order id ${cancel_request.trade_id}.`
} }
reactor.dispatchEvent('message_for_user', msg_response); reactor.dispatchEvent('message_for_user', msg_response);
} });
);
} else { } else {
err_response = { err_response = {
user_flo_addr: cancel_request.trader_flo_address, user_flo_addr: cancel_request.trader_flo_address,
@ -18323,6 +18305,9 @@
let transaction_key = localbitcoinplusplus.actions let transaction_key = localbitcoinplusplus.actions
.master_decrypt(btc_reserves.supernode_transaction_key); .master_decrypt(btc_reserves.supernode_transaction_key);
if(typeof transaction_key=="string") {
transaction_key = JSON.parse(transaction_key);
}
if (transaction_key.length > 0) { if (transaction_key.length > 0) {
let btc_private_key = RM_WALLET.rebuild_private_key( let btc_private_key = RM_WALLET.rebuild_private_key(
btc_pk_shares_array, btc_pk_shares_array,
@ -19979,7 +19964,13 @@
reactor.dispatchEvent('message_for_user', err_response); reactor.dispatchEvent('message_for_user', err_response);
} }
); ).catch(e=>{
msg_response = {
user_flo_addr: cancel_request.trader_flo_address,
msg: `Failed to delete Order id ${cancel_request.trade_id}.`
}
reactor.dispatchEvent('message_for_user', msg_response);
});
} else { } else {
err_response = { err_response = {
user_flo_addr: cancel_request.trader_flo_address, user_flo_addr: cancel_request.trader_flo_address,
@ -20150,6 +20141,9 @@
let transaction_key = localbitcoinplusplus.actions let transaction_key = localbitcoinplusplus.actions
.master_decrypt(btc_reserves.supernode_transaction_key); .master_decrypt(btc_reserves.supernode_transaction_key);
if(typeof transaction_key=="string") {
transaction_key = JSON.parse(transaction_key);
}
if (transaction_key.length > 0) { if (transaction_key.length > 0) {
let btc_private_key = RM_WALLET.rebuild_private_key( let btc_private_key = RM_WALLET.rebuild_private_key(
btc_pk_shares_array, btc_pk_shares_array,
@ -21775,7 +21769,6 @@
console.log(trx); console.log(trx);
let signedTxHash = trx.sign(utxo_addr_wif, 1); //SIGHASH_ALL DEFAULT 1 let signedTxHash = trx.sign(utxo_addr_wif, 1); //SIGHASH_ALL DEFAULT 1
showMessage(`Signed Transaction Hash: ${signedTxHash}`);
console.log(signedTxHash); console.log(signedTxHash);
var http = new XMLHttpRequest(); var http = new XMLHttpRequest();
@ -22719,15 +22712,14 @@
RM_WALLET.distributeShamirsSecretShares(newKeys.privateKeyWIF) RM_WALLET.distributeShamirsSecretShares(newKeys.privateKeyWIF)
.then(() => privateKeyBuilder()) .then(() => privateKeyBuilder())
.finally(() => { .finally(() => {
setTimeout(function() { setTimeout(async function() {
if ( if (
typeof localbitcoinplusplus.wallets typeof localbitcoinplusplus.wallets
.MY_SUPERNODE_PRIVATE_KEY !== "string" || .MY_SUPERNODE_PRIVATE_KEY !== "string" ||
localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY
.length < 1 .length < 1
) { ) {
RM_WALLET.manually_assign_my_private_key(); await RM_WALLET.manually_assign_my_private_key();
dataBaseUIOperations();
} else if ( } else if (
typeof localbitcoinplusplus.wallets typeof localbitcoinplusplus.wallets
.MY_SUPERNODE_PRIVATE_KEY == "string" && .MY_SUPERNODE_PRIVATE_KEY == "string" &&
@ -22839,14 +22831,13 @@
// rebuild private key // rebuild private key
await privateKeyBuilder(); await privateKeyBuilder();
setTimeout(function() { setTimeout(async function() {
if ( if (
typeof localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY !== typeof localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY !==
"string" || "string" ||
localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY.length < 1 localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY.length < 1
) { ) {
RM_WALLET.manually_assign_my_private_key(); await RM_WALLET.manually_assign_my_private_key();
dataBaseUIOperations();
} else if ( } else if (
typeof localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY == typeof localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY ==
"string" && "string" &&
@ -23092,7 +23083,7 @@
// Connection established, build private key and UI // Connection established, build private key and UI
await privateKeyBuilder(); await privateKeyBuilder();
localbitcoinplusplus.actions.delay(10000).then(() => { localbitcoinplusplus.actions.delay(10000).then(async() => {
if ( if (
typeof localbitcoinplusplus.wallets typeof localbitcoinplusplus.wallets
.MY_SUPERNODE_PRIVATE_KEY !== "string" || .MY_SUPERNODE_PRIVATE_KEY !== "string" ||
@ -23100,8 +23091,7 @@
1 1
) { ) {
const RM_WALLET = new localbitcoinplusplus.wallets(); const RM_WALLET = new localbitcoinplusplus.wallets();
RM_WALLET.manually_assign_my_private_key(); await RM_WALLET.manually_assign_my_private_key();
dataBaseUIOperations();
} else if ( } else if (
typeof localbitcoinplusplus.wallets typeof localbitcoinplusplus.wallets
.MY_SUPERNODE_PRIVATE_KEY == "string" && .MY_SUPERNODE_PRIVATE_KEY == "string" &&
@ -23545,7 +23535,8 @@
addDB("buyOrders", buyOrders_data).then(() => { addDB("buyOrders", buyOrders_data).then(() => {
if(localbitcoinplusplus.wallets.my_local_flo_address if(localbitcoinplusplus.wallets.my_local_flo_address
===buyOrders_data.trader_flo_address) { ===buyOrders_data.trader_flo_address) {
showMessage(`Your buy order is placed successfully.`); displayTradeOrders(localbitcoinplusplus.wallets.my_local_flo_address)
notify(`Your buy order is placed successfully.`);
} }
}); });
} }
@ -23581,9 +23572,8 @@
addDB("sellOrders", sellOrders_data).then(() => { addDB("sellOrders", sellOrders_data).then(() => {
if(localbitcoinplusplus.wallets.my_local_flo_address if(localbitcoinplusplus.wallets.my_local_flo_address
===sellOrders_data.trader_flo_address) { ===sellOrders_data.trader_flo_address) {
showMessage( displayTradeOrders(localbitcoinplusplus.wallets.my_local_flo_address);
`Your sell order is placed successfully.` notify(`Your sell order is placed successfully.`);
);
} }
}); });
@ -23889,11 +23879,13 @@
); );
Promise.all([p1,p2,p3,p4]).then(()=>{ Promise.all([p1,p2,p3,p4]).then(()=>{
displayTradeOrders(localbitcoinplusplus.wallets.my_local_flo_address)
// Update balances // Update balances
displayBalances( displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address localbitcoinplusplus.wallets.my_local_flo_address
); );
showMessage("Balances updated.") notify("Trade successfull. Balances updated.")
showMessage("Trade successfull. Balances updated.")
}) })
.catch(e => {throw new Error(e)}); .catch(e => {throw new Error(e)});
@ -23999,6 +23991,8 @@
typeof res_obj.nodePubKey != "string" typeof res_obj.nodePubKey != "string"
|| !localbitcoinplusplus.master_configurations.supernodesPubKeys || !localbitcoinplusplus.master_configurations.supernodesPubKeys
.includes(res_obj.nodePubKey) .includes(res_obj.nodePubKey)
|| !localbitcoinplusplus.master_configurations.supernodesPubKeys
.includes(localbitcoinplusplus.wallets.my_local_flo_address)
) return; ) return;
readDB( readDB(
@ -25118,7 +25112,8 @@
addDB("buyOrders", buyOrders_data).then(() => { addDB("buyOrders", buyOrders_data).then(() => {
if(localbitcoinplusplus.wallets.my_local_flo_address if(localbitcoinplusplus.wallets.my_local_flo_address
===buyOrders_data.trader_flo_address) { ===buyOrders_data.trader_flo_address) {
showMessage(`Your buy order is placed successfully.`); displayTradeOrders(localbitcoinplusplus.wallets.my_local_flo_address)
notify(`Your buy order is placed successfully.`);
} }
}); });
} }
@ -25147,11 +25142,6 @@
if ( if (
typeof localbitcoinplusplus.master_configurations typeof localbitcoinplusplus.master_configurations
.supernodesPubKeys == "object" .supernodesPubKeys == "object"
// Commented this because it prevents usernode to register data in db
// while a backup supernode sends it any data like trade_buy
// && localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(
// sellOrders_data.supernodePubKey)
) { ) {
let isDataSignedBySuperNode = RM_WALLET.verify( let isDataSignedBySuperNode = RM_WALLET.verify(
sellOrders_data.data_hash, sellOrders_data.data_hash,
@ -25163,9 +25153,8 @@
addDB("sellOrders", sellOrders_data).then(() => { addDB("sellOrders", sellOrders_data).then(() => {
if(localbitcoinplusplus.wallets.my_local_flo_address if(localbitcoinplusplus.wallets.my_local_flo_address
===sellOrders_data.trader_flo_address) { ===sellOrders_data.trader_flo_address) {
showMessage( displayTradeOrders(localbitcoinplusplus.wallets.my_local_flo_address);
`Your sell order is placed successfully.` notify(`Your sell order is placed successfully.`);
);
} }
}); });
} }
@ -25483,10 +25472,13 @@
); );
Promise.all([pr1,pr2,pr3,pr4]).then(()=>{ Promise.all([pr1,pr2,pr3,pr4]).then(()=>{
displayTradeOrders(localbitcoinplusplus.wallets.my_local_flo_address);
// Update balances // Update balances
displayBalances( displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address localbitcoinplusplus.wallets.my_local_flo_address
); );
notify("Trade successfull. Balances updated.")
showMessage("Trade successfull. Balances updated.")
}) })
.catch(e => {throw new Error(e)}); .catch(e => {throw new Error(e)});
@ -25653,6 +25645,8 @@
.includes(res_obj.nodePubKey) .includes(res_obj.nodePubKey)
|| typeof localbitcoinplusplus.newBackupDatabase.db[res_obj.params[0].db_inst] || typeof localbitcoinplusplus.newBackupDatabase.db[res_obj.params[0].db_inst]
!== "object" !== "object"
|| !localbitcoinplusplus.master_configurations.supernodesPubKeys
.includes(localbitcoinplusplus.wallets.my_local_flo_address)
) )
return; return;
@ -27095,12 +27089,7 @@
false false
); );
Promise.all([b1,b2,b3,b4]).then(()=>{ Promise.all([b1,b2,b3,b4])
// Update balances
displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address
);
})
.catch(e => {throw new Error(e)}); .catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
@ -27461,6 +27450,8 @@
.includes(res_obj.nodePubKey) .includes(res_obj.nodePubKey)
|| typeof localbitcoinplusplus.newBackupDatabase.db[res_obj.params[0].db_inst] || typeof localbitcoinplusplus.newBackupDatabase.db[res_obj.params[0].db_inst]
!== "object" !== "object"
|| !localbitcoinplusplus.master_configurations.supernodesPubKeys
.includes(localbitcoinplusplus.wallets.my_local_flo_address)
) )
return; return;
@ -29411,7 +29402,9 @@
let objectStoreRequest = request.get(key); let objectStoreRequest = request.get(key);
objectStoreRequest.onsuccess = function (event) { objectStoreRequest.onsuccess = function (event) {
var myRecord = objectStoreRequest.result; var myRecord = objectStoreRequest.result;
if (typeof myRecord !== "object") { if (myRecord==null
|| myRecord== undefined
|| typeof myRecord !== "object") {
Obj.vectorClock = Obj.vectorClock =
typeof Obj.vectorClock == "number" ? Obj.vectorClock : 0; typeof Obj.vectorClock == "number" ? Obj.vectorClock : 0;
if(!exception_datastores.includes(tablename)) { if(!exception_datastores.includes(tablename)) {
@ -29420,11 +29413,16 @@
request = db.transaction([tablename], "readwrite") request = db.transaction([tablename], "readwrite")
.objectStore(tablename).put(Obj); .objectStore(tablename).put(Obj);
} else if (myRecord.vectorClock < Obj.vectorClock) { } else if (myRecord.vectorClock < Obj.vectorClock) {
// Don't sign rather verify data here
if(!exception_datastores.includes(tablename)) { if(!exception_datastores.includes(tablename)) {
Obj = signDBData(Obj); if(verifyDBData(Obj)===true) {
request = db.transaction([tablename], "readwrite")
.objectStore(tablename).put(Obj);
} else {
console.trace(Obj);
throw new Error('Failed verification at db update');
}
} }
request = db.transaction([tablename], "readwrite")
.objectStore(tablename).put(Obj);
} else { } else {
resolve(Obj); resolve(Obj);
} }
@ -30061,7 +30059,9 @@
let objectStoreRequest = this.request.get(key); let objectStoreRequest = this.request.get(key);
objectStoreRequest.onsuccess = function(event) { objectStoreRequest.onsuccess = function(event) {
var myRecord = objectStoreRequest.result; var myRecord = objectStoreRequest.result;
if (typeof myRecord !== "object") { if (myRecord==null
|| myRecord== undefined
|| typeof myRecord !== "object") {
Obj.vectorClock = Obj.vectorClock =
typeof Obj.vectorClock == "number" ? Obj.vectorClock : 0; typeof Obj.vectorClock == "number" ? Obj.vectorClock : 0;
if(!exception_datastores.includes(tablename)) { if(!exception_datastores.includes(tablename)) {
@ -30076,8 +30076,8 @@
this.request = this.db.transaction([tablename], "readwrite") this.request = this.db.transaction([tablename], "readwrite")
.objectStore(tablename).put(Obj); .objectStore(tablename).put(Obj);
} else { } else {
console.error('failed verification at backup update');
console.trace(Obj); console.trace(Obj);
throw new Error('failed verification at backup update');
} }
} }
@ -30552,27 +30552,22 @@
my_trades_div.innerHTML = '<h4>No trade orders yet.</h4>' my_trades_div.innerHTML = '<h4>No trade orders yet.</h4>'
my_trades_div.append(frag); my_trades_div.append(frag);
var delclassname = document.getElementsByClassName("CANCEL_TRADE"); // Function for cancelling trade orders
document.getElementById('orders_container').addEventListener('click', (e) => {
Array.from(delclassname).forEach(function(element) {
element.addEventListener("click", function(e) {
let container = document.getElementById('orders_container'); let container = document.getElementById('orders_container');
if(e.target.closest('.cancel-order')) if(e.target.closest('.cancel-order'))
askConfirmation('Are you sure to cancel this trade order?').then((result) => { askConfirmation('Are you sure to cancel this trade order?').then((result) => {
if(result){ if(result){
let cancel_td = this.id;
let trade_opts = cancel_td.split("-");
RM_TRADE.cancelTrade(trade_opts[0], trade_opts[1], trade_opts[2]);
let tradeId = e.target.closest('.cancel-order').id; let tradeId = e.target.closest('.cancel-order').id;
let trade_opts = tradeId.split("-");
RM_TRADE.cancelTrade(trade_opts[0], trade_opts[1], trade_opts[2]);
e.target.closest('.order').remove(); e.target.closest('.order').remove();
notify(`Order id: ${tradeId} cancelled.`) showMessage('', `Order id: ${trade_opts[0]} cancelled.`)
if(container.children.length === 0) if(container.children.length === 0)
container.innerHTML = '<h4>No trade orders yet.</h4>' container.innerHTML = '<h4>No trade orders yet.</h4>'
} }
}) })
}); })
});
}); });
}; };
@ -30684,7 +30679,7 @@
let parentPopup = this.closest('.popup'), let parentPopup = this.closest('.popup'),
selectedCrypto = parentPopup.querySelector("input[name='crypto']:checked").value, selectedCrypto = parentPopup.querySelector("input[name='crypto']:checked").value,
selectedCurrency = parentPopup.querySelector("input[name='currency']:checked").value, selectedCurrency = parentPopup.querySelector("input[name='currency']:checked").value,
buyWorth = parentPopup.querySelector('.input input').value; buyWorth = parentPopup.querySelector("input[name='trading_amount']:checked").value;
RM_TRADE.place_order( RM_TRADE.place_order(
"buy", "buy",
@ -30708,7 +30703,7 @@
let parentPopup = this.closest('.popup'), let parentPopup = this.closest('.popup'),
selectedCrypto = parentPopup.querySelector("input[name='crypto']:checked").value, selectedCrypto = parentPopup.querySelector("input[name='crypto']:checked").value,
selectedCurrency = parentPopup.querySelector("input[name='currency']:checked").value, selectedCurrency = parentPopup.querySelector("input[name='currency']:checked").value,
sellWorth = parentPopup.querySelector('.input input').value; sellWorth = parentPopup.querySelector("input[name='trading_amount']:checked").value;
RM_TRADE.place_order( RM_TRADE.place_order(
"sell", "sell",
@ -30776,9 +30771,9 @@
withdrawCryptoButton.addEventListener("click", function(params) { withdrawCryptoButton.addEventListener("click", function(params) {
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') let receivinAddress = document.getElementById('withdraw_recving_addr').value
let withdraw_amount= document.getElementById('crypto_withdraw_amount') let withdraw_amount= document.getElementById('crypto_withdraw_amount')
if (receivinAddress == null || receivinAddress.trim == "") { if (receivinAddress == null || receivinAddress.trim() == "") {
err_msg =`You must specify a valid ${asset_type} address to continue.`; err_msg =`You must specify a valid ${asset_type} address to continue.`;
showMessage(err_msg); showMessage(err_msg);
throw new Error(err_msg); throw new Error(err_msg);
@ -31056,7 +31051,6 @@
function buildBroadcastTxUI() { function buildBroadcastTxUI() {
const broadcast_tx_ui = document.getElementById("send_crypto_select_div"); const broadcast_tx_ui = document.getElementById("send_crypto_select_div");
get_crypto_svg_selection_html('broadcastTx', broadcast_tx_ui); get_crypto_svg_selection_html('broadcastTx', broadcast_tx_ui);
//broadcast_tx_ui.insertAdjacentHTML('beforeend', selectCryptoHtml)
} }
</script> </script>