fixed signDBData issue
This commit is contained in:
parent
4ab92b51ce
commit
445e3a8811
155
index.html
155
index.html
@ -12501,20 +12501,14 @@
|
||||
#!#tradableAsset1=BTC,FLO,BTC_TEST,FLO_TEST#!#tradableAsset2=INR,USD,
|
||||
#!#validTradingAmount=10,50,100,#!#btcTradeMargin=5000
|
||||
#!#MaxBackups=1
|
||||
#!#ordersLife={"trade":3600000, "cryptoDeposit":172800000, "cryptoWithdraw":3600000, "cashDeposit":172800000, "cashWithdraw":172800000}
|
||||
#!#ordersLife={"trade":300000, "cryptoDeposit":900000, "cryptoWithdraw":300000, "cashDeposit":900000, "cashWithdraw":900000}
|
||||
#!#miners_fee={"btc":0.0005, "flo":0.001}
|
||||
#!#supernodesPubKeys=0315C3A20FE7096CC2E0F81A80D5F1A687B8F9EFA65242A0B0881E1BA3EE7D7D53,
|
||||
03F7493F11B8E44B9798CD434D20FBE7FA34B9779D144984889D11A17C56A18742,039B4AA00DBFC0A6631DE6DA83526611A0E6B857D3579DF840BBDEAE8B6898E3B6,
|
||||
03C8E3836C9A77E2AF03D4265D034BA85732738919708EAF6A16382195AE796EDF,0349B08AA1ABDCFFB6D78CD7C949665AD2FF065EA02B3C6C47A5E9592C9A1C6BCB,
|
||||
026FCC6CFF6EB3A39E54BEB6E13FC2F02C3A93F4767AA80E49E7E876443F95AE5F,
|
||||
#!#externalFiles={"d3js":"58f54395efa8346e8e94d12609770f66b916897e7f4e05f6c98780cffa5c70a3"}
|
||||
#!#cashiers={"032871A74D2DDA9D0DE7135F58B5BD2D7F679D2CCA20EA7909466D1A6912DF4022":"johnDoe@upi",
|
||||
"03DB4A12EB543B293DDBB0CE314C46C36D6761294AFBB7264A6D78F710FFD97CF0":"janeDoe@upi"}
|
||||
#!#ShamirsMaxShares=8#!#supernodeSeeds={"ranchimall1":{"ip":"127.0.0.1:9111","kbucketId":"oZxHcbSf1JC8t5GjutopWYXs7C6Fe9p7ps"},
|
||||
"ranchimall2":{"ip":"127.0.0.1:9112","kbucketId":"oTWjPupy3Z7uMdPcu5uXd521HBkcsLuSuM"},
|
||||
"ranchimall3":{"ip":"127.0.0.1:9113","kbucketId":"odYA6KagmbokSh9GY7yAfeTUZRtZLwecY1"},
|
||||
"ranchimall4":{"ip":"127.0.0.1:9114","kbucketId":"oJosrve9dBv2Hj2bfncxv2oEpTysg3Wejv"},
|
||||
"ranchimall5":{"ip":"127.0.0.1:9115","kbucketId":"oMhv5sAzqg77sYHxmUGZWKRrVo4P4JQduS"},
|
||||
"ranchimall6":{"ip":"127.0.0.1:9116","kbucketId":"oV1wCeWca3VawbBTfUGKA7Vd368PATnKAx"}}`;
|
||||
return callback(text);
|
||||
|
||||
@ -14555,6 +14549,9 @@
|
||||
) {
|
||||
// Connect to nearest live backup nodes
|
||||
reactor.dispatchEvent("resolve_backup_ws_connections");
|
||||
// Also refresh deposited crypto balances
|
||||
RM_WALLET.refresh_reserved_crypto_balances(
|
||||
localbitcoinplusplus.wallets.my_local_flo_address);
|
||||
// Inform left side Supernodes you are back
|
||||
const msg_obj = {};
|
||||
msg_obj.protocol = '__ALL_SUPERNODES_MSG__';
|
||||
@ -15412,72 +15409,57 @@
|
||||
showPopup('sign_in_popup');
|
||||
const signInBtn = document.getElementById('signInBtn');
|
||||
signInBtn.onclick = function() {
|
||||
//readDB("localbitcoinUser", "00-01")
|
||||
//.then(async usr => {
|
||||
// if (typeof usr == "object" && usr.myLocalFLOAddress.length > 0) {
|
||||
|
||||
const RM_WALLET = new localbitcoinplusplus.wallets();
|
||||
const pk_manual = document.getElementById('get_priv_key_field').value;
|
||||
let gen_new_keys = RM_WALLET.generateFloKeys(pk_manual);
|
||||
|
||||
Object.defineProperty(
|
||||
localbitcoinplusplus.wallets,
|
||||
"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
|
||||
}
|
||||
);
|
||||
|
||||
const RM_WALLET = new localbitcoinplusplus.wallets();
|
||||
const pk_manual = document.getElementById('get_priv_key_field').value;
|
||||
let gen_new_keys = RM_WALLET.generateFloKeys(pk_manual);
|
||||
//if (gen_new_keys.address == usr.myLocalFLOAddress) {
|
||||
Object.defineProperty(
|
||||
localbitcoinplusplus.wallets,
|
||||
"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('sign_in_popup');
|
||||
if (localbitcoinplusplus.is_ui_loaded == false) {
|
||||
dataBaseUIOperations();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// 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);
|
||||
// } else {
|
||||
// let mes = `WARNING: Failed to build your private key. You can reset keys and generate new keys from keys section below.`;
|
||||
// showMessage(mes);
|
||||
// throw new Error(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);
|
||||
// });
|
||||
return resolve(gen_new_keys.privateKeyWIF);
|
||||
}
|
||||
});
|
||||
|
||||
@ -22214,11 +22196,6 @@
|
||||
}
|
||||
let remove_promises_res = await Promise.all(remove_promises);
|
||||
console.log(remove_promises_res);
|
||||
// Also refresh deposited crypto balances
|
||||
const RM_WALLET = new localbitcoinplusplus.wallets;
|
||||
RM_WALLET.refresh_reserved_crypto_balances(
|
||||
localbitcoinplusplus.wallets.my_local_flo_address);
|
||||
|
||||
}
|
||||
|
||||
readAllDB("myClosestSupernodes")
|
||||
@ -28303,15 +28280,18 @@
|
||||
|
||||
function signDBData(objectdata) {
|
||||
try {
|
||||
if(!localbitcoinplusplus.master_configurations.supernodesPubKeys
|
||||
.includes(localbitcoinplusplus.wallets.my_local_flo_public_key)) return objectdata;
|
||||
|
||||
if(typeof localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY !=="string")
|
||||
throw new Error("Private key not found.");
|
||||
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)) return objectdata;
|
||||
|
||||
let objectdata_copy = JSON.parse(JSON.stringify(objectdata));
|
||||
if(typeof objectdata_copy.db_sign=="string") delete objectdata_copy.db_sign;
|
||||
if(typeof objectdata_copy.db_signer=="string") delete objectdata_copy.db_signer;
|
||||
objectdata_copy.db_sign = RM_WALLET.sign(JSON.stringify(objectdata_copy), localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY);
|
||||
objectdata_copy.db_signer = localbitcoinplusplus.wallets.my_local_flo_public_key;
|
||||
objectdata_copy.db_signer = pubKey;
|
||||
return objectdata_copy;
|
||||
} catch (error) {
|
||||
throw new Error(error);
|
||||
@ -28326,7 +28306,6 @@
|
||||
let objectdata_copy = JSON.parse(JSON.stringify(objectdata));
|
||||
delete objectdata_copy.db_sign;
|
||||
delete objectdata_copy.db_signer;
|
||||
//return RM_WALLET.verify(JSON.stringify(objectdata_copy), objectdata.db_sign, objectdata.db_signer);
|
||||
if(RM_WALLET.verify(JSON.stringify(objectdata_copy), objectdata.db_sign, objectdata.db_signer)) {
|
||||
return true;
|
||||
} else {
|
||||
@ -28630,25 +28609,25 @@
|
||||
if(!exception_datastores.includes(tablename)) {
|
||||
if(verifyDBData(originalObj)===true) {
|
||||
Obj = signDBData(Obj);
|
||||
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 if (myRecord.vectorClock == Obj.vectorClock) {
|
||||
if(myRecord.timestamp < Obj.timestamp) {
|
||||
if(!exception_datastores.includes(tablename)) {
|
||||
if(verifyDBData(originalObj)===true) {
|
||||
Obj = signDBData(Obj);
|
||||
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 {
|
||||
resolve(Obj);
|
||||
@ -29305,26 +29284,26 @@
|
||||
if(!exception_datastores.includes(tablename)) {
|
||||
if(verifyDBData(originalObj)===true) {
|
||||
Obj = signDBData(Obj);
|
||||
this.request = this.db.transaction([tablename], "readwrite")
|
||||
.objectStore(tablename).put(Obj);
|
||||
} else {
|
||||
console.trace(Obj);
|
||||
throw new Error('failed verification at backup update');
|
||||
}
|
||||
}
|
||||
this.request = this.db.transaction([tablename], "readwrite")
|
||||
.objectStore(tablename).put(Obj);
|
||||
|
||||
} else if (myRecord.vectorClock == Obj.vectorClock) {
|
||||
if(myRecord.timestamp < Obj.timestamp) {
|
||||
if(!exception_datastores.includes(tablename)) {
|
||||
if(verifyDBData(originalObj)===true) {
|
||||
Obj = signDBData(Obj);
|
||||
this.request = this.db.transaction([tablename], "readwrite")
|
||||
.objectStore(tablename).put(Obj);
|
||||
} else {
|
||||
console.trace(Obj);
|
||||
throw new Error('Failed verification at db update');
|
||||
}
|
||||
}
|
||||
this.request = this.db.transaction([tablename], "readwrite")
|
||||
.objectStore(tablename).put(Obj);
|
||||
}
|
||||
} else {
|
||||
resolve(Obj);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user