added my_inbox feature, improved login

This commit is contained in:
Abhishek Sinha 2020-05-27 19:23:33 +05:30
parent 41ffea38a3
commit 8cc5b98afc

View File

@ -88,9 +88,14 @@
<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"/> <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> </svg>
</div> </div>
<p class="light-text"> <div class="action expand" id="newUserSignInBtn">
Don't have private key, get it from <a href="https://flo-webwallet.duckdns.org/" target="_blank">here</a>. <button class="primary-btn expand" type="submit">
</p> New User Sign In
</button>
<svg viewBox="0 0 73 73" class="loader">
<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>
</div>
</div> </div>
</div> </div>
@ -15365,50 +15370,85 @@
document.querySelector('main').classList.add('hide-completely') document.querySelector('main').classList.add('hide-completely')
notify('Please provide your FLO private key to Sign in.'); notify('Please provide your FLO private key to Sign in.');
showPopup('sign_in_popup', 'no'); showPopup('sign_in_popup', 'no');
const signInBtn = document.getElementById('signInBtn');
signInBtn.onclick = function () {
const RM_WALLET = new localbitcoinplusplus.wallets(); async function app_login() {
const pk_manual = document.getElementById('get_priv_key_field').value;
let gen_new_keys = RM_WALLET.generateFloKeys(pk_manual);
Object.defineProperty( try {
localbitcoinplusplus.wallets, const RM_WALLET = new localbitcoinplusplus.wallets();
"MY_SUPERNODE_PRIVATE_KEY", let pk_manual = document.getElementById('get_priv_key_field').value;
{ const usr_details = await readDB('localbitcoinUser', '00-01');
value: gen_new_keys.privateKeyWIF, let gen_new_keys = RM_WALLET.generateFloKeys(pk_manual);
writable: false,
configurable: false, if(typeof usr_details.myLocalFLOAddress=="string"
enumerable: false && usr_details.myLocalFLOAddress.length>0) {
if(gen_new_keys.address!==usr_details.myLocalFLOAddress) {
notify('Incorrect private key. Please provide your FLO private key to Sign in.', 'error');
return resolve(false);
}
} else {
notify(`This is your LOGIN PRIVATE KEY:
${gen_new_keys.privateKeyWIF}
Please copy & save it securely somewhere.
You can use it to login or recover your account.
DO NOT SHARE OR LOSE THIS PRIVATE KEY.
Else you can lose your desposited assets like Bitcoins or Cash forever.
`, '', true, true, true);
} }
);
Object.defineProperty(
localbitcoinplusplus.wallets,
"my_local_flo_address",
{
value: gen_new_keys.address,
writable: false,
configurable: false,
enumerable: false
}
);
Object.defineProperty(
localbitcoinplusplus.wallets,
"my_local_flo_public_key",
{
value: gen_new_keys.pubKeyHex,
writable: false,
configurable: false,
enumerable: false
}
);
notify('Signed in successfully.') Object.defineProperty(
document.querySelector('main').classList.remove('hide-completely') localbitcoinplusplus.wallets,
hidePopup(); "MY_SUPERNODE_PRIVATE_KEY",
{
value: gen_new_keys.privateKeyWIF,
writable: false,
configurable: false,
enumerable: false
}
);
Object.defineProperty(
localbitcoinplusplus.wallets,
"my_local_flo_address",
{
value: gen_new_keys.address,
writable: false,
configurable: false,
enumerable: false
}
);
Object.defineProperty(
localbitcoinplusplus.wallets,
"my_local_flo_public_key",
{
value: gen_new_keys.pubKeyHex,
writable: false,
configurable: false,
enumerable: false
}
);
notify('Signed in successfully.')
document.querySelector('main').classList.remove('hide-completely')
hidePopup();
return resolve(gen_new_keys.privateKeyWIF);
} catch(e) {
notify('Incorrect private key. Please provide your FLO private key to Sign in.', 'error');
return resolve(false);
}
return resolve(gen_new_keys.privateKeyWIF);
} }
const signInBtn = document.getElementById('signInBtn');
signInBtn.onclick=app_login;
const newUserSignInBtn = document.getElementById('newUserSignInBtn');
newUserSignInBtn.onclick=app_login;
}); });
}, },
@ -22986,8 +23026,8 @@
console.log(finalMessage); console.log(finalMessage);
reactor.dispatchEvent("informAllSuperNode", msg_obj); reactor.dispatchEvent("informAllSuperNode", msg_obj);
showMessage("Sent Crypto shares to "+req_params.initialSender); showMessage("Sent Crypto shares to "+res_obj.initialSender);
console.info("Sent Crypto shares to "+req_params.initialSender); console.info("Sent Crypto shares to "+res_obj.initialSender);
}); });
} }
@ -23186,6 +23226,13 @@
) { ) {
notify(received_resp.server_msg, '', false, true, true); notify(received_resp.server_msg, '', false, true, true);
showMessage(received_resp.server_msg); showMessage(received_resp.server_msg);
addDB('my_inbox', {
id: helper_functions.unique_id(),
trader_flo_address: received_resp.receiver_flo_address,
sender: res_obj.nodePubKey,
msg: received_resp.server_msg,
datetime: + new Date()
});
return false; return false;
} }
} else { } else {
@ -24888,6 +24935,13 @@
) { ) {
notify(received_resp.server_msg, '', false, true, true); notify(received_resp.server_msg, '', false, true, true);
showMessage(received_resp.server_msg); showMessage(received_resp.server_msg);
addDB('my_inbox', {
id: helper_functions.unique_id(),
trader_flo_address: received_resp.receiver_flo_address,
sender: res_obj.nodePubKey,
msg: received_resp.server_msg,
datetime: + new Date()
});
return false; return false;
} }
} else { } else {
@ -30254,6 +30308,16 @@
); );
} }
readAllDB('my_inbox').then(resp=>{
resp.map(m=>{
if(localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(m.sender)
&& m.trader_flo_address===localbitcoinplusplus.wallets.my_local_flo_address
&& m.datetime<2*24*60*60*1000) {
notify(m.msg, '', false, false, true);
}
});
});
hidePopup(); // hide main_loader hidePopup(); // hide main_loader
notify( notify(