fixed errors during first sign in
This commit is contained in:
parent
3141ab6b77
commit
b726e7144e
288
index.html
288
index.html
@ -12613,10 +12613,11 @@
|
|||||||
#!#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=0315C3A20FE7096CC2E0F81A80D5F1A687B8F9EFA65242A0B0881E1BA3EE7D7D53,
|
||||||
026FCC6CFF6EB3A39E54BEB6E13FC2F02C3A93F4767AA80E49E7E876443F95AE5F,
|
026FCC6CFF6EB3A39E54BEB6E13FC2F02C3A93F4767AA80E49E7E876443F95AE5F,039B4AA00DBFC0A6631DE6DA83526611A0E6B857D3579DF840BBDEAE8B6898E3B6
|
||||||
#!#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={"ranchimall1":{"ip":"127.0.0.1:9111","kbucketId":"oZxHcbSf1JC8t5GjutopWYXs7C6Fe9p7ps"},
|
||||||
|
"ranchimall3":{"ip":"127.0.0.1:9113","kbucketId":"odYA6KagmbokSh9GY7yAfeTUZRtZLwecY1"},
|
||||||
"ranchimall6":{"ip":"127.0.0.1:9116","kbucketId":"oV1wCeWca3VawbBTfUGKA7Vd368PATnKAx"}}`;
|
"ranchimall6":{"ip":"127.0.0.1:9116","kbucketId":"oV1wCeWca3VawbBTfUGKA7Vd368PATnKAx"}}`;
|
||||||
return callback(text);
|
return callback(text);
|
||||||
|
|
||||||
@ -15601,16 +15602,6 @@
|
|||||||
notify('Signed in successfully.')
|
notify('Signed in successfully.')
|
||||||
document.querySelector('main').classList.remove('hide-completely')
|
document.querySelector('main').classList.remove('hide-completely')
|
||||||
hidePopup('sign_in_popup');
|
hidePopup('sign_in_popup');
|
||||||
if (localbitcoinplusplus.is_ui_loaded == false) {
|
|
||||||
dataBaseUIOperations();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Private key is built. Now execute private key dependent functions
|
|
||||||
const pubkey = gen_new_keys.pubKeyHex;
|
|
||||||
if (localbitcoinplusplus.master_configurations.supernodesPubKeys
|
|
||||||
.includes(pubkey)) {
|
|
||||||
reactor.dispatchEvent("user_flo_keys_active", pubkey);
|
|
||||||
}
|
|
||||||
|
|
||||||
return resolve(gen_new_keys.privateKeyWIF);
|
return resolve(gen_new_keys.privateKeyWIF);
|
||||||
}
|
}
|
||||||
@ -15659,12 +15650,6 @@
|
|||||||
configurable: false,
|
configurable: false,
|
||||||
enumerable: false
|
enumerable: false
|
||||||
});
|
});
|
||||||
|
|
||||||
// Private key is built. Now execute private key dependent functions
|
|
||||||
if(localbitcoinplusplus.master_configurations.supernodesPubKeys
|
|
||||||
.includes(localbitcoinplusplus.wallets.my_local_flo_public_key)) {
|
|
||||||
reactor.dispatchEvent("user_flo_keys_active", localbitcoinplusplus.wallets.my_local_flo_public_key);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
rebuild_private_key: function(
|
rebuild_private_key: function(
|
||||||
private_key_shamirs_shares,
|
private_key_shamirs_shares,
|
||||||
@ -21728,235 +21713,127 @@
|
|||||||
|
|
||||||
var output;
|
var output;
|
||||||
|
|
||||||
function kickInit() {
|
async function kickInit() {
|
||||||
const RM_WALLET = new localbitcoinplusplus.wallets();
|
const RM_WALLET = new localbitcoinplusplus.wallets();
|
||||||
const BACKUP_DB = (localbitcoinplusplus.newBackupDatabase.db = []);
|
const BACKUP_DB = (localbitcoinplusplus.newBackupDatabase.db = []);
|
||||||
const backUpSupernodesWS = (localbitcoinplusplus.backupWS = []);
|
const backUpSupernodesWS = (localbitcoinplusplus.backupWS = []);
|
||||||
return new Promise(resolve => {
|
let user_priv_key = '';
|
||||||
readDB("localbitcoinUser", "00-01").then(async function(idbData) {
|
let idbData = await readDB("localbitcoinUser", "00-01");
|
||||||
if (
|
if (
|
||||||
typeof idbData !== "object" ||
|
typeof idbData !== "object" ||
|
||||||
typeof idbData.myLocalFLOPublicKey == "undefined" ||
|
typeof idbData.myLocalFLOPublicKey == "undefined" ||
|
||||||
idbData.myLocalFLOPublicKey.trim() == ""
|
idbData.myLocalFLOPublicKey.trim() == ""
|
||||||
) {
|
) {
|
||||||
let user_pvt_key = await RM_WALLET.manually_assign_my_private_key();
|
let user_pvt_key = await RM_WALLET.manually_assign_my_private_key();
|
||||||
|
|
||||||
if (user_pvt_key.trim() == "" || user_pvt_key.length < 1)
|
if (user_pvt_key.trim() == "" || user_pvt_key.length < 1)
|
||||||
user_pvt_key = null;
|
user_pvt_key = null;
|
||||||
|
|
||||||
let newKeys = RM_WALLET.generateFloKeys(user_pvt_key);
|
let newKeys = RM_WALLET.generateFloKeys(user_pvt_key);
|
||||||
if (
|
|
||||||
typeof newKeys == "object" &&
|
|
||||||
newKeys.privateKeyWIF.length > 0 &&
|
|
||||||
newKeys.address.length > 0
|
|
||||||
) {
|
|
||||||
localbitcoinplusplusObj.myLocalFLOAddress = newKeys.address;
|
|
||||||
localbitcoinplusplusObj.myLocalFLOPublicKey = newKeys.pubKeyHex;
|
|
||||||
localbitcoinplusplusObj.lastConnectedTime = +new Date();
|
|
||||||
|
|
||||||
await updateinDB("localbitcoinUser", localbitcoinplusplusObj);
|
|
||||||
|
|
||||||
// launch KBuckets
|
|
||||||
launchKBuckects = await localbitcoinplusplus.kademlia.launchKBucket(
|
|
||||||
newKeys.address
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!launchKBuckects) {
|
|
||||||
const kmsg = `ERROR: Failed to build KBuckets. System cannot proceed further.`;
|
|
||||||
showMessage(kmsg);
|
|
||||||
throw new Error(kmsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
await localbitcoinplusplus.kademlia.restoreSupernodeKBucket();
|
|
||||||
|
|
||||||
wsUri = await localbitcoinplusplus.kademlia.getSupernodeSeed(
|
|
||||||
localbitcoinplusplusObj.myLocalFLOAddress
|
|
||||||
);
|
|
||||||
|
|
||||||
// Add close supernodes to KBucket
|
|
||||||
wsUri.map(d => {
|
|
||||||
localbitcoinplusplus.kademlia.addNewUserNodeInKbucket(
|
|
||||||
localbitcoinplusplus.BASE_BLOCKCHAIN,
|
|
||||||
d.trader_flo_address,
|
|
||||||
{ id: d.trader_flo_address }
|
|
||||||
);
|
|
||||||
showMessage(
|
|
||||||
`INFO: Added Supernode Id ${d.trader_flo_address} to KBucket.`
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
await startWebSocket(`${WS}://${wsUri[0].ip}`);
|
|
||||||
|
|
||||||
RM_WALLET.distributeShamirsSecretShares(newKeys.privateKeyWIF)
|
|
||||||
.then(() => privateKeyBuilder())
|
|
||||||
.finally(() => {
|
|
||||||
setTimeout(async function() {
|
|
||||||
if (
|
|
||||||
typeof localbitcoinplusplus.wallets
|
|
||||||
.MY_SUPERNODE_PRIVATE_KEY !== "string" ||
|
|
||||||
localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY
|
|
||||||
.length < 1
|
|
||||||
) {
|
|
||||||
await RM_WALLET.manually_assign_my_private_key();
|
|
||||||
} else if (
|
|
||||||
typeof localbitcoinplusplus.wallets
|
|
||||||
.MY_SUPERNODE_PRIVATE_KEY == "string" &&
|
|
||||||
localbitcoinplusplus.is_ui_loaded == false
|
|
||||||
) {
|
|
||||||
dataBaseUIOperations();
|
|
||||||
}
|
|
||||||
clearTimeout();
|
|
||||||
}, 10000);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Connect with backup supernodes
|
|
||||||
if (
|
if (
|
||||||
localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(
|
typeof newKeys == "object" &&
|
||||||
idbData.myLocalFLOPublicKey
|
newKeys.privateKeyWIF.length > 0 &&
|
||||||
)
|
newKeys.address.length > 0
|
||||||
) {
|
) {
|
||||||
|
localbitcoinplusplusObj.myLocalFLOAddress = newKeys.address;
|
||||||
|
localbitcoinplusplusObj.myLocalFLOPublicKey = newKeys.pubKeyHex;
|
||||||
|
localbitcoinplusplusObj.lastConnectedTime = +new Date();
|
||||||
|
|
||||||
wsUri.map((uri, index) => {
|
idbData = await updateinDB("localbitcoinUser", localbitcoinplusplusObj);
|
||||||
// Do not serve to any requests unless data is fully synced.
|
user_priv_key = newKeys.privateKeyWIF;
|
||||||
// localbitcoinplusplus.services[
|
|
||||||
// `can_serve_${uri.trader_flo_address}`
|
} else {
|
||||||
// ] = false;
|
err_msg = "Failed to generate new FLO keys. Please retry.";
|
||||||
|
showMessage(err_msg);
|
||||||
if (index > 0) {
|
throw new Error(err_msg);
|
||||||
let dbname = `su_backup_${uri.trader_flo_address}`;
|
|
||||||
BACKUP_DB[uri.trader_flo_address] = new newBackupDB(
|
|
||||||
dbname
|
|
||||||
);
|
|
||||||
BACKUP_DB[uri.trader_flo_address].createNewDB();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
localbitcoinplusplus.MY_SUPERNODE_FLO_ADDRESS =
|
|
||||||
wsUri[0].trader_flo_address;
|
|
||||||
|
|
||||||
resolve(true);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
err_msg = "Failed to generate new FLO keys. Please retry.";
|
|
||||||
showMessage(err_msg);
|
|
||||||
throw new Error(err_msg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// launch KBucekts
|
// launch KBucekts
|
||||||
launchKBuckects = await localbitcoinplusplus.kademlia.launchKBucket(
|
launchKBuckects = await localbitcoinplusplus.kademlia.launchKBucket(
|
||||||
idbData.myLocalFLOAddress
|
idbData.myLocalFLOAddress
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!launchKBuckects) {
|
if (!launchKBuckects) {
|
||||||
const kmsg = `ERROR: Failed to build KBuckets. System cannot proceed further.`;
|
const kmsg = `ERROR: Failed to build KBuckets. System cannot proceed further.`;
|
||||||
showMessage(kmsg);
|
showMessage(kmsg);
|
||||||
throw new Error(kmsg);
|
throw new Error(kmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
await localbitcoinplusplus.kademlia.restoreSupernodeKBucket();
|
await localbitcoinplusplus.kademlia.restoreSupernodeKBucket();
|
||||||
|
|
||||||
wsUri = await localbitcoinplusplus.kademlia.getSupernodeSeed(
|
wsUri = await localbitcoinplusplus.kademlia.getSupernodeSeed(
|
||||||
idbData.myLocalFLOAddress
|
idbData.myLocalFLOAddress
|
||||||
);
|
);
|
||||||
|
|
||||||
const getClosestSuList = await readAllDB("myClosestSupernodes");
|
const getClosestSuList = await readAllDB("myClosestSupernodes");
|
||||||
|
console.log("getClosestSuList", getClosestSuList);
|
||||||
|
|
||||||
reactor.dispatchEvent("createClosestSupernodesObject", getClosestSuList);
|
reactor.dispatchEvent("createClosestSupernodesObject", getClosestSuList);
|
||||||
reactor.dispatchEvent("createCashierStatusObject", getClosestSuList);
|
reactor.dispatchEvent("createCashierStatusObject", getClosestSuList);
|
||||||
|
|
||||||
if (
|
|
||||||
localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(
|
|
||||||
idbData.myLocalFLOPublicKey
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
if (
|
|
||||||
getClosestSuList.length <
|
|
||||||
localbitcoinplusplus.master_configurations.supernodesPubKeys
|
|
||||||
) {
|
|
||||||
showMessage(
|
|
||||||
`INFO: Invalid connection. Refreshing the closest supernode list in DB.`
|
|
||||||
);
|
|
||||||
|
|
||||||
wsUri = await localbitcoinplusplus.kademlia.updateClosestSupernodeSeeds(
|
|
||||||
idbData.myLocalFLOAddress
|
|
||||||
);
|
|
||||||
|
|
||||||
// Reconfigure ws conns
|
|
||||||
reactor.dispatchEvent('resolve_backup_ws_connections');
|
|
||||||
|
|
||||||
// Possible entry of new Supernode. Export data of users
|
|
||||||
localbitcoinplusplus.actions.exportUserDataFromOneSupernodeToAnother(idbData.myLocalFLOAddress);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add close supernodes to KBucket
|
// Add close supernodes to KBucket
|
||||||
wsUri.map(d => {
|
wsUri.map(d => {
|
||||||
localbitcoinplusplus.kademlia.addNewUserNodeInKbucket(
|
localbitcoinplusplus.kademlia.addNewUserNodeInKbucket(
|
||||||
localbitcoinplusplus.BASE_BLOCKCHAIN,
|
localbitcoinplusplus.BASE_BLOCKCHAIN,
|
||||||
d.trader_flo_address,
|
d.trader_flo_address,
|
||||||
{ id: d.trader_flo_address }
|
{ id: d.trader_flo_address }
|
||||||
);
|
);
|
||||||
showMessage(
|
showMessage(
|
||||||
`INFO: Added Supernode Id ${d.trader_flo_address} to KBucket.`
|
`INFO: Added Supernode Id ${d.trader_flo_address} to KBucket.`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Connect with primary supernodes
|
// Connect with primary supernodes
|
||||||
await startWebSocket(`${WS}://${wsUri[0].ip}`);
|
await startWebSocket(`${WS}://${wsUri[0].ip}`);
|
||||||
|
|
||||||
|
if(user_priv_key.length>0) {
|
||||||
|
await RM_WALLET.distributeShamirsSecretShares(user_priv_key);
|
||||||
|
}
|
||||||
|
|
||||||
// rebuild private key
|
// rebuild private key
|
||||||
await privateKeyBuilder();
|
await privateKeyBuilder();
|
||||||
|
|
||||||
setTimeout(async 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
|
||||||
) {
|
) {
|
||||||
await RM_WALLET.manually_assign_my_private_key();
|
await RM_WALLET.manually_assign_my_private_key();
|
||||||
} else if (
|
}
|
||||||
typeof localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY ==
|
if (
|
||||||
"string" &&
|
typeof localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY ==
|
||||||
localbitcoinplusplus.is_ui_loaded == false
|
"string" &&
|
||||||
) {
|
localbitcoinplusplus.is_ui_loaded == false
|
||||||
dataBaseUIOperations();
|
) {
|
||||||
}
|
dataBaseUIOperations();
|
||||||
|
}
|
||||||
}, 10000);
|
}, 10000);
|
||||||
|
|
||||||
localbitcoinplusplus.MY_SUPERNODE_FLO_ADDRESS =
|
localbitcoinplusplus.MY_SUPERNODE_FLO_ADDRESS =
|
||||||
wsUri[0].trader_flo_address;
|
wsUri[0].trader_flo_address;
|
||||||
|
|
||||||
localbitcoinplusplus.services = {};
|
localbitcoinplusplus.services = {};
|
||||||
|
|
||||||
// Connect with backup supernodes
|
// Connect with backup supernodes
|
||||||
if (
|
if (
|
||||||
localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(
|
localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(
|
||||||
idbData.myLocalFLOPublicKey
|
idbData.myLocalFLOPublicKey
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
|
||||||
wsUri.map((uri, index) => {
|
wsUri.map((uri, index) => {
|
||||||
// Do not serve to any requests unless data is fully synced.
|
if (index > 0) {
|
||||||
// localbitcoinplusplus.services[
|
let dbname = `su_backup_${uri.trader_flo_address}`;
|
||||||
// `can_serve_${uri.trader_flo_address}`
|
BACKUP_DB[uri.trader_flo_address] = new newBackupDB(dbname);
|
||||||
// ] = false;
|
BACKUP_DB[uri.trader_flo_address].createNewDB();
|
||||||
|
}
|
||||||
if (index > 0) {
|
});
|
||||||
let dbname = `su_backup_${uri.trader_flo_address}`;
|
|
||||||
BACKUP_DB[uri.trader_flo_address] = new newBackupDB(dbname);
|
|
||||||
BACKUP_DB[uri.trader_flo_address].createNewDB();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(true);
|
return true;
|
||||||
});
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const backupSupernodesWebSocketObject = (localbitcoinplusplus.backupWS = function(
|
const backupSupernodesWebSocketObject = (localbitcoinplusplus.backupWS = function(
|
||||||
ws_url
|
ws_url
|
||||||
@ -29557,7 +29434,7 @@
|
|||||||
localbitcoinplusplus.master_configurations.tradableAsset1.map(
|
localbitcoinplusplus.master_configurations.tradableAsset1.map(
|
||||||
asset => bitjslib(asset)
|
asset => bitjslib(asset)
|
||||||
);
|
);
|
||||||
kickInit();
|
await kickInit();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -29659,27 +29536,14 @@
|
|||||||
const MY_LOCAL_FLO_ADDRESS = localbitcoinplusplus.wallets.my_local_flo_address;
|
const MY_LOCAL_FLO_ADDRESS = localbitcoinplusplus.wallets.my_local_flo_address;
|
||||||
const MY_LOCAL_FLO_PUBLIC_KEY = localbitcoinplusplus.wallets.my_local_flo_public_key;
|
const MY_LOCAL_FLO_PUBLIC_KEY = localbitcoinplusplus.wallets.my_local_flo_public_key;
|
||||||
|
|
||||||
// restore k-bucket
|
|
||||||
if(typeof KBucket!=="object" || KBucket==null) {
|
|
||||||
await localbitcoinplusplus.kademlia.launchKBucket(
|
|
||||||
MY_LOCAL_FLO_ADDRESS
|
|
||||||
);
|
|
||||||
}
|
|
||||||
const dbObj = await localbitcoinplusplus.kademlia.restoreKbucket(
|
|
||||||
MY_LOCAL_FLO_ADDRESS,
|
|
||||||
localbitcoinplusplus.BASE_BLOCKCHAIN,
|
|
||||||
KBucket
|
|
||||||
);
|
|
||||||
|
|
||||||
// launch supernode kbucket
|
// launch supernode kbucket
|
||||||
if (
|
if (
|
||||||
localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(
|
localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(
|
||||||
MY_LOCAL_FLO_PUBLIC_KEY
|
MY_LOCAL_FLO_PUBLIC_KEY
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
// Build Supernodes KBuckets
|
|
||||||
launchSupernodesKBuckects = await localbitcoinplusplus.kademlia.launchSupernodesKBucket();
|
|
||||||
reactor.dispatchEvent("remove_temp_data_from_db", localbitcoinplusplus.wallets.my_local_flo_address);
|
reactor.dispatchEvent("remove_temp_data_from_db", localbitcoinplusplus.wallets.my_local_flo_address);
|
||||||
|
reactor.dispatchEvent("user_flo_keys_active", localbitcoinplusplus.wallets.my_local_flo_public_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send your id to Supernode kbucket
|
// Send your id to Supernode kbucket
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user