diff --git a/index.html b/index.html
index ac4f23e..8b93387 100644
--- a/index.html
+++ b/index.html
@@ -12613,10 +12613,11 @@
#!#ordersLife={"trade":300000, "cryptoDeposit":900000, "cryptoWithdraw":300000, "cashDeposit":900000, "cashWithdraw":900000}
#!#miners_fee={"btc":0.0005, "flo":0.001}
#!#supernodesPubKeys=0315C3A20FE7096CC2E0F81A80D5F1A687B8F9EFA65242A0B0881E1BA3EE7D7D53,
- 026FCC6CFF6EB3A39E54BEB6E13FC2F02C3A93F4767AA80E49E7E876443F95AE5F,
+ 026FCC6CFF6EB3A39E54BEB6E13FC2F02C3A93F4767AA80E49E7E876443F95AE5F,039B4AA00DBFC0A6631DE6DA83526611A0E6B857D3579DF840BBDEAE8B6898E3B6
#!#cashiers={"032871A74D2DDA9D0DE7135F58B5BD2D7F679D2CCA20EA7909466D1A6912DF4022":{"upi":"johnDoe@upi", "currencies":["INR"], "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"},
+ "ranchimall3":{"ip":"127.0.0.1:9113","kbucketId":"odYA6KagmbokSh9GY7yAfeTUZRtZLwecY1"},
"ranchimall6":{"ip":"127.0.0.1:9116","kbucketId":"oV1wCeWca3VawbBTfUGKA7Vd368PATnKAx"}}`;
return callback(text);
@@ -15601,16 +15602,6 @@
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 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);
}
@@ -15659,12 +15650,6 @@
configurable: 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(
private_key_shamirs_shares,
@@ -21728,235 +21713,127 @@
var output;
- function kickInit() {
- const RM_WALLET = new localbitcoinplusplus.wallets();
- const BACKUP_DB = (localbitcoinplusplus.newBackupDatabase.db = []);
- const backUpSupernodesWS = (localbitcoinplusplus.backupWS = []);
- return new Promise(resolve => {
- readDB("localbitcoinUser", "00-01").then(async function(idbData) {
+ async function kickInit() {
+ const RM_WALLET = new localbitcoinplusplus.wallets();
+ const BACKUP_DB = (localbitcoinplusplus.newBackupDatabase.db = []);
+ const backUpSupernodesWS = (localbitcoinplusplus.backupWS = []);
+ let user_priv_key = '';
+ let idbData = await readDB("localbitcoinUser", "00-01");
if (
- typeof idbData !== "object" ||
- typeof idbData.myLocalFLOPublicKey == "undefined" ||
- idbData.myLocalFLOPublicKey.trim() == ""
+ typeof idbData !== "object" ||
+ typeof idbData.myLocalFLOPublicKey == "undefined" ||
+ 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)
- user_pvt_key = null;
+ if (user_pvt_key.trim() == "" || user_pvt_key.length < 1)
+ user_pvt_key = null;
- 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
+ let newKeys = RM_WALLET.generateFloKeys(user_pvt_key);
if (
- localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(
- idbData.myLocalFLOPublicKey
- )
+ typeof newKeys == "object" &&
+ newKeys.privateKeyWIF.length > 0 &&
+ newKeys.address.length > 0
) {
+ localbitcoinplusplusObj.myLocalFLOAddress = newKeys.address;
+ localbitcoinplusplusObj.myLocalFLOPublicKey = newKeys.pubKeyHex;
+ localbitcoinplusplusObj.lastConnectedTime = +new Date();
- wsUri.map((uri, index) => {
- // Do not serve to any requests unless data is fully synced.
- // localbitcoinplusplus.services[
- // `can_serve_${uri.trader_flo_address}`
- // ] = false;
-
- 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();
- }
- });
+ idbData = await updateinDB("localbitcoinUser", localbitcoinplusplusObj);
+ user_priv_key = newKeys.privateKeyWIF;
+
+ } else {
+ err_msg = "Failed to generate new FLO keys. Please retry.";
+ showMessage(err_msg);
+ throw new Error(err_msg);
}
-
- 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
launchKBuckects = await localbitcoinplusplus.kademlia.launchKBucket(
- idbData.myLocalFLOAddress
+ idbData.myLocalFLOAddress
);
if (!launchKBuckects) {
- const kmsg = `ERROR: Failed to build KBuckets. System cannot proceed further.`;
- showMessage(kmsg);
- throw new Error(kmsg);
+ 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(
- idbData.myLocalFLOAddress
+ idbData.myLocalFLOAddress
);
const getClosestSuList = await readAllDB("myClosestSupernodes");
+ console.log("getClosestSuList", getClosestSuList);
reactor.dispatchEvent("createClosestSupernodesObject", 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
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.`
- );
+ 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.`
+ );
});
// Connect with primary supernodes
await startWebSocket(`${WS}://${wsUri[0].ip}`);
+ if(user_priv_key.length>0) {
+ await RM_WALLET.distributeShamirsSecretShares(user_priv_key);
+ }
+
// rebuild private key
await privateKeyBuilder();
- 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();
- }
+ 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();
+ }
+ if (
+ typeof localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY ==
+ "string" &&
+ localbitcoinplusplus.is_ui_loaded == false
+ ) {
+ dataBaseUIOperations();
+ }
}, 10000);
localbitcoinplusplus.MY_SUPERNODE_FLO_ADDRESS =
- wsUri[0].trader_flo_address;
+ wsUri[0].trader_flo_address;
localbitcoinplusplus.services = {};
// Connect with backup supernodes
if (
- localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(
- idbData.myLocalFLOPublicKey
- )
+ localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(
+ idbData.myLocalFLOPublicKey
+ )
) {
- wsUri.map((uri, index) => {
- // Do not serve to any requests unless data is fully synced.
- // localbitcoinplusplus.services[
- // `can_serve_${uri.trader_flo_address}`
- // ] = false;
-
- 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();
- }
- });
-
+ wsUri.map((uri, index) => {
+ 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(
ws_url
@@ -29557,7 +29434,7 @@
localbitcoinplusplus.master_configurations.tradableAsset1.map(
asset => bitjslib(asset)
);
- kickInit();
+ await kickInit();
}
);
} catch (error) {
@@ -29659,27 +29536,14 @@
const MY_LOCAL_FLO_ADDRESS = localbitcoinplusplus.wallets.my_local_flo_address;
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
if (
localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(
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("user_flo_keys_active", localbitcoinplusplus.wallets.my_local_flo_public_key);
}
// Send your id to Supernode kbucket