diff --git a/supernode/cash_payments_handler.html b/supernode/cash_payments_handler.html
index 49190b3..7f566dd 100644
--- a/supernode/cash_payments_handler.html
+++ b/supernode/cash_payments_handler.html
@@ -12411,11 +12411,10 @@
localbitcoinplusplus.master_configurations.supernodeSeeds;
if (typeof supernodeSeeds !== "object")
reject("Failed to get supernode seeds.");
- let supernodeSeedsObj = JSON.parse(supernodeSeeds);
- nearestSupernodeAddresslist = Object.values(supernodeSeedsObj);
+ nearestSupernodeAddresslist = Object.values(supernodeSeeds);
nearestSupernodeAddresslist.map((m, i) => {
- m.id = i + 1;
- updateinDB("supernodesList", m).catch(e => {
+ let sl = Object.assign({id: i+1}, m);
+ updateinDB("supernodesList", sl).catch(e => {
throw new Error(e);
});
});
@@ -12848,7 +12847,7 @@
}
}
- async function updateinDB(
+ function updateinDB(
tablename,
Obj,
key,
@@ -12857,43 +12856,51 @@
) {
// updateByVectorClock==true will not return Obj back.
// Return value will be undefined
- try {
- if (typeof Obj.vectorClock == "undefined") {
- Obj.vectorClock = 0;
- } else if (increaseVectorClock === false) {
- // leave the vector clock field unchanged
- } else {
- Obj.vectorClock += 1;
- }
- if (typeof Obj.timestamp !== "number") {
- Obj.timestamp = +new Date();
- }
- var request = db.transaction([tablename], "readwrite");
- let store = request.objectStore(tablename);
- if (updateByVectorClock === true) {
- if (typeof key == "undefined") {
- key = Obj[store.keyPath];
- }
- let objectStoreRequest = store.get(key);
- objectStoreRequest.onsuccess = async function(event) {
- var myRecord = objectStoreRequest.result;
- if (typeof myRecord !== "object") {
- Obj.vectorClock = 1;
- await store.put(Obj);
- await request.complete;
- } else if (myRecord.vectorClock + 1 < Obj.vectorClock) {
- await store.put(Obj);
- await request.complete;
+ return new Promise((resolve, reject) => {
+
+ try {
+ if (typeof Obj.vectorClock == "undefined") {
+ Obj.vectorClock = 0;
+ } else if (increaseVectorClock === false) {
+ // leave the vector clock field unchanged
+ } else {
+ Obj.vectorClock += 1;
}
- };
- } else {
- await store.put(Obj);
- await request.complete;
+ if (typeof Obj.timestamp !== "number") {
+ Obj.timestamp = +new Date();
+ }
+ var request = db.transaction([tablename], "readwrite");
+ let store = request.objectStore(tablename);
+ if (updateByVectorClock === true) {
+ if (typeof key == "undefined") {
+ key = Obj[store.keyPath];
+ }
+ let objectStoreRequest = store.get(key);
+ objectStoreRequest.onsuccess = async function(event) {
+ var myRecord = objectStoreRequest.result;
+ if (typeof myRecord !== "object") {
+ Obj.vectorClock = 1;
+ store.put(Obj);
+ } else if (myRecord.vectorClock + 1 < Obj.vectorClock) {
+ store.put(Obj);
+ }
+ };
+ } else {
+ store.put(Obj);
+ }
+
+ store.onsuccess = function() {
+ resolve(Obj);
+ }
+
+ store.onerror = function(e) {
+ reject(e);
+ }
+ } catch (error) {
+ reject(error);
+ return new Error(error);
}
- return Obj;
- } catch (error) {
- return new Error(error);
- }
+ });
}
async function removeinDB(tablename, id) {
diff --git a/supernode/index.html b/supernode/index.html
index ec1244e..2f4ebc1 100644
--- a/supernode/index.html
+++ b/supernode/index.html
@@ -546,10 +546,9 @@
Close
-Event information log
+ Event information log
=====================
-
+
☰
@@ -13963,6 +13962,7 @@ Event information log
function showMessage(msg = "", t = 10000) {
if (msg.length > 0) LogEvent(msg);
+ console.trace(msg);
displayMessages();
setTimeout(function() {
closeMessage();
@@ -14871,6 +14871,19 @@ Event information log
params.currency,
params.product
);
+ // If margin is > 2% discontinue the trade
+ const diffPercent = Math.floor(((eqCrypto- trade_margin.remaining_crypto_credit)
+ /trade_margin.remaining_crypto_credit)*100);
+ console.log(trade_margin.remaining_crypto_credit, eqCrypto);
+ console.info(diffPercent);
+
+ if(diffPercent<=2) {
+ eqCrypto = trade_margin.remaining_crypto_credit;
+ } else {
+ console.info(`Info: Difference between Crypto balance and trading amount is too high: ${diffPercent}`);
+ return;
+ }
+
if (
trade_margin.remaining_crypto_credit > 0 &&
trade_margin.remaining_crypto_credit >= eqCrypto
@@ -16478,6 +16491,16 @@ Event information log
params.currency,
params.product
);
+ const diffPercent = Math.floor(((eqCrypto- trade_margin.remaining_crypto_credit)
+ /trade_margin.remaining_crypto_credit)*100);
+
+ if(diffPercent<=2) {
+ eqCrypto=trade_margin.remaining_crypto_credit;
+ } else {
+ console.info(`Info: Difference between Crypto balance and trading amount is too high: ${diffPercent}`);
+ return;
+ }
+
if (
trade_margin.remaining_crypto_credit > 0 &&
trade_margin.remaining_crypto_credit >= eqCrypto
@@ -20799,7 +20822,10 @@ Event information log
if (isDataSignedBySuperNode === true) {
// Add buy order
addDB("buyOrders", buyOrders_data).then(() => {
- showMessage(`Your buy order is placed successfully.`);
+ if(localbitcoinplusplus.wallets.my_local_flo_address
+ ===buyOrders_data.trader_flo_address) {
+ showMessage(`Your buy order is placed successfully.`);
+ }
});
}
}
@@ -20832,9 +20858,13 @@ Event information log
if (isDataSignedBySuperNode === true) {
// Add buy order
addDB("sellOrders", sellOrders_data).then(() => {
- showMessage(
+ if(localbitcoinplusplus.wallets.my_local_flo_address
+ ===sellOrders_data.trader_flo_address) {
+ showMessage(
`Your sell order is placed successfully.`
- );
+ );
+ }
+
});
}
}
@@ -22584,7 +22614,10 @@ Event information log
if (isDataSignedBySuperNode === true) {
// Add buy order
addDB("buyOrders", buyOrders_data).then(() => {
- showMessage(`Your buy order is placed successfully.`);
+ if(localbitcoinplusplus.wallets.my_local_flo_address
+ ===buyOrders_data.trader_flo_address) {
+ showMessage(`Your buy order is placed successfully.`);
+ }
});
}
}
@@ -22626,9 +22659,12 @@ Event information log
if (isDataSignedBySuperNode === true) {
// Add buy order
addDB("sellOrders", sellOrders_data).then(() => {
- showMessage(
+ if(localbitcoinplusplus.wallets.my_local_flo_address
+ ===sellOrders_data.trader_flo_address) {
+ showMessage(
`Your sell order is placed successfully.`
- );
+ );
+ }
});
}
}
@@ -24610,10 +24646,7 @@ Event information log
// Add buy order
backup_server_db_instance
- .backup_addDB("buyOrders", buyOrders_data)
- .then(() => {
- showMessage(`Your buy order is placed successfully.`);
- });
+ .backup_addDB("buyOrders", buyOrders_data);
}
}
break;
@@ -24653,12 +24686,7 @@ Event information log
// Add buy order
backup_server_db_instance
- .backup_addDB("sellOrders", sellOrders_data)
- .then(() => {
- showMessage(
- `Your sell order is placed successfully.`
- );
- });
+ .backup_addDB("sellOrders", sellOrders_data);
}
}
}
@@ -26783,7 +26811,7 @@ Event information log
var db;
const DBName = "localbitcoinDB";
- const request = window.indexedDB.open(DBName, 5);
+ const request = window.indexedDB.open(DBName, 1);
request.onerror = function(event) {
//https://stackoverflow.com/questions/13972385/invalidstateerror-while-opening-indexeddb-in-firefox
@@ -28059,6 +28087,9 @@ Event information log
// Deposit / Withdraw asset
depositWithdrawAsset(idbData.myLocalFLOAddress);
+ // Deposit / Withdraw Fiat
+ depositWithdrawFiat(idbData.myLocalFLOAddress);
+
// User's Trade Details
displayTradeOrders(idbData.myLocalFLOAddress);
@@ -28389,7 +28420,7 @@ Event information log