store private key shares locally
This commit is contained in:
parent
edb1e67860
commit
7c64e05595
814
index.html
814
index.html
@ -651,539 +651,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
<script id="ui_functions">
|
|
||||||
let frag = document.createDocumentFragment(),
|
|
||||||
currentTimeout,
|
|
||||||
notificationSound = document.getElementById('notification_sound'),
|
|
||||||
depositCryptoButtonClicked = 0,
|
|
||||||
depositCryptoButton = document.getElementById('depositCryptoButton'),
|
|
||||||
themeToggler = document.getElementById('theme_toggle'),
|
|
||||||
body = document.querySelector('body');
|
|
||||||
if(localStorage.theme === 'dark'){
|
|
||||||
nightlight();
|
|
||||||
themeToggler.checked = true
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
daylight()
|
|
||||||
themeToggler.checked = false
|
|
||||||
}
|
|
||||||
themeToggler.addEventListener('change', () => {
|
|
||||||
if(themeToggler.checked){
|
|
||||||
nightlight();
|
|
||||||
localStorage.setItem('theme', 'dark')
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
daylight();
|
|
||||||
localStorage.setItem('theme', 'light')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
function daylight(){
|
|
||||||
body.setAttribute("data-theme", 'light');
|
|
||||||
}
|
|
||||||
function nightlight(){
|
|
||||||
body.setAttribute('data-theme', 'dark');
|
|
||||||
}
|
|
||||||
const render = {
|
|
||||||
// returns an order element;
|
|
||||||
order: function(tradeId, type, product, price, currency){
|
|
||||||
let card = document.createElement('div'), currencySymbol;
|
|
||||||
card.classList.add('order', 'grid', 'grid-2')
|
|
||||||
currency === 'INR' ? currencySymbol = '₹' : currencySymbol = '$';
|
|
||||||
card.innerHTML = `<div class="details">
|
|
||||||
<h3>${type.toUpperCase()}</h3>
|
|
||||||
${product} worth ${currencySymbol}${price}
|
|
||||||
<h5>Trade Id</h5>
|
|
||||||
<span class="breakable">${tradeId}</span>
|
|
||||||
</div>
|
|
||||||
<button id="${tradeId}-${localbitcoinplusplus.wallets.my_local_flo_address}-${type}"
|
|
||||||
class="cancel-order">Cancel</button>`;
|
|
||||||
return card;
|
|
||||||
},
|
|
||||||
notification: function(message){
|
|
||||||
let card = document.createElement('div');
|
|
||||||
card.classList.add('notification');
|
|
||||||
card.innerHTML = `
|
|
||||||
<svg class="remove-notification" viewBox="0 0 50 50">
|
|
||||||
<title>Close this notification</title>
|
|
||||||
<line x1="50" y1="0" x2="0" y2="50"/>
|
|
||||||
<line x1="0" y1="0" x2="50" y2="50"/>
|
|
||||||
</svg>
|
|
||||||
<p>${message}</p>`
|
|
||||||
return card;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Checks for internet connection status
|
|
||||||
if(!navigator.onLine)
|
|
||||||
notify('There seems to be a problem connecting to the internet.','error', true)
|
|
||||||
window.addEventListener('offline', () =>{
|
|
||||||
notify('There seems to be a problem connecting to the internet.','error', true)
|
|
||||||
})
|
|
||||||
window.addEventListener('online', () =>{
|
|
||||||
notify('We are back online.')
|
|
||||||
})
|
|
||||||
|
|
||||||
// function required for popups or modals to appear
|
|
||||||
class Stack {
|
|
||||||
constructor(){
|
|
||||||
this.items = [];
|
|
||||||
}
|
|
||||||
push(element){
|
|
||||||
this.items.push(element);
|
|
||||||
}
|
|
||||||
pop(){
|
|
||||||
if (this.items.length == 0)
|
|
||||||
return "Underflow";
|
|
||||||
return this.items.pop();
|
|
||||||
}
|
|
||||||
peek(){
|
|
||||||
return this.items[this.items.length - 1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let popupStack = new Stack(),
|
|
||||||
loader = document.getElementById('loader'),
|
|
||||||
zIndex = 10,
|
|
||||||
tipsInterval;
|
|
||||||
function showPopup(popup, permission){
|
|
||||||
let thisPopup = document.getElementById(popup);
|
|
||||||
thisPopup.parentNode.classList.remove('hide');
|
|
||||||
thisPopup.classList.add('no-transformations');
|
|
||||||
popupStack.push({popup, permission})
|
|
||||||
zIndex++;
|
|
||||||
thisPopup.parentNode.setAttribute('style', `z-index: ${zIndex}`)
|
|
||||||
if(popup === 'main_loader'){
|
|
||||||
loader.classList.add('animate-loader')
|
|
||||||
tipsInterval = setInterval(changeTips, 2000)
|
|
||||||
document.querySelector('main').classList.add('hide-completely')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// hides the popup or modal
|
|
||||||
function hidePopup(){
|
|
||||||
let {popup, permission} = popupStack.pop();
|
|
||||||
thisPopup = document.getElementById(popup);
|
|
||||||
thisPopup.closest('.popup-container').classList.add('hide');
|
|
||||||
thisPopup.closest('.popup').classList.remove('no-transformations');
|
|
||||||
setTimeout(() => {
|
|
||||||
clearAllInputs(thisPopup)
|
|
||||||
zIndex--;
|
|
||||||
thisPopup.parentNode.setAttribute('style', `z-index: ${zIndex}`)
|
|
||||||
if(thisPopup.querySelector('.btn')){
|
|
||||||
btnLoading(thisPopup.querySelector('.action'), 'stop')
|
|
||||||
thisPopup.querySelector("button[type='submit']").disabled = true;
|
|
||||||
}
|
|
||||||
}, 400)
|
|
||||||
if(popup === 'deposit_cash_popup'){
|
|
||||||
thisPopup.querySelector('#upiToAddress').classList.add('hide-completely')
|
|
||||||
thisPopup.querySelectorAll('.input').forEach((input) => {
|
|
||||||
input.classList.remove('hide-completely')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if(popup === 'deposit_crypto_popup'){
|
|
||||||
setTimeout(() => {
|
|
||||||
depositCryptoButton.classList.remove('hide-completely');
|
|
||||||
let selectDepositCryptoSection = document.getElementById('select_deposit_crypto_section')
|
|
||||||
showElement(selectDepositCryptoSection, 'deposit-crypto-group');
|
|
||||||
depositCryptoButton.firstElementChild.textContent = 'proceed'
|
|
||||||
}, 400)
|
|
||||||
document.getElementById('send_crypto_hidden_section').querySelectorAll('input').forEach(input => {
|
|
||||||
input.disabled = true;
|
|
||||||
})
|
|
||||||
depositCryptoButtonClicked = 0;
|
|
||||||
}
|
|
||||||
if(popup === 'main_loader'){
|
|
||||||
loader.classList.remove('animate-loader')
|
|
||||||
clearInterval(tipsInterval)
|
|
||||||
document.querySelector('main').classList.remove('hide-completely')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setAttributes(el, attrs) {
|
|
||||||
for(var key in attrs) {
|
|
||||||
el.setAttribute(key, attrs[key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearAllInputs(parent){
|
|
||||||
parent.querySelectorAll("input").forEach((field) => {
|
|
||||||
if(field.getAttribute('type') !== 'radio'){
|
|
||||||
field.value = '';
|
|
||||||
if(field.closest('.input'))
|
|
||||||
{
|
|
||||||
field.closest('.input').classList.remove('animate-label')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
field.checked = false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
//Function for displaying toast notifications.
|
|
||||||
/*options
|
|
||||||
message - notifiation body text.
|
|
||||||
mode - error or normal notification. only error has to be specified.
|
|
||||||
fixed - if set true notification will not fade after 4s;
|
|
||||||
sound - set true to enable notification sound. ! should only be used for important tasks.
|
|
||||||
setAside - set true to add notification inside notification panel
|
|
||||||
*/
|
|
||||||
let currentCount = 0;
|
|
||||||
function notify(message, mode, fixed, sound, setAside){
|
|
||||||
let banner = document.getElementById('show_message'),
|
|
||||||
notificationContainer = document.getElementById('notification_container'),
|
|
||||||
notifiationCounter = document.querySelector("#notification_badge");
|
|
||||||
currentCount = parseInt(notifiationCounter.getAttribute('data-badge'));
|
|
||||||
|
|
||||||
if(mode === 'error'){
|
|
||||||
banner.querySelector('#error_icon').classList.remove('hide-completely')
|
|
||||||
banner.querySelector('#done_icon').classList.add('hide-completely')
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
banner.querySelector('#error_icon').classList.add('hide-completely')
|
|
||||||
banner.querySelector('#done_icon').classList.remove('hide-completely')
|
|
||||||
}
|
|
||||||
if(setAside){
|
|
||||||
notificationContainer.prepend(render.notification(message));
|
|
||||||
console.log(currentCount)
|
|
||||||
currentCount++;
|
|
||||||
notifiationCounter.setAttribute('data-badge', currentCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
banner.classList.add('no-transformations')
|
|
||||||
banner.classList.remove('hide')
|
|
||||||
banner.querySelector('#notification_text').textContent = message.charAt(0).toUpperCase() + message.slice(1);
|
|
||||||
if(navigator.onLine && sound){
|
|
||||||
notificationSound.currentTime = 0;
|
|
||||||
notificationSound.play();
|
|
||||||
}
|
|
||||||
banner.querySelector('#hide_banner_btn').onclick = function() {
|
|
||||||
banner.classList.add('hide')
|
|
||||||
banner.classList.remove('no-transformations')
|
|
||||||
}
|
|
||||||
clearTimeout(currentTimeout)
|
|
||||||
if(fixed) return;
|
|
||||||
currentTimeout = setTimeout(()=>{
|
|
||||||
banner.classList.add('hide')
|
|
||||||
banner.classList.remove('no-transformations')
|
|
||||||
}, 6000)
|
|
||||||
}
|
|
||||||
|
|
||||||
function showNotifications(){
|
|
||||||
let notificationPanel = document.getElementById('notification_panel');
|
|
||||||
currentCount = 0;
|
|
||||||
document.querySelector("#notification_badge").setAttribute('data-badge', currentCount);
|
|
||||||
notificationPanel.classList.toggle('hide')
|
|
||||||
window.onmousedown = e => {
|
|
||||||
if(!e.target.closest('.dropdown'))
|
|
||||||
notificationPanel.classList.add('hide')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearAllNotifications(){
|
|
||||||
document.getElementById('notification_container').innerHTML = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// displays a popup for asking permission. Use this instead of JS confirm
|
|
||||||
let askConfirmation = function(message){
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
let popup = document.getElementById('confirmation');
|
|
||||||
showPopup('confirmation')
|
|
||||||
popup.children[0].textContent = message;
|
|
||||||
popup.children[1].firstElementChild.onclick = function() {
|
|
||||||
hidePopup()
|
|
||||||
resolve(false)
|
|
||||||
}
|
|
||||||
popup.children[1].children[1].onclick = function() {
|
|
||||||
hidePopup()
|
|
||||||
resolve(true);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
function enableBtn(btn){
|
|
||||||
if(typeof btn === 'string')
|
|
||||||
btn = document.getElementById(btn);
|
|
||||||
if(btn.disabled)
|
|
||||||
btn.disabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function disableBtn(btn){
|
|
||||||
if(typeof btn === 'string')
|
|
||||||
btn = document.getElementById(btn);
|
|
||||||
if(!btn.disabled)
|
|
||||||
btn.disabled = true;
|
|
||||||
}
|
|
||||||
function btnLoading(btn, option){
|
|
||||||
if(typeof btn === 'string')
|
|
||||||
btn = document.getElementById(btn);
|
|
||||||
if(option === 'start'){
|
|
||||||
btn.children[0].classList.add('clip')
|
|
||||||
btn.children[1].classList.add('animate-loader')
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
btn.children[0].classList.remove('clip')
|
|
||||||
btn.children[1].classList.remove('animate-loader')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyToClipboard(parent, childIndex) {
|
|
||||||
let input = document.createElement('textarea'),
|
|
||||||
toast = document.getElementById('textCopied');
|
|
||||||
input.setAttribute('readonly', '');
|
|
||||||
input.setAttribute('style', 'position: absolute; left: -9999px');
|
|
||||||
document.body.appendChild(input);
|
|
||||||
input.value = parent.children[childIndex].textContent;
|
|
||||||
input.select();
|
|
||||||
document.execCommand('copy');
|
|
||||||
document.body.removeChild(input);
|
|
||||||
toast.classList.remove('hide');
|
|
||||||
setTimeout(() => {
|
|
||||||
toast.classList.add('hide');
|
|
||||||
}, 2000)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let allExchangeSections = document.querySelectorAll('.exchange-section'),
|
|
||||||
allExchangeBtns = document.querySelectorAll('.exchange-btn');
|
|
||||||
function showSection(thisBtn, elem){
|
|
||||||
let element = document.getElementById(elem)
|
|
||||||
allExchangeSections.forEach((section) => {
|
|
||||||
section.classList.add('hide-completely')
|
|
||||||
})
|
|
||||||
allExchangeBtns.forEach((btn) => {
|
|
||||||
btn.classList.remove('active')
|
|
||||||
})
|
|
||||||
element.classList.remove('hide-completely')
|
|
||||||
thisBtn.classList.add('active')
|
|
||||||
}
|
|
||||||
// prevents non numerical input on firefox
|
|
||||||
function preventNonNumericalInput(e) {
|
|
||||||
e = e || window.event;
|
|
||||||
let charCode = (typeof e.which == "undefined") ? e.keyCode : e.which,
|
|
||||||
charStr = String.fromCharCode(charCode);
|
|
||||||
|
|
||||||
if (!charStr.match(/([0-9]*[.])?[0-9]+/))
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
function areInputsEmpty(parent){
|
|
||||||
let allInputs = parent.querySelectorAll(".input input:not([disabled])"),
|
|
||||||
allRadios = parent.querySelectorAll("input[type='radio']"),
|
|
||||||
radioStatus, inputStatus, counter = radioGroups = 0;
|
|
||||||
if(parent.querySelector("input[name='trading_amount']"))
|
|
||||||
radioGroups++;
|
|
||||||
if(parent.querySelector("input[name='crypto']"))
|
|
||||||
radioGroups++;
|
|
||||||
if(parent.querySelector("input[name='currency']"))
|
|
||||||
radioGroups++;
|
|
||||||
inputStatus = [...allInputs].every(input => input.checkValidity())
|
|
||||||
|
|
||||||
allRadios.forEach(radio => {
|
|
||||||
if(radio.checked)
|
|
||||||
counter++;
|
|
||||||
})
|
|
||||||
if(counter === radioGroups)
|
|
||||||
radioStatus = true;
|
|
||||||
if(inputStatus && radioStatus)
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
function formValidation(formElement, e){
|
|
||||||
if(formElement.getAttribute('type') === 'number')
|
|
||||||
preventNonNumericalInput(e);
|
|
||||||
let parent = formElement.closest('.popup'),
|
|
||||||
submitBtn = parent.querySelector("button[type = 'submit']");
|
|
||||||
if(areInputsEmpty(parent))
|
|
||||||
submitBtn.disabled = false;
|
|
||||||
else{
|
|
||||||
submitBtn.disabled = true;
|
|
||||||
btnLoading(submitBtn.parentNode, 'stop')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Event delegation when clicked on exchage options
|
|
||||||
window.addEventListener('load', ()=> {
|
|
||||||
document.getElementById('switcher_body').addEventListener('click', (e) => {
|
|
||||||
if(e.target.closest('#buy_crypto_btn'))
|
|
||||||
showPopup('buy_crypto_popup')
|
|
||||||
if(e.target.closest('#sell_crypto_btn'))
|
|
||||||
showPopup('sell_crypto_popup')
|
|
||||||
if(e.target.closest('#send_crypto_btn'))
|
|
||||||
showPopup('send_crypto_popup', 'no')
|
|
||||||
if(e.target.closest('#deposit_crypto_btn'))
|
|
||||||
showPopup('deposit_crypto_popup', 'no')
|
|
||||||
if(e.target.closest('#withdraw_crypto_btn'))
|
|
||||||
showPopup('withdraw_crypto_popup')
|
|
||||||
if(e.target.closest('#deposit_cash_btn'))
|
|
||||||
showPopup('deposit_cash_popup')
|
|
||||||
if(e.target.closest('#withdraw_cash_btn'))
|
|
||||||
showPopup('withdraw_cash_popup')
|
|
||||||
})
|
|
||||||
|
|
||||||
window.addEventListener('mousedown', e => {
|
|
||||||
if(e.target.classList.contains('popup-container') && popupStack.peek().permission !== 'no'){
|
|
||||||
hidePopup()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
function checkInput(e){
|
|
||||||
if(e.target.closest('.input') || e.target.closest('.select-crypto')){
|
|
||||||
let parent = e.target.closest('.input') || e.target.closest('.select-crypto');
|
|
||||||
if(parent.classList.contains('input')){
|
|
||||||
if(parent.firstElementChild.value !== '')
|
|
||||||
parent.classList.add('animate-label')
|
|
||||||
else
|
|
||||||
parent.classList.remove('animate-label')
|
|
||||||
}
|
|
||||||
formValidation(parent.firstElementChild, e)
|
|
||||||
if(e.key === 'Enter')
|
|
||||||
parent.closest('.popup').querySelector("button[type='submit']").click();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
document.getElementById('popup-parent').addEventListener('input', (e) => {
|
|
||||||
checkInput(e);
|
|
||||||
})
|
|
||||||
document.getElementById('popup-parent').addEventListener('keyup', (e) => {
|
|
||||||
checkInput(e);
|
|
||||||
})
|
|
||||||
|
|
||||||
//Sign in behaviour
|
|
||||||
document.getElementById('sign_in_popup').addEventListener('input', (e) => {
|
|
||||||
checkInput(e);
|
|
||||||
})
|
|
||||||
document.getElementById('sign_in_popup').addEventListener('keyup', (e) => {
|
|
||||||
checkInput(e);
|
|
||||||
})
|
|
||||||
|
|
||||||
document.getElementById('refresh_market_price').addEventListener('click', () => {
|
|
||||||
btnLoading('refresh_market_price', 'start')
|
|
||||||
localbitcoinplusplus.actions.request_live_prices_from_server();
|
|
||||||
})
|
|
||||||
|
|
||||||
document.getElementById('refresh_bal').addEventListener('click', (e) => {
|
|
||||||
btnLoading('refresh_bal', 'start')
|
|
||||||
const RM_WALLET = new localbitcoinplusplus.wallets;
|
|
||||||
RM_WALLET.get_current_user_balance();
|
|
||||||
})
|
|
||||||
|
|
||||||
let notificationsContainer = document.getElementById('notification_container');
|
|
||||||
notificationsContainer.addEventListener('click', (e) => {
|
|
||||||
if(e.target.closest('.remove-notification'))
|
|
||||||
{
|
|
||||||
e.target.closest('.notification').remove()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
//call these functions inside your already created functions and provide new value as parameters
|
|
||||||
function updateMarketPrice(crypto_code, price) {
|
|
||||||
btnLoading('refresh_market_price', 'stop')
|
|
||||||
if(crypto_code=="BTC") {
|
|
||||||
document.getElementById('btc_market_price').textContent = '₹'+ price;
|
|
||||||
} else if(crypto_code=="FLO") {
|
|
||||||
document.getElementById('flo_market_price').textContent = '₹'+ price;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function sendCrypto(btn){
|
|
||||||
let parentPopup = btn.closest('.popup'),
|
|
||||||
send_crypto_type = document.querySelector("input[name='crypto']:checked").value,
|
|
||||||
utxo_addr_input = parentPopup.querySelector("input[name='senderFloId']").value,
|
|
||||||
utxo_addr_wif_input = parentPopup.querySelector("input[name='senderPrivateKey']").value,
|
|
||||||
receiver_address_input = parentPopup.querySelector("input[name='recieverFloId']").value,
|
|
||||||
receiving_crypto_amount_input = parentPopup.querySelector("input[name='amount']").value;
|
|
||||||
|
|
||||||
btnLoading(btn, 'start')
|
|
||||||
|
|
||||||
const RM_TRADE = new localbitcoinplusplus.trade();
|
|
||||||
RM_TRADE.sendMultipleInputsTransaction(
|
|
||||||
send_crypto_type,
|
|
||||||
[utxo_addr_wif_input],
|
|
||||||
receiver_address_input,
|
|
||||||
receiving_crypto_amount_input,
|
|
||||||
utxo_addr_input,
|
|
||||||
async function(res) {
|
|
||||||
console.log(res);
|
|
||||||
if (typeof res == "object") {
|
|
||||||
try {
|
|
||||||
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}`;
|
|
||||||
showMessage(msg);
|
|
||||||
notify(msg);
|
|
||||||
btnLoading(btn, 'stop')
|
|
||||||
hidePopup()
|
|
||||||
return true;
|
|
||||||
} catch (error) {
|
|
||||||
console.warn(error);
|
|
||||||
showMessage(error);
|
|
||||||
notify(error, 'error');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//show or hide element group from a group
|
|
||||||
|
|
||||||
function showElement(elem, classGroup){
|
|
||||||
let allGroups = document.querySelectorAll(`.${classGroup}`),
|
|
||||||
thisElement = elem;
|
|
||||||
if(typeof elem === 'string')
|
|
||||||
thisElement = document.getElementById(elem);
|
|
||||||
allGroups.forEach(group => {
|
|
||||||
group.classList.add('hide-completely')
|
|
||||||
})
|
|
||||||
thisElement.classList.remove('hide-completely')
|
|
||||||
}
|
|
||||||
|
|
||||||
// new displayMeesage and closeMessage functions. please remove old functions from script
|
|
||||||
|
|
||||||
let eventLog = document.getElementById("event_log");
|
|
||||||
function displayMessages() {
|
|
||||||
eventLog.classList.remove('hide')
|
|
||||||
eventLog.classList.add('no-transformations')
|
|
||||||
window.onmousedown = e => {
|
|
||||||
if(!e.target.closest('#event_log'))
|
|
||||||
closeMessage()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeMessage() {
|
|
||||||
eventLog.classList.add('hide')
|
|
||||||
eventLog.classList.remove('no-transformations')
|
|
||||||
}
|
|
||||||
|
|
||||||
//Show tips when loading screen is shown
|
|
||||||
let tips = [
|
|
||||||
'Loading Local Bitcoin Plus Plus',
|
|
||||||
'Always keep your private key safe',
|
|
||||||
`Use this software on same browser and same mobile or laptop`,
|
|
||||||
'Withdraw your assets soon after the trade'
|
|
||||||
],currentIndex = 0, tipsLength = tips.length,
|
|
||||||
tipContainer = document.getElementById('tip_container');
|
|
||||||
|
|
||||||
function changeTips(){
|
|
||||||
if(tipsLength > currentIndex)
|
|
||||||
currentIndex++
|
|
||||||
if(tipsLength === currentIndex)
|
|
||||||
currentIndex = 0
|
|
||||||
tipContainer.textContent = tips[currentIndex]
|
|
||||||
}
|
|
||||||
let defaultCurrencySelector= document.getElementById('default_currency_selector');
|
|
||||||
|
|
||||||
if(localStorage.getItem('defaultCurrency') !== null){
|
|
||||||
defaultCurrencySelector.querySelector(`input[value="${localStorage.defaultCurrency}"]`).checked = true;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
localStorage.setItem('defaultCurrency', 'INR')
|
|
||||||
}
|
|
||||||
defaultCurrencySelector.addEventListener('input', () => {
|
|
||||||
let selectedCurrency = defaultCurrencySelector.querySelector('input[type="radio"]:checked').value
|
|
||||||
localStorage.setItem('defaultCurrency', selectedCurrency)
|
|
||||||
console.log(localStorage.defaultCurrency)
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
//crypto-sha256-hmac.js
|
//crypto-sha256-hmac.js
|
||||||
@ -12024,7 +11491,6 @@
|
|||||||
|
|
||||||
/***************Change made by Abhishek*************/
|
/***************Change made by Abhishek*************/
|
||||||
const selection = this.arbiter(incumbent, contact);
|
const selection = this.arbiter(incumbent, contact);
|
||||||
//const selection = localbitcoinplusplus.kademlia.arbiter(incumbent, contact);
|
|
||||||
// if the selection is our old contact and the candidate is some new
|
// if the selection is our old contact and the candidate is some new
|
||||||
// contact, then there is nothing to do
|
// contact, then there is nothing to do
|
||||||
if (selection === incumbent && incumbent !== contact) return;
|
if (selection === incumbent && incumbent !== contact) return;
|
||||||
@ -12110,7 +11576,7 @@
|
|||||||
var LPP = {};
|
var LPP = {};
|
||||||
function BitBang() {
|
function BitBang() {
|
||||||
//SECTION: INITIALIZATION
|
//SECTION: INITIALIZATION
|
||||||
|
//let localbitcoinplusplus;
|
||||||
LPP = localbitcoinplusplus = {
|
LPP = localbitcoinplusplus = {
|
||||||
wallets: {},
|
wallets: {},
|
||||||
trade: {},
|
trade: {},
|
||||||
@ -12720,17 +12186,15 @@
|
|||||||
#!#waitTime={"normaldelay":180000, "exportdelay":300000, "syncdelay":600000, "hugedelay":1200000}
|
#!#waitTime={"normaldelay":180000, "exportdelay":300000, "syncdelay":600000, "hugedelay":1200000}
|
||||||
#!#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=0315C3A20FE7096CC2E0F81A80D5F1A687B8F9EFA65242A0B0881E1BA3EE7D7D53,
|
#!#supernodesPubKeys=026FCC6CFF6EB3A39E54BEB6E13FC2F02C3A93F4767AA80E49E7E876443F95AE5F,0349B08AA1ABDCFFB6D78CD7C949665AD2FF065EA02B3C6C47A5E9592C9A1C6BCB
|
||||||
026FCC6CFF6EB3A39E54BEB6E13FC2F02C3A93F4767AA80E49E7E876443F95AE5F,039B4AA00DBFC0A6631DE6DA83526611A0E6B857D3579DF840BBDEAE8B6898E3B6,
|
|
||||||
0349B08AA1ABDCFFB6D78CD7C949665AD2FF065EA02B3C6C47A5E9592C9A1C6BCB
|
|
||||||
#!#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={"ranchimall1":{"ip":"127.0.0.1:9111","kbucketId":"oZxHcbSf1JC8t5GjutopWYXs7C6Fe9p7ps"},
|
#!#ShamirsMaxShares=8#!#supernodeSeeds={
|
||||||
"ranchimall3":{"ip":"127.0.0.1:9113","kbucketId":"odYA6KagmbokSh9GY7yAfeTUZRtZLwecY1"},
|
|
||||||
"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);
|
||||||
|
|
||||||
return callback(text);
|
return callback(text);
|
||||||
|
|
||||||
let master_data = '';
|
let master_data = '';
|
||||||
@ -15552,8 +15016,6 @@
|
|||||||
// SECTION: Wallet Operations (Generate, Sign and Verify)
|
// SECTION: Wallet Operations (Generate, Sign and Verify)
|
||||||
var wallets = (localbitcoinplusplus.wallets = function (wallets) { });
|
var wallets = (localbitcoinplusplus.wallets = function (wallets) { });
|
||||||
|
|
||||||
const MY_PRIVATE_KEY_SHAMIRS_SHARES = (localbitcoinplusplus.wallets.private_key_shamirs_secrets_shares = []);
|
|
||||||
|
|
||||||
wallets.prototype = {
|
wallets.prototype = {
|
||||||
ecparams: EllipticCurve.getSECCurveByName("secp256k1"),
|
ecparams: EllipticCurve.getSECCurveByName("secp256k1"),
|
||||||
generateFloKeys: function (pk, crypto = localbitcoinplusplus.BASE_BLOCKCHAIN) {
|
generateFloKeys: function (pk, crypto = localbitcoinplusplus.BASE_BLOCKCHAIN) {
|
||||||
@ -15746,7 +15208,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
rebuild_my_private_key: function (transactionKey) {
|
rebuild_my_private_key: function (transactionKey, MY_PRIVATE_KEY_SHAMIRS_SHARES) {
|
||||||
const RM_WALLET = new localbitcoinplusplus.wallets();
|
const RM_WALLET = new localbitcoinplusplus.wallets();
|
||||||
let my_pvt_key = RM_WALLET.rebuild_private_key(
|
let my_pvt_key = RM_WALLET.rebuild_private_key(
|
||||||
MY_PRIVATE_KEY_SHAMIRS_SHARES,
|
MY_PRIVATE_KEY_SHAMIRS_SHARES,
|
||||||
@ -15862,38 +15324,26 @@
|
|||||||
) {
|
) {
|
||||||
// Add suprnode's own private keys to DB
|
// Add suprnode's own private keys to DB
|
||||||
let supernode_transaction_key = Crypto.util.randomBytes(64);
|
let supernode_transaction_key = Crypto.util.randomBytes(64);
|
||||||
let pvt_key_shamirs_secret_shares_array = pvt_key_shamirs_secret_shares.map(
|
pvt_key_shamirs_secret_shares.map(
|
||||||
chunks => {
|
chunks => {
|
||||||
let chunk_ids = Crypto.util.bytesToHex(
|
let chunk_ids = Crypto.util.bytesToHex(
|
||||||
Crypto.util.randomBytes(64)
|
Crypto.util.randomBytes(64)
|
||||||
);
|
);
|
||||||
let chunk_array = {
|
try {
|
||||||
|
addDB("my_supernode_private_key_chunks", {
|
||||||
id: chunk_ids,
|
id: chunk_ids,
|
||||||
|
supernode_transaction_key: supernode_transaction_key,
|
||||||
privateKeyChunks: Crypto.AES.encrypt(
|
privateKeyChunks: Crypto.AES.encrypt(
|
||||||
chunks,
|
chunks,
|
||||||
supernode_transaction_key
|
supernode_transaction_key
|
||||||
)
|
)
|
||||||
};
|
|
||||||
try {
|
|
||||||
addDB("my_supernode_private_key_chunks", {
|
|
||||||
id: chunk_ids,
|
|
||||||
supernode_transaction_key: supernode_transaction_key
|
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
return chunk_array;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Send chunks of private keys to other supernodes
|
|
||||||
pvt_key_shamirs_secret_shares_array.map(shares => {
|
|
||||||
const RM_RPC = new localbitcoinplusplus.rpc();
|
|
||||||
RM_RPC.send_rpc
|
|
||||||
.call(this, "store_shamirs_secret_pvtkey_shares", shares)
|
|
||||||
.then(store_pvtkey_req => doSend(store_pvtkey_req));
|
|
||||||
});
|
|
||||||
|
|
||||||
return Promise.resolve(true);
|
return Promise.resolve(true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -20658,14 +20108,13 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
// This function should be run periodically maybe through cron job
|
// This function should be run periodically maybe through cron job
|
||||||
update_fiat_to_crypto_exchange_rate(crypto_code = "", fiat = "") {
|
async update_fiat_to_crypto_exchange_rate(crypto_code = "", fiat = "") {
|
||||||
if (crypto_code == "BTC_TEST") {
|
if (crypto_code == "BTC_TEST") {
|
||||||
crypto_code = "BTC";
|
crypto_code = "BTC";
|
||||||
} else if (crypto_code == "FLO_TEST") {
|
} else if (crypto_code == "FLO_TEST") {
|
||||||
crypto_code = "FLO";
|
crypto_code = "FLO";
|
||||||
}
|
}
|
||||||
this.fiat_to_crypto_exchange_rate_from_API(crypto_code, fiat)
|
const new_price = await this.fiat_to_crypto_exchange_rate_from_API(crypto_code, fiat)
|
||||||
.then(new_price => {
|
|
||||||
console.log(new_price);
|
console.log(new_price);
|
||||||
if (typeof new_price == "number") {
|
if (typeof new_price == "number") {
|
||||||
let rate_obj = {
|
let rate_obj = {
|
||||||
@ -20706,10 +20155,7 @@
|
|||||||
`ERROR: Failed to get valid response while fetching ${crypto_code}<=>${fiat} rate.`
|
`ERROR: Failed to get valid response while fetching ${crypto_code}<=>${fiat} rate.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.catch(e => {
|
|
||||||
console.error(e);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
fiat_to_crypto_exchange_rate_from_API(crypto_code = "", fiat = "") {
|
fiat_to_crypto_exchange_rate_from_API(crypto_code = "", fiat = "") {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -22642,7 +22088,7 @@
|
|||||||
return my_closest_su_url == ws_url;
|
return my_closest_su_url == ws_url;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if (typeof disconnected_su[0].trader_flo_address == "string") {
|
if (disconnected_su.length>0 && typeof disconnected_su[0].trader_flo_address == "string") {
|
||||||
return Promise.resolve(disconnected_su[0].trader_flo_address);
|
return Promise.resolve(disconnected_su[0].trader_flo_address);
|
||||||
} else {
|
} else {
|
||||||
return Promise.reject(false);
|
return Promise.reject(false);
|
||||||
@ -23128,8 +22574,6 @@
|
|||||||
"sync_primary_supernode_from_backup_supernode_response",
|
"sync_primary_supernode_from_backup_supernode_response",
|
||||||
"supernode_message",
|
"supernode_message",
|
||||||
"store_shamirs_secret_pvtkey_shares",
|
"store_shamirs_secret_pvtkey_shares",
|
||||||
"send_back_shamirs_secret_supernode_pvtkey",
|
|
||||||
"retrieve_shamirs_secret_supernode_pvtkey",
|
|
||||||
"send_back_shamirs_secret_btc_pvtkey",
|
"send_back_shamirs_secret_btc_pvtkey",
|
||||||
"retrieve_shamirs_secret_btc_pvtkey",
|
"retrieve_shamirs_secret_btc_pvtkey",
|
||||||
"add_user_public_data",
|
"add_user_public_data",
|
||||||
@ -23612,83 +23056,7 @@
|
|||||||
addDB("supernode_private_key_chunks", res_obj.params[0]);
|
addDB("supernode_private_key_chunks", res_obj.params[0]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "send_back_shamirs_secret_supernode_pvtkey":
|
|
||||||
if (
|
|
||||||
typeof res_obj.params == "object" &&
|
|
||||||
typeof res_obj.params[0] == "object"
|
|
||||||
) {
|
|
||||||
readDB(
|
|
||||||
"supernode_private_key_chunks",
|
|
||||||
res_obj.params[0].chunk_val
|
|
||||||
).then(function (res) {
|
|
||||||
if (typeof res == "object") {
|
|
||||||
RM_RPC.send_rpc
|
|
||||||
.call(
|
|
||||||
this,
|
|
||||||
"retrieve_shamirs_secret_supernode_pvtkey",
|
|
||||||
{
|
|
||||||
private_key_chunk: res
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.then(send_pvtkey_req => doSend(send_pvtkey_req));
|
|
||||||
} else {
|
|
||||||
RM_RPC.send_rpc
|
|
||||||
.call(
|
|
||||||
this,
|
|
||||||
"retrieve_shamirs_secret_supernode_pvtkey",
|
|
||||||
""
|
|
||||||
)
|
|
||||||
.then(send_pvtkey_req => doSend(send_pvtkey_req));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "retrieve_shamirs_secret_supernode_pvtkey":
|
|
||||||
if (typeof retrieve_pvtkey_counter == "undefined")
|
|
||||||
retrieve_pvtkey_counter = 0;
|
|
||||||
let runUIFunc = false;
|
|
||||||
if (
|
|
||||||
typeof res_obj.params == "object" &&
|
|
||||||
typeof res_obj.params[0] == "object" &&
|
|
||||||
typeof res_obj.params[0].private_key_chunk == "object" &&
|
|
||||||
typeof localbitcoinplusplus.wallets
|
|
||||||
.supernode_transaction_key == "object"
|
|
||||||
) {
|
|
||||||
let share =
|
|
||||||
res_obj.params[0].private_key_chunk.privateKeyChunks;
|
|
||||||
if (
|
|
||||||
typeof share !== "undefined" &&
|
|
||||||
!MY_PRIVATE_KEY_SHAMIRS_SHARES.includes(share)
|
|
||||||
) {
|
|
||||||
MY_PRIVATE_KEY_SHAMIRS_SHARES.push(share);
|
|
||||||
}
|
|
||||||
if (MY_PRIVATE_KEY_SHAMIRS_SHARES.length == 5) {
|
|
||||||
RM_WALLET.rebuild_my_private_key(
|
|
||||||
localbitcoinplusplus.wallets.supernode_transaction_key
|
|
||||||
);
|
|
||||||
runUIFunc = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (
|
|
||||||
retrieve_pvtkey_counter == 10 &&
|
|
||||||
typeof localbitcoinplusplus.wallets
|
|
||||||
.MY_SUPERNODE_PRIVATE_KEY == "undefined"
|
|
||||||
) {
|
|
||||||
RM_WALLET.manually_assign_my_private_key();
|
|
||||||
runUIFunc = true;
|
|
||||||
retrieve_pvtkey_counter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
typeof localbitcoinplusplus.wallets
|
|
||||||
.MY_SUPERNODE_PRIVATE_KEY == "string" &&
|
|
||||||
localbitcoinplusplus.is_ui_loaded == false
|
|
||||||
) {
|
|
||||||
dataBaseUIOperations();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
retrieve_pvtkey_counter++;
|
|
||||||
break;
|
|
||||||
case "send_back_shamirs_secret_btc_pvtkey":
|
case "send_back_shamirs_secret_btc_pvtkey":
|
||||||
if (
|
if (
|
||||||
typeof res_obj.params == "object" &&
|
typeof res_obj.params == "object" &&
|
||||||
@ -24836,9 +24204,7 @@
|
|||||||
res_obj.method !== "link_My_Local_IP_To_My_Flo_Id" &&
|
res_obj.method !== "link_My_Local_IP_To_My_Flo_Id" &&
|
||||||
res_obj.method !== "link_Others_Local_IP_To_Their_Flo_Id" &&
|
res_obj.method !== "link_Others_Local_IP_To_Their_Flo_Id" &&
|
||||||
res_obj.method !== "send_back_shamirs_secret_btc_pvtkey" &&
|
res_obj.method !== "send_back_shamirs_secret_btc_pvtkey" &&
|
||||||
res_obj.method !== "send_back_shamirs_secret_supernode_pvtkey" &&
|
res_obj.method !== "store_shamirs_secret_pvtkey_shares"
|
||||||
res_obj.method !== "store_shamirs_secret_pvtkey_shares" &&
|
|
||||||
res_obj.method !== "retrieve_shamirs_secret_supernode_pvtkey"
|
|
||||||
) {
|
) {
|
||||||
if (
|
if (
|
||||||
localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(
|
localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(
|
||||||
@ -24881,8 +24247,6 @@
|
|||||||
"sync_primary_supernode_from_backup_supernode_response",
|
"sync_primary_supernode_from_backup_supernode_response",
|
||||||
"supernode_message",
|
"supernode_message",
|
||||||
"store_shamirs_secret_pvtkey_shares",
|
"store_shamirs_secret_pvtkey_shares",
|
||||||
"send_back_shamirs_secret_supernode_pvtkey",
|
|
||||||
"retrieve_shamirs_secret_supernode_pvtkey",
|
|
||||||
"send_back_shamirs_secret_btc_pvtkey",
|
"send_back_shamirs_secret_btc_pvtkey",
|
||||||
"retrieve_shamirs_secret_btc_pvtkey",
|
"retrieve_shamirs_secret_btc_pvtkey",
|
||||||
"add_user_public_data",
|
"add_user_public_data",
|
||||||
@ -25432,117 +24796,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "send_back_shamirs_secret_supernode_pvtkey":
|
|
||||||
if (
|
|
||||||
typeof res_obj.params == "object" &&
|
|
||||||
typeof res_obj.params[0] == "object" &&
|
|
||||||
localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(
|
|
||||||
localbitcoinplusplus.wallets.my_local_flo_public_key
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
if (
|
|
||||||
typeof res_obj.globalParams.primarySupernode != "string"
|
|
||||||
)
|
|
||||||
return;
|
|
||||||
localbitcoinplusplus.kademlia
|
|
||||||
.determineClosestSupernode(
|
|
||||||
res_obj.globalParams.primarySupernode
|
|
||||||
)
|
|
||||||
.then(my_closest_su_list => {
|
|
||||||
console.log(my_closest_su_list);
|
|
||||||
|
|
||||||
const primarySupernodeOfThisUser =
|
|
||||||
my_closest_su_list[0].data.id;
|
|
||||||
const backup_server_db_instance =
|
|
||||||
localbitcoinplusplus.newBackupDatabase.db[
|
|
||||||
primarySupernodeOfThisUser
|
|
||||||
];
|
|
||||||
|
|
||||||
if (typeof backup_server_db_instance !== "object") {
|
|
||||||
let backup_db_error_msg = `WARNING: Unknown DB instance. DB Backup failed.`;
|
|
||||||
showMessage(backup_db_error_msg);
|
|
||||||
throw new Error(backup_db_error_msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
backup_server_db_instance
|
|
||||||
.backup_readDB(
|
|
||||||
"supernode_private_key_chunks",
|
|
||||||
res_obj.params[0].chunk_val
|
|
||||||
)
|
|
||||||
.then(function (res) {
|
|
||||||
if (typeof res == "object") {
|
|
||||||
RM_RPC.send_rpc
|
|
||||||
.call(
|
|
||||||
this,
|
|
||||||
"retrieve_shamirs_secret_supernode_pvtkey",
|
|
||||||
{
|
|
||||||
private_key_chunk: res
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.then(send_pvtkey_req =>
|
|
||||||
doSend(send_pvtkey_req)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
RM_RPC.send_rpc
|
|
||||||
.call(
|
|
||||||
this,
|
|
||||||
"retrieve_shamirs_secret_supernode_pvtkey",
|
|
||||||
""
|
|
||||||
)
|
|
||||||
.then(send_pvtkey_req =>
|
|
||||||
doSend(send_pvtkey_req)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "retrieve_shamirs_secret_supernode_pvtkey":
|
|
||||||
if (typeof retrieve_pvtkey_counter == "undefined")
|
|
||||||
retrieve_pvtkey_counter = 0;
|
|
||||||
let runUIFunc = false;
|
|
||||||
if (
|
|
||||||
typeof res_obj.params == "object" &&
|
|
||||||
typeof res_obj.params[0] == "object" &&
|
|
||||||
typeof res_obj.params[0].private_key_chunk == "object" &&
|
|
||||||
typeof localbitcoinplusplus.wallets
|
|
||||||
.supernode_transaction_key == "object"
|
|
||||||
) {
|
|
||||||
let share =
|
|
||||||
res_obj.params[0].private_key_chunk.privateKeyChunks;
|
|
||||||
if (
|
|
||||||
typeof share !== "undefined" &&
|
|
||||||
!MY_PRIVATE_KEY_SHAMIRS_SHARES.includes(share)
|
|
||||||
) {
|
|
||||||
MY_PRIVATE_KEY_SHAMIRS_SHARES.push(share);
|
|
||||||
}
|
|
||||||
if (MY_PRIVATE_KEY_SHAMIRS_SHARES.length == 5) {
|
|
||||||
RM_WALLET.rebuild_my_private_key(
|
|
||||||
localbitcoinplusplus.wallets.supernode_transaction_key
|
|
||||||
);
|
|
||||||
runUIFunc = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (
|
|
||||||
retrieve_pvtkey_counter == 10 &&
|
|
||||||
typeof localbitcoinplusplus.wallets
|
|
||||||
.MY_SUPERNODE_PRIVATE_KEY == "undefined"
|
|
||||||
) {
|
|
||||||
RM_WALLET.manually_assign_my_private_key();
|
|
||||||
runUIFunc = true;
|
|
||||||
retrieve_pvtkey_counter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
typeof localbitcoinplusplus.wallets
|
|
||||||
.MY_SUPERNODE_PRIVATE_KEY == "string" &&
|
|
||||||
localbitcoinplusplus.is_ui_loaded == false
|
|
||||||
) {
|
|
||||||
dataBaseUIOperations();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
retrieve_pvtkey_counter++;
|
|
||||||
break;
|
|
||||||
case "send_back_shamirs_secret_btc_pvtkey":
|
case "send_back_shamirs_secret_btc_pvtkey":
|
||||||
if (
|
if (
|
||||||
typeof res_obj.params == "object" &&
|
typeof res_obj.params == "object" &&
|
||||||
@ -28582,8 +27836,6 @@
|
|||||||
|
|
||||||
function doSend(message, user_flo_id = "") {
|
function doSend(message, user_flo_id = "") {
|
||||||
const request_array = [
|
const request_array = [
|
||||||
"send_back_shamirs_secret_supernode_pvtkey",
|
|
||||||
"retrieve_shamirs_secret_supernode_pvtkey",
|
|
||||||
"store_shamirs_secret_pvtkey_shares",
|
"store_shamirs_secret_pvtkey_shares",
|
||||||
"request_me_db_data"
|
"request_me_db_data"
|
||||||
];
|
];
|
||||||
@ -28687,8 +27939,6 @@
|
|||||||
reject(false);
|
reject(false);
|
||||||
}
|
}
|
||||||
const request_array = [
|
const request_array = [
|
||||||
"send_back_shamirs_secret_supernode_pvtkey",
|
|
||||||
"retrieve_shamirs_secret_supernode_pvtkey",
|
|
||||||
"store_shamirs_secret_pvtkey_shares",
|
"store_shamirs_secret_pvtkey_shares",
|
||||||
"request_me_db_data"
|
"request_me_db_data"
|
||||||
];
|
];
|
||||||
@ -30230,29 +29480,20 @@
|
|||||||
const chunks = await readAllDB("my_supernode_private_key_chunks");
|
const chunks = await readAllDB("my_supernode_private_key_chunks");
|
||||||
if (typeof chunks == "object" && chunks.length > 0) {
|
if (typeof chunks == "object" && chunks.length > 0) {
|
||||||
const RM_RPC = new localbitcoinplusplus.rpc();
|
const RM_RPC = new localbitcoinplusplus.rpc();
|
||||||
let txKey = chunks.map(async (chunk, indexx) => {
|
const RM_WALLET = new localbitcoinplusplus.wallets();
|
||||||
if (indexx == chunks.length - 1) {
|
let MY_PRIVATE_KEY_SHAMIRS_SHARES = chunks
|
||||||
supernode_transaction_key_arr.push(
|
.map(chunk =>chunk.privateKeyChunks);
|
||||||
chunk.supernode_transaction_key
|
|
||||||
);
|
const txKey = chunks[0].supernode_transaction_key;
|
||||||
return supernode_transaction_key_arr;
|
|
||||||
|
if (MY_PRIVATE_KEY_SHAMIRS_SHARES.length>0) {
|
||||||
|
RM_WALLET.rebuild_my_private_key(txKey, MY_PRIVATE_KEY_SHAMIRS_SHARES);
|
||||||
}
|
}
|
||||||
|
|
||||||
let retrieve_pvtkey_req = await RM_RPC;
|
|
||||||
RM_RPC.send_rpc
|
|
||||||
.call(this, "send_back_shamirs_secret_supernode_pvtkey", {
|
|
||||||
chunk_val: chunk.id
|
|
||||||
})
|
|
||||||
.then(retrieve_pvtkey_req => doSend(retrieve_pvtkey_req));
|
|
||||||
});
|
|
||||||
|
|
||||||
txKey[chunks.length - 1].then(txk => {
|
|
||||||
const TRANSACTION_KEY = (localbitcoinplusplus.wallets.supernode_transaction_key =
|
|
||||||
txk[0]);
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
const RM_WALLET = new localbitcoinplusplus.wallets();
|
const RM_WALLET = new localbitcoinplusplus.wallets();
|
||||||
await RM_WALLET.manually_assign_my_private_key();
|
await RM_WALLET.manually_assign_my_private_key();
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
typeof localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY ==
|
typeof localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY ==
|
||||||
"string" &&
|
"string" &&
|
||||||
@ -30260,7 +29501,6 @@
|
|||||||
) {
|
) {
|
||||||
dataBaseUIOperations();
|
dataBaseUIOperations();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
resolve(true);
|
resolve(true);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -30427,10 +29667,6 @@
|
|||||||
asset1,
|
asset1,
|
||||||
asset2
|
asset2
|
||||||
);
|
);
|
||||||
await RM_TRADE.resolve_current_crypto_price_in_fiat(
|
|
||||||
asset1,
|
|
||||||
asset2
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user