fixed sync of backup from primary issue

This commit is contained in:
Abhishek Sinha 2020-03-18 14:59:49 +05:30
parent 799d1cfb6b
commit d42bf94d52
9 changed files with 1161 additions and 1160 deletions

View File

@ -14081,10 +14081,10 @@
const myClosestSusList = myClosestSus.map( const myClosestSusList = myClosestSus.map(
m => m.trader_flo_address m => m.trader_flo_address
); );
if ( // if (
myClosestSusList.indexOf(conn_su_flo_id) > // myClosestSusList.indexOf(conn_su_flo_id) >
localbitcoinplusplus.master_configurations.MaxBackups // localbitcoinplusplus.master_configurations.MaxBackups
) { // ) {
// Ask conn_su_flo_id to ask you your DB data // Ask conn_su_flo_id to ask you your DB data
const RM_RPC = new localbitcoinplusplus.rpc(); const RM_RPC = new localbitcoinplusplus.rpc();
RM_RPC.send_rpc.call(this, "request_me_db_data", { RM_RPC.send_rpc.call(this, "request_me_db_data", {
@ -14094,7 +14094,7 @@
db_inst: localbitcoinplusplus.wallets.my_local_flo_address db_inst: localbitcoinplusplus.wallets.my_local_flo_address
}) })
.then(req => doSend(req)); .then(req => doSend(req));
} //}
// Check if the number of backup ws connections satisfy max baxkup master // Check if the number of backup ws connections satisfy max baxkup master
// config condition. If false, request ws connection to next backup supernode. // config condition. If false, request ws connection to next backup supernode.
@ -18526,8 +18526,6 @@
} else { } else {
_removeinDB("cash_deposits", params.deposit_id); _removeinDB("cash_deposits", params.deposit_id);
} }
return;
// Broadcast deposit and cash balances datastore data to backups // Broadcast deposit and cash balances datastore data to backups
let update_cash_balance_obj = { let update_cash_balance_obj = {
@ -20299,6 +20297,15 @@
throw new Error(error) throw new Error(error)
} }
}, },
truncateDecimals: (num, digits=8)=> {
var numS = num.toString(),
decPos = numS.indexOf('.'),
substrLength = decPos == -1 ? numS.length : 1 + decPos + digits,
trimmedResult = numS.substr(0, substrLength),
finalResult = isNaN(trimmedResult) ? 0 : trimmedResult;
return Number(finalResult);
}
}; };
</script> </script>
@ -21717,28 +21724,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
updateinDB( let p1 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let p2 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
updateinDB( let p3 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let p4 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -21746,10 +21753,14 @@
false false
); );
// Update balances Promise.all([p1,p2,p3,p4]).then(()=>{
displayBalances( // Update balances
localbitcoinplusplus.wallets.my_local_flo_address displayBalances(
); localbitcoinplusplus.wallets.my_local_flo_address
);
})
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -21987,12 +21998,13 @@
withdraw_success_response.withdrawer_cash_data.id, withdraw_success_response.withdrawer_cash_data.id,
false, false,
false false
); ).then(()=>{
// Update balances
displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address
);
})
// Update balances
displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address
);
return true; return true;
} }
return false; return false;
@ -22209,17 +22221,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); );
showMessage(`INFO: Your Crypto balance is updated.`); showMessage(`INFO: Your Crypto balance is updated.`);
} }
return true; return true;
});
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -22253,17 +22266,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -23675,28 +23689,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
updateinDB( let pr1 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let pr2 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
updateinDB( let pr3 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let pr4 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -23704,10 +23718,14 @@
false false
); );
// Update balances Promise.all([pr1,pr2,pr3,pr4]).then(()=>{
displayBalances( // Update balances
localbitcoinplusplus.wallets.my_local_flo_address displayBalances(
); localbitcoinplusplus.wallets.my_local_flo_address
);
})
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -24000,12 +24018,13 @@
withdraw_success_response.withdrawer_cash_data.id, withdraw_success_response.withdrawer_cash_data.id,
false, false,
false false
); ).then(()=>{
// Update balances // Update balances
displayBalances( displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address localbitcoinplusplus.wallets.my_local_flo_address
); );
return true; return true;
})
} }
return false; return false;
} }
@ -24290,17 +24309,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -24335,17 +24355,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -25723,28 +25744,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
backup_server_db_instance.backup_updateinDB( let b1 = backup_server_db_instance.backup_updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b2 = backup_server_db_instance.backup_updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b3 = backup_server_db_instance.backup_updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b4 = backup_server_db_instance.backup_updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -25752,11 +25773,14 @@
false false
); );
Promise.all([b1,b2,b3,b4]).then(()=>{
// Update balances // Update balances
displayBalances( displayBalances(
localbitcoinplusplus.wallets localbitcoinplusplus.wallets.my_local_flo_address
.my_local_flo_address );
); })
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -26280,18 +26304,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
true, true,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets localbitcoinplusplus.wallets.my_local_flo_address ==
.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address
) {
displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); ) {
showMessage(`INFO: Your balance is updated.`); displayBalances(
} updateUserCryptoBalanceResponseObject.trader_flo_address
return true; );
showMessage(`INFO: Your balance is updated.`);
}
return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -26349,17 +26373,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
true, true,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -29267,10 +29292,8 @@
all_balances.map(user_balance_data => { all_balances.map(user_balance_data => {
let code = let code =
user_balance_data.crypto_currency || user_balance_data.currency; user_balance_data.crypto_currency || user_balance_data.currency;
let value = let value = user_balance_data.crypto_balance || user_balance_data.cash_balance;
user_balance_data.crypto_balance || t += `<span>${code}:${helper_functions.truncateDecimals(value)}</span> &nbsp;`;
user_balance_data.cash_balance;
t += `<span>${code}:${value}</span> &nbsp;`;
}); });
balances_div.innerHTML = t; balances_div.innerHTML = t;
} }

Binary file not shown.

View File

@ -6,7 +6,7 @@
#include "mongoose.h" #include "mongoose.h"
static sig_atomic_t s_signal_received = 0; static sig_atomic_t s_signal_received = 0;
static const char *s_http_port = "9115"; static const char *s_http_port = "9116";
static struct mg_serve_http_opts s_http_server_opts; static struct mg_serve_http_opts s_http_server_opts;
static void signal_handler(int sig_num) { static void signal_handler(int sig_num) {

View File

@ -14081,10 +14081,10 @@
const myClosestSusList = myClosestSus.map( const myClosestSusList = myClosestSus.map(
m => m.trader_flo_address m => m.trader_flo_address
); );
if ( // if (
myClosestSusList.indexOf(conn_su_flo_id) > // myClosestSusList.indexOf(conn_su_flo_id) >
localbitcoinplusplus.master_configurations.MaxBackups // localbitcoinplusplus.master_configurations.MaxBackups
) { // ) {
// Ask conn_su_flo_id to ask you your DB data // Ask conn_su_flo_id to ask you your DB data
const RM_RPC = new localbitcoinplusplus.rpc(); const RM_RPC = new localbitcoinplusplus.rpc();
RM_RPC.send_rpc.call(this, "request_me_db_data", { RM_RPC.send_rpc.call(this, "request_me_db_data", {
@ -14094,7 +14094,7 @@
db_inst: localbitcoinplusplus.wallets.my_local_flo_address db_inst: localbitcoinplusplus.wallets.my_local_flo_address
}) })
.then(req => doSend(req)); .then(req => doSend(req));
} //}
// Check if the number of backup ws connections satisfy max baxkup master // Check if the number of backup ws connections satisfy max baxkup master
// config condition. If false, request ws connection to next backup supernode. // config condition. If false, request ws connection to next backup supernode.
@ -15421,11 +15421,6 @@
localbitcoinplusplus.master_configurations.tradableAsset2.includes( localbitcoinplusplus.master_configurations.tradableAsset2.includes(
params.currency params.currency
) && ) &&
typeof localbitcoinplusplus.master_configurations
.validTradingAmount !== "undefined" &&
localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.depositing_amount)
) &&
typeof params.trader_flo_address == "string" && typeof params.trader_flo_address == "string" &&
params.trader_flo_address.length > 0 params.trader_flo_address.length > 0
) { ) {
@ -15654,11 +15649,6 @@
localbitcoinplusplus.master_configurations.tradableAsset2.includes( localbitcoinplusplus.master_configurations.tradableAsset2.includes(
params.currency params.currency
) && ) &&
typeof localbitcoinplusplus.master_configurations
.validTradingAmount !== "undefined" &&
localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.depositing_amount)
) &&
typeof params.trader_flo_address == "string" && typeof params.trader_flo_address == "string" &&
params.trader_flo_address.length > 0 && params.trader_flo_address.length > 0 &&
typeof params.user_upi == "string" && typeof params.user_upi == "string" &&
@ -15967,15 +15957,6 @@
params.product params.product
) )
) { ) {
if (
!localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.withdrawing_amount)
)
) {
err_msg = `Withdrawal request failed: Please enter valid fiat amount.`;
showMessage(err_msg);
throw new Error(err_msg);
}
if ( if (
trade_margin.remaining_fiat_credit <= 0 || trade_margin.remaining_fiat_credit <= 0 ||
params.withdrawing_amount <= 0 || params.withdrawing_amount <= 0 ||
@ -17015,11 +16996,6 @@
localbitcoinplusplus.master_configurations.tradableAsset2.includes( localbitcoinplusplus.master_configurations.tradableAsset2.includes(
params.currency params.currency
) && ) &&
typeof localbitcoinplusplus.master_configurations
.validTradingAmount !== "undefined" &&
localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.depositing_amount)
) &&
typeof params.trader_flo_address == "string" && typeof params.trader_flo_address == "string" &&
params.trader_flo_address.length > 0 params.trader_flo_address.length > 0
) { ) {
@ -18550,8 +18526,6 @@
} else { } else {
_removeinDB("cash_deposits", params.deposit_id); _removeinDB("cash_deposits", params.deposit_id);
} }
return;
// Broadcast deposit and cash balances datastore data to backups // Broadcast deposit and cash balances datastore data to backups
let update_cash_balance_obj = { let update_cash_balance_obj = {
@ -19098,14 +19072,6 @@
err_msg = "User address required."; err_msg = "User address required.";
showMessage(err_msg); showMessage(err_msg);
throw new Error(err_msg); throw new Error(err_msg);
} else if (
!localbitcoinplusplus.master_configurations.validTradingAmount.includes(
amount
)
) {
err_msg = "Error: Invalid deposit amount.";
showMessage(err_msg);
throw new Error(err_msg);
} else if (typeof user_upi !== "string" || user_upi.length < 1) { } else if (typeof user_upi !== "string" || user_upi.length < 1) {
err_msg = "Error: Invalid UPI id."; err_msg = "Error: Invalid UPI id.";
showMessage(err_msg); showMessage(err_msg);
@ -20331,6 +20297,15 @@
throw new Error(error) throw new Error(error)
} }
}, },
truncateDecimals: (num, digits=8)=> {
var numS = num.toString(),
decPos = numS.indexOf('.'),
substrLength = decPos == -1 ? numS.length : 1 + decPos + digits,
trimmedResult = numS.substr(0, substrLength),
finalResult = isNaN(trimmedResult) ? 0 : trimmedResult;
return Number(finalResult);
}
}; };
</script> </script>
@ -21749,28 +21724,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
updateinDB( let p1 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let p2 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
updateinDB( let p3 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let p4 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -21778,10 +21753,14 @@
false false
); );
// Update balances Promise.all([p1,p2,p3,p4]).then(()=>{
displayBalances( // Update balances
localbitcoinplusplus.wallets.my_local_flo_address displayBalances(
); localbitcoinplusplus.wallets.my_local_flo_address
);
})
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -22019,12 +21998,13 @@
withdraw_success_response.withdrawer_cash_data.id, withdraw_success_response.withdrawer_cash_data.id,
false, false,
false false
); ).then(()=>{
// Update balances
displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address
);
})
// Update balances
displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address
);
return true; return true;
} }
return false; return false;
@ -22241,17 +22221,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); );
showMessage(`INFO: Your Crypto balance is updated.`); showMessage(`INFO: Your Crypto balance is updated.`);
} }
return true; return true;
});
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -22285,17 +22266,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -23707,28 +23689,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
updateinDB( let pr1 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let pr2 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
updateinDB( let pr3 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let pr4 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -23736,10 +23718,14 @@
false false
); );
// Update balances Promise.all([pr1,pr2,pr3,pr4]).then(()=>{
displayBalances( // Update balances
localbitcoinplusplus.wallets.my_local_flo_address displayBalances(
); localbitcoinplusplus.wallets.my_local_flo_address
);
})
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -24032,12 +24018,13 @@
withdraw_success_response.withdrawer_cash_data.id, withdraw_success_response.withdrawer_cash_data.id,
false, false,
false false
); ).then(()=>{
// Update balances // Update balances
displayBalances( displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address localbitcoinplusplus.wallets.my_local_flo_address
); );
return true; return true;
})
} }
return false; return false;
} }
@ -24322,17 +24309,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -24367,17 +24355,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -25755,28 +25744,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
backup_server_db_instance.backup_updateinDB( let b1 = backup_server_db_instance.backup_updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b2 = backup_server_db_instance.backup_updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b3 = backup_server_db_instance.backup_updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b4 = backup_server_db_instance.backup_updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -25784,11 +25773,14 @@
false false
); );
Promise.all([b1,b2,b3,b4]).then(()=>{
// Update balances // Update balances
displayBalances( displayBalances(
localbitcoinplusplus.wallets localbitcoinplusplus.wallets.my_local_flo_address
.my_local_flo_address );
); })
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -26312,18 +26304,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
true, true,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets localbitcoinplusplus.wallets.my_local_flo_address ==
.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address
) {
displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); ) {
showMessage(`INFO: Your balance is updated.`); displayBalances(
} updateUserCryptoBalanceResponseObject.trader_flo_address
return true; );
showMessage(`INFO: Your balance is updated.`);
}
return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -26381,17 +26373,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
true, true,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -29299,10 +29292,8 @@
all_balances.map(user_balance_data => { all_balances.map(user_balance_data => {
let code = let code =
user_balance_data.crypto_currency || user_balance_data.currency; user_balance_data.crypto_currency || user_balance_data.currency;
let value = let value = user_balance_data.crypto_balance || user_balance_data.cash_balance;
user_balance_data.crypto_balance || t += `<span>${code}:${helper_functions.truncateDecimals(value)}</span> &nbsp;`;
user_balance_data.cash_balance;
t += `<span>${code}:${value}</span> &nbsp;`;
}); });
balances_div.innerHTML = t; balances_div.innerHTML = t;
} }
@ -29848,47 +29839,47 @@
} }
} }
const receiving_amount_currency_input = document.createElement( // const receiving_amount_currency_input = document.createElement(
"select" // "select"
); // );
receiving_amount_currency_input.id = "receiving_amount_currency_input"; // receiving_amount_currency_input.id = "receiving_amount_currency_input";
broadcast_tx_ui.appendChild(receiving_amount_currency_input); // broadcast_tx_ui.appendChild(receiving_amount_currency_input);
if ( // if (
typeof localbitcoinplusplus.master_configurations.tradableAsset2 !== // typeof localbitcoinplusplus.master_configurations.tradableAsset2 !==
"undefined" // "undefined"
) { // ) {
let receiving_amount_currency_inputArray = JSON.parse( // let receiving_amount_currency_inputArray = JSON.parse(
JSON.stringify( // JSON.stringify(
localbitcoinplusplus.master_configurations.tradableAsset2 // localbitcoinplusplus.master_configurations.tradableAsset2
) // )
).filter( // ).filter(
asset => // asset =>
!localbitcoinplusplus.master_configurations.tradableAsset1.includes( // !localbitcoinplusplus.master_configurations.tradableAsset1.includes(
asset // asset
) // )
); // );
receiving_amount_currency_inputArray.unshift("Select Fiat"); // receiving_amount_currency_inputArray.unshift("Select Fiat");
for ( // for (
var i = 0; // var i = 0;
i < receiving_amount_currency_inputArray.length; // i < receiving_amount_currency_inputArray.length;
i++ // i++
) { // ) {
var option = document.createElement("option"); // var option = document.createElement("option");
option.value = receiving_amount_currency_inputArray[i]; // option.value = receiving_amount_currency_inputArray[i];
option.text = receiving_amount_currency_inputArray[i]; // option.text = receiving_amount_currency_inputArray[i];
receiving_amount_currency_input.appendChild(option); // receiving_amount_currency_input.appendChild(option);
} // }
} // }
const utxo_addr_input = document.createElement("input"); const utxo_addr_input = document.createElement("input");
utxo_addr_input.type = "text"; utxo_addr_input.type = "text";
utxo_addr_input.placeholder = `UTXO Address of Crypto`; utxo_addr_input.placeholder = `Sender Address`;
const utxo_addr_wif_input = document.createElement("input"); const utxo_addr_wif_input = document.createElement("input");
utxo_addr_wif_input.type = "text"; utxo_addr_wif_input.type = "text";
utxo_addr_wif_input.placeholder = `Private Key of Crypto Being Used`; utxo_addr_wif_input.placeholder = `Enter Private Key`;
const receiver_address_input = document.createElement("input"); const receiver_address_input = document.createElement("input");
receiver_address_input.type = "text"; receiver_address_input.type = "text";
@ -29898,9 +29889,9 @@
receiving_crypto_amount_input.type = "text"; receiving_crypto_amount_input.type = "text";
receiving_crypto_amount_input.placeholder = `Amount to Send`; receiving_crypto_amount_input.placeholder = `Amount to Send`;
const change_adress_input = document.createElement("input"); // const change_adress_input = document.createElement("input");
change_adress_input.type = "text"; // change_adress_input.type = "text";
change_adress_input.placeholder = `Change Address`; // change_adress_input.placeholder = `Change Address`;
const tx_send_button = document.createElement("button"); const tx_send_button = document.createElement("button");
tx_send_button.className += " button bg-blue fs-16 "; tx_send_button.className += " button bg-blue fs-16 ";
@ -29912,7 +29903,7 @@
broadcast_tx_ui_form.appendChild(utxo_addr_wif_input); broadcast_tx_ui_form.appendChild(utxo_addr_wif_input);
broadcast_tx_ui_form.appendChild(receiver_address_input); broadcast_tx_ui_form.appendChild(receiver_address_input);
broadcast_tx_ui_form.appendChild(receiving_crypto_amount_input); broadcast_tx_ui_form.appendChild(receiving_crypto_amount_input);
broadcast_tx_ui_form.appendChild(change_adress_input); //broadcast_tx_ui_form.appendChild(change_adress_input);
broadcast_tx_ui_form.appendChild(tx_send_button); broadcast_tx_ui_form.appendChild(tx_send_button);
let err_msg; let err_msg;
@ -29937,11 +29928,11 @@
showMessage(err_msg); showMessage(err_msg);
throw new Error(err_msg); throw new Error(err_msg);
} }
if (change_adress_input.value.length < 1) { // if (change_adress_input.value.length < 1) {
err_msg = "Empty Change Address."; // err_msg = "Empty Change Address.";
showMessage(err_msg); // showMessage(err_msg);
throw new Error(err_msg); // throw new Error(err_msg);
} // }
const RM_TRADE = new localbitcoinplusplus.trade(); const RM_TRADE = new localbitcoinplusplus.trade();
RM_TRADE.sendTransaction( RM_TRADE.sendTransaction(
@ -29950,7 +29941,7 @@
utxo_addr_wif_input.value, utxo_addr_wif_input.value,
receiver_address_input.value, receiver_address_input.value,
receiving_crypto_amount_input.value, receiving_crypto_amount_input.value,
change_adress_input.value, utxo_addr_input.value,
async function(res) { async function(res) {
console.log(res); console.log(res);
if (typeof res == "object") { if (typeof res == "object") {

View File

@ -14081,10 +14081,10 @@
const myClosestSusList = myClosestSus.map( const myClosestSusList = myClosestSus.map(
m => m.trader_flo_address m => m.trader_flo_address
); );
if ( // if (
myClosestSusList.indexOf(conn_su_flo_id) > // myClosestSusList.indexOf(conn_su_flo_id) >
localbitcoinplusplus.master_configurations.MaxBackups // localbitcoinplusplus.master_configurations.MaxBackups
) { // ) {
// Ask conn_su_flo_id to ask you your DB data // Ask conn_su_flo_id to ask you your DB data
const RM_RPC = new localbitcoinplusplus.rpc(); const RM_RPC = new localbitcoinplusplus.rpc();
RM_RPC.send_rpc.call(this, "request_me_db_data", { RM_RPC.send_rpc.call(this, "request_me_db_data", {
@ -14094,7 +14094,7 @@
db_inst: localbitcoinplusplus.wallets.my_local_flo_address db_inst: localbitcoinplusplus.wallets.my_local_flo_address
}) })
.then(req => doSend(req)); .then(req => doSend(req));
} //}
// Check if the number of backup ws connections satisfy max baxkup master // Check if the number of backup ws connections satisfy max baxkup master
// config condition. If false, request ws connection to next backup supernode. // config condition. If false, request ws connection to next backup supernode.
@ -18526,8 +18526,6 @@
} else { } else {
_removeinDB("cash_deposits", params.deposit_id); _removeinDB("cash_deposits", params.deposit_id);
} }
return;
// Broadcast deposit and cash balances datastore data to backups // Broadcast deposit and cash balances datastore data to backups
let update_cash_balance_obj = { let update_cash_balance_obj = {
@ -20299,6 +20297,15 @@
throw new Error(error) throw new Error(error)
} }
}, },
truncateDecimals: (num, digits=8)=> {
var numS = num.toString(),
decPos = numS.indexOf('.'),
substrLength = decPos == -1 ? numS.length : 1 + decPos + digits,
trimmedResult = numS.substr(0, substrLength),
finalResult = isNaN(trimmedResult) ? 0 : trimmedResult;
return Number(finalResult);
}
}; };
</script> </script>
@ -21717,28 +21724,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
updateinDB( let p1 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let p2 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
updateinDB( let p3 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let p4 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -21746,10 +21753,14 @@
false false
); );
// Update balances Promise.all([p1,p2,p3,p4]).then(()=>{
displayBalances( // Update balances
localbitcoinplusplus.wallets.my_local_flo_address displayBalances(
); localbitcoinplusplus.wallets.my_local_flo_address
);
})
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -21987,12 +21998,13 @@
withdraw_success_response.withdrawer_cash_data.id, withdraw_success_response.withdrawer_cash_data.id,
false, false,
false false
); ).then(()=>{
// Update balances
displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address
);
})
// Update balances
displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address
);
return true; return true;
} }
return false; return false;
@ -22209,17 +22221,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); );
showMessage(`INFO: Your Crypto balance is updated.`); showMessage(`INFO: Your Crypto balance is updated.`);
} }
return true; return true;
});
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -22253,17 +22266,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -23675,28 +23689,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
updateinDB( let pr1 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let pr2 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
updateinDB( let pr3 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let pr4 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -23704,10 +23718,14 @@
false false
); );
// Update balances Promise.all([pr1,pr2,pr3,pr4]).then(()=>{
displayBalances( // Update balances
localbitcoinplusplus.wallets.my_local_flo_address displayBalances(
); localbitcoinplusplus.wallets.my_local_flo_address
);
})
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -24000,12 +24018,13 @@
withdraw_success_response.withdrawer_cash_data.id, withdraw_success_response.withdrawer_cash_data.id,
false, false,
false false
); ).then(()=>{
// Update balances // Update balances
displayBalances( displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address localbitcoinplusplus.wallets.my_local_flo_address
); );
return true; return true;
})
} }
return false; return false;
} }
@ -24290,17 +24309,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -24335,17 +24355,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -25723,28 +25744,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
backup_server_db_instance.backup_updateinDB( let b1 = backup_server_db_instance.backup_updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b2 = backup_server_db_instance.backup_updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b3 = backup_server_db_instance.backup_updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b4 = backup_server_db_instance.backup_updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -25752,11 +25773,14 @@
false false
); );
Promise.all([b1,b2,b3,b4]).then(()=>{
// Update balances // Update balances
displayBalances( displayBalances(
localbitcoinplusplus.wallets localbitcoinplusplus.wallets.my_local_flo_address
.my_local_flo_address );
); })
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -26280,18 +26304,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
true, true,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets localbitcoinplusplus.wallets.my_local_flo_address ==
.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address
) {
displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); ) {
showMessage(`INFO: Your balance is updated.`); displayBalances(
} updateUserCryptoBalanceResponseObject.trader_flo_address
return true; );
showMessage(`INFO: Your balance is updated.`);
}
return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -26349,17 +26373,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
true, true,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -29267,10 +29292,8 @@
all_balances.map(user_balance_data => { all_balances.map(user_balance_data => {
let code = let code =
user_balance_data.crypto_currency || user_balance_data.currency; user_balance_data.crypto_currency || user_balance_data.currency;
let value = let value = user_balance_data.crypto_balance || user_balance_data.cash_balance;
user_balance_data.crypto_balance || t += `<span>${code}:${helper_functions.truncateDecimals(value)}</span> &nbsp;`;
user_balance_data.cash_balance;
t += `<span>${code}:${value}</span> &nbsp;`;
}); });
balances_div.innerHTML = t; balances_div.innerHTML = t;
} }

View File

@ -14081,10 +14081,10 @@
const myClosestSusList = myClosestSus.map( const myClosestSusList = myClosestSus.map(
m => m.trader_flo_address m => m.trader_flo_address
); );
if ( // if (
myClosestSusList.indexOf(conn_su_flo_id) > // myClosestSusList.indexOf(conn_su_flo_id) >
localbitcoinplusplus.master_configurations.MaxBackups // localbitcoinplusplus.master_configurations.MaxBackups
) { // ) {
// Ask conn_su_flo_id to ask you your DB data // Ask conn_su_flo_id to ask you your DB data
const RM_RPC = new localbitcoinplusplus.rpc(); const RM_RPC = new localbitcoinplusplus.rpc();
RM_RPC.send_rpc.call(this, "request_me_db_data", { RM_RPC.send_rpc.call(this, "request_me_db_data", {
@ -14094,7 +14094,7 @@
db_inst: localbitcoinplusplus.wallets.my_local_flo_address db_inst: localbitcoinplusplus.wallets.my_local_flo_address
}) })
.then(req => doSend(req)); .then(req => doSend(req));
} //}
// Check if the number of backup ws connections satisfy max baxkup master // Check if the number of backup ws connections satisfy max baxkup master
// config condition. If false, request ws connection to next backup supernode. // config condition. If false, request ws connection to next backup supernode.
@ -15421,11 +15421,6 @@
localbitcoinplusplus.master_configurations.tradableAsset2.includes( localbitcoinplusplus.master_configurations.tradableAsset2.includes(
params.currency params.currency
) && ) &&
typeof localbitcoinplusplus.master_configurations
.validTradingAmount !== "undefined" &&
localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.depositing_amount)
) &&
typeof params.trader_flo_address == "string" && typeof params.trader_flo_address == "string" &&
params.trader_flo_address.length > 0 params.trader_flo_address.length > 0
) { ) {
@ -15654,11 +15649,6 @@
localbitcoinplusplus.master_configurations.tradableAsset2.includes( localbitcoinplusplus.master_configurations.tradableAsset2.includes(
params.currency params.currency
) && ) &&
typeof localbitcoinplusplus.master_configurations
.validTradingAmount !== "undefined" &&
localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.depositing_amount)
) &&
typeof params.trader_flo_address == "string" && typeof params.trader_flo_address == "string" &&
params.trader_flo_address.length > 0 && params.trader_flo_address.length > 0 &&
typeof params.user_upi == "string" && typeof params.user_upi == "string" &&
@ -15967,15 +15957,6 @@
params.product params.product
) )
) { ) {
if (
!localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.withdrawing_amount)
)
) {
err_msg = `Withdrawal request failed: Please enter valid fiat amount.`;
showMessage(err_msg);
throw new Error(err_msg);
}
if ( if (
trade_margin.remaining_fiat_credit <= 0 || trade_margin.remaining_fiat_credit <= 0 ||
params.withdrawing_amount <= 0 || params.withdrawing_amount <= 0 ||
@ -17015,11 +16996,6 @@
localbitcoinplusplus.master_configurations.tradableAsset2.includes( localbitcoinplusplus.master_configurations.tradableAsset2.includes(
params.currency params.currency
) && ) &&
typeof localbitcoinplusplus.master_configurations
.validTradingAmount !== "undefined" &&
localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.depositing_amount)
) &&
typeof params.trader_flo_address == "string" && typeof params.trader_flo_address == "string" &&
params.trader_flo_address.length > 0 params.trader_flo_address.length > 0
) { ) {
@ -18550,8 +18526,6 @@
} else { } else {
_removeinDB("cash_deposits", params.deposit_id); _removeinDB("cash_deposits", params.deposit_id);
} }
return;
// Broadcast deposit and cash balances datastore data to backups // Broadcast deposit and cash balances datastore data to backups
let update_cash_balance_obj = { let update_cash_balance_obj = {
@ -19098,14 +19072,6 @@
err_msg = "User address required."; err_msg = "User address required.";
showMessage(err_msg); showMessage(err_msg);
throw new Error(err_msg); throw new Error(err_msg);
} else if (
!localbitcoinplusplus.master_configurations.validTradingAmount.includes(
amount
)
) {
err_msg = "Error: Invalid deposit amount.";
showMessage(err_msg);
throw new Error(err_msg);
} else if (typeof user_upi !== "string" || user_upi.length < 1) { } else if (typeof user_upi !== "string" || user_upi.length < 1) {
err_msg = "Error: Invalid UPI id."; err_msg = "Error: Invalid UPI id.";
showMessage(err_msg); showMessage(err_msg);
@ -20331,6 +20297,15 @@
throw new Error(error) throw new Error(error)
} }
}, },
truncateDecimals: (num, digits=8)=> {
var numS = num.toString(),
decPos = numS.indexOf('.'),
substrLength = decPos == -1 ? numS.length : 1 + decPos + digits,
trimmedResult = numS.substr(0, substrLength),
finalResult = isNaN(trimmedResult) ? 0 : trimmedResult;
return Number(finalResult);
}
}; };
</script> </script>
@ -21749,28 +21724,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
updateinDB( let p1 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let p2 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
updateinDB( let p3 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let p4 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -21778,10 +21753,14 @@
false false
); );
// Update balances Promise.all([p1,p2,p3,p4]).then(()=>{
displayBalances( // Update balances
localbitcoinplusplus.wallets.my_local_flo_address displayBalances(
); localbitcoinplusplus.wallets.my_local_flo_address
);
})
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -22019,12 +21998,13 @@
withdraw_success_response.withdrawer_cash_data.id, withdraw_success_response.withdrawer_cash_data.id,
false, false,
false false
); ).then(()=>{
// Update balances
displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address
);
})
// Update balances
displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address
);
return true; return true;
} }
return false; return false;
@ -22241,17 +22221,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); );
showMessage(`INFO: Your Crypto balance is updated.`); showMessage(`INFO: Your Crypto balance is updated.`);
} }
return true; return true;
});
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -22285,17 +22266,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -23707,28 +23689,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
updateinDB( let pr1 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let pr2 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
updateinDB( let pr3 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let pr4 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -23736,10 +23718,14 @@
false false
); );
// Update balances Promise.all([pr1,pr2,pr3,pr4]).then(()=>{
displayBalances( // Update balances
localbitcoinplusplus.wallets.my_local_flo_address displayBalances(
); localbitcoinplusplus.wallets.my_local_flo_address
);
})
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -24032,12 +24018,13 @@
withdraw_success_response.withdrawer_cash_data.id, withdraw_success_response.withdrawer_cash_data.id,
false, false,
false false
); ).then(()=>{
// Update balances // Update balances
displayBalances( displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address localbitcoinplusplus.wallets.my_local_flo_address
); );
return true; return true;
})
} }
return false; return false;
} }
@ -24322,17 +24309,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -24367,17 +24355,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -25755,28 +25744,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
backup_server_db_instance.backup_updateinDB( let b1 = backup_server_db_instance.backup_updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b2 = backup_server_db_instance.backup_updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b3 = backup_server_db_instance.backup_updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b4 = backup_server_db_instance.backup_updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -25784,11 +25773,14 @@
false false
); );
Promise.all([b1,b2,b3,b4]).then(()=>{
// Update balances // Update balances
displayBalances( displayBalances(
localbitcoinplusplus.wallets localbitcoinplusplus.wallets.my_local_flo_address
.my_local_flo_address );
); })
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -26312,18 +26304,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
true, true,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets localbitcoinplusplus.wallets.my_local_flo_address ==
.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address
) {
displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); ) {
showMessage(`INFO: Your balance is updated.`); displayBalances(
} updateUserCryptoBalanceResponseObject.trader_flo_address
return true; );
showMessage(`INFO: Your balance is updated.`);
}
return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -26381,17 +26373,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
true, true,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -29299,10 +29292,8 @@
all_balances.map(user_balance_data => { all_balances.map(user_balance_data => {
let code = let code =
user_balance_data.crypto_currency || user_balance_data.currency; user_balance_data.crypto_currency || user_balance_data.currency;
let value = let value = user_balance_data.crypto_balance || user_balance_data.cash_balance;
user_balance_data.crypto_balance || t += `<span>${code}:${helper_functions.truncateDecimals(value)}</span> &nbsp;`;
user_balance_data.cash_balance;
t += `<span>${code}:${value}</span> &nbsp;`;
}); });
balances_div.innerHTML = t; balances_div.innerHTML = t;
} }
@ -29848,47 +29839,47 @@
} }
} }
const receiving_amount_currency_input = document.createElement( // const receiving_amount_currency_input = document.createElement(
"select" // "select"
); // );
receiving_amount_currency_input.id = "receiving_amount_currency_input"; // receiving_amount_currency_input.id = "receiving_amount_currency_input";
broadcast_tx_ui.appendChild(receiving_amount_currency_input); // broadcast_tx_ui.appendChild(receiving_amount_currency_input);
if ( // if (
typeof localbitcoinplusplus.master_configurations.tradableAsset2 !== // typeof localbitcoinplusplus.master_configurations.tradableAsset2 !==
"undefined" // "undefined"
) { // ) {
let receiving_amount_currency_inputArray = JSON.parse( // let receiving_amount_currency_inputArray = JSON.parse(
JSON.stringify( // JSON.stringify(
localbitcoinplusplus.master_configurations.tradableAsset2 // localbitcoinplusplus.master_configurations.tradableAsset2
) // )
).filter( // ).filter(
asset => // asset =>
!localbitcoinplusplus.master_configurations.tradableAsset1.includes( // !localbitcoinplusplus.master_configurations.tradableAsset1.includes(
asset // asset
) // )
); // );
receiving_amount_currency_inputArray.unshift("Select Fiat"); // receiving_amount_currency_inputArray.unshift("Select Fiat");
for ( // for (
var i = 0; // var i = 0;
i < receiving_amount_currency_inputArray.length; // i < receiving_amount_currency_inputArray.length;
i++ // i++
) { // ) {
var option = document.createElement("option"); // var option = document.createElement("option");
option.value = receiving_amount_currency_inputArray[i]; // option.value = receiving_amount_currency_inputArray[i];
option.text = receiving_amount_currency_inputArray[i]; // option.text = receiving_amount_currency_inputArray[i];
receiving_amount_currency_input.appendChild(option); // receiving_amount_currency_input.appendChild(option);
} // }
} // }
const utxo_addr_input = document.createElement("input"); const utxo_addr_input = document.createElement("input");
utxo_addr_input.type = "text"; utxo_addr_input.type = "text";
utxo_addr_input.placeholder = `UTXO Address of Crypto`; utxo_addr_input.placeholder = `Sender Address`;
const utxo_addr_wif_input = document.createElement("input"); const utxo_addr_wif_input = document.createElement("input");
utxo_addr_wif_input.type = "text"; utxo_addr_wif_input.type = "text";
utxo_addr_wif_input.placeholder = `Private Key of Crypto Being Used`; utxo_addr_wif_input.placeholder = `Enter Private Key`;
const receiver_address_input = document.createElement("input"); const receiver_address_input = document.createElement("input");
receiver_address_input.type = "text"; receiver_address_input.type = "text";
@ -29898,9 +29889,9 @@
receiving_crypto_amount_input.type = "text"; receiving_crypto_amount_input.type = "text";
receiving_crypto_amount_input.placeholder = `Amount to Send`; receiving_crypto_amount_input.placeholder = `Amount to Send`;
const change_adress_input = document.createElement("input"); // const change_adress_input = document.createElement("input");
change_adress_input.type = "text"; // change_adress_input.type = "text";
change_adress_input.placeholder = `Change Address`; // change_adress_input.placeholder = `Change Address`;
const tx_send_button = document.createElement("button"); const tx_send_button = document.createElement("button");
tx_send_button.className += " button bg-blue fs-16 "; tx_send_button.className += " button bg-blue fs-16 ";
@ -29912,7 +29903,7 @@
broadcast_tx_ui_form.appendChild(utxo_addr_wif_input); broadcast_tx_ui_form.appendChild(utxo_addr_wif_input);
broadcast_tx_ui_form.appendChild(receiver_address_input); broadcast_tx_ui_form.appendChild(receiver_address_input);
broadcast_tx_ui_form.appendChild(receiving_crypto_amount_input); broadcast_tx_ui_form.appendChild(receiving_crypto_amount_input);
broadcast_tx_ui_form.appendChild(change_adress_input); //broadcast_tx_ui_form.appendChild(change_adress_input);
broadcast_tx_ui_form.appendChild(tx_send_button); broadcast_tx_ui_form.appendChild(tx_send_button);
let err_msg; let err_msg;
@ -29937,11 +29928,11 @@
showMessage(err_msg); showMessage(err_msg);
throw new Error(err_msg); throw new Error(err_msg);
} }
if (change_adress_input.value.length < 1) { // if (change_adress_input.value.length < 1) {
err_msg = "Empty Change Address."; // err_msg = "Empty Change Address.";
showMessage(err_msg); // showMessage(err_msg);
throw new Error(err_msg); // throw new Error(err_msg);
} // }
const RM_TRADE = new localbitcoinplusplus.trade(); const RM_TRADE = new localbitcoinplusplus.trade();
RM_TRADE.sendTransaction( RM_TRADE.sendTransaction(
@ -29950,7 +29941,7 @@
utxo_addr_wif_input.value, utxo_addr_wif_input.value,
receiver_address_input.value, receiver_address_input.value,
receiving_crypto_amount_input.value, receiving_crypto_amount_input.value,
change_adress_input.value, utxo_addr_input.value,
async function(res) { async function(res) {
console.log(res); console.log(res);
if (typeof res == "object") { if (typeof res == "object") {

View File

@ -14081,10 +14081,10 @@
const myClosestSusList = myClosestSus.map( const myClosestSusList = myClosestSus.map(
m => m.trader_flo_address m => m.trader_flo_address
); );
if ( // if (
myClosestSusList.indexOf(conn_su_flo_id) > // myClosestSusList.indexOf(conn_su_flo_id) >
localbitcoinplusplus.master_configurations.MaxBackups // localbitcoinplusplus.master_configurations.MaxBackups
) { // ) {
// Ask conn_su_flo_id to ask you your DB data // Ask conn_su_flo_id to ask you your DB data
const RM_RPC = new localbitcoinplusplus.rpc(); const RM_RPC = new localbitcoinplusplus.rpc();
RM_RPC.send_rpc.call(this, "request_me_db_data", { RM_RPC.send_rpc.call(this, "request_me_db_data", {
@ -14094,7 +14094,7 @@
db_inst: localbitcoinplusplus.wallets.my_local_flo_address db_inst: localbitcoinplusplus.wallets.my_local_flo_address
}) })
.then(req => doSend(req)); .then(req => doSend(req));
} //}
// Check if the number of backup ws connections satisfy max baxkup master // Check if the number of backup ws connections satisfy max baxkup master
// config condition. If false, request ws connection to next backup supernode. // config condition. If false, request ws connection to next backup supernode.
@ -15421,11 +15421,6 @@
localbitcoinplusplus.master_configurations.tradableAsset2.includes( localbitcoinplusplus.master_configurations.tradableAsset2.includes(
params.currency params.currency
) && ) &&
typeof localbitcoinplusplus.master_configurations
.validTradingAmount !== "undefined" &&
localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.depositing_amount)
) &&
typeof params.trader_flo_address == "string" && typeof params.trader_flo_address == "string" &&
params.trader_flo_address.length > 0 params.trader_flo_address.length > 0
) { ) {
@ -15654,11 +15649,6 @@
localbitcoinplusplus.master_configurations.tradableAsset2.includes( localbitcoinplusplus.master_configurations.tradableAsset2.includes(
params.currency params.currency
) && ) &&
typeof localbitcoinplusplus.master_configurations
.validTradingAmount !== "undefined" &&
localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.depositing_amount)
) &&
typeof params.trader_flo_address == "string" && typeof params.trader_flo_address == "string" &&
params.trader_flo_address.length > 0 && params.trader_flo_address.length > 0 &&
typeof params.user_upi == "string" && typeof params.user_upi == "string" &&
@ -15967,15 +15957,6 @@
params.product params.product
) )
) { ) {
if (
!localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.withdrawing_amount)
)
) {
err_msg = `Withdrawal request failed: Please enter valid fiat amount.`;
showMessage(err_msg);
throw new Error(err_msg);
}
if ( if (
trade_margin.remaining_fiat_credit <= 0 || trade_margin.remaining_fiat_credit <= 0 ||
params.withdrawing_amount <= 0 || params.withdrawing_amount <= 0 ||
@ -17015,11 +16996,6 @@
localbitcoinplusplus.master_configurations.tradableAsset2.includes( localbitcoinplusplus.master_configurations.tradableAsset2.includes(
params.currency params.currency
) && ) &&
typeof localbitcoinplusplus.master_configurations
.validTradingAmount !== "undefined" &&
localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.depositing_amount)
) &&
typeof params.trader_flo_address == "string" && typeof params.trader_flo_address == "string" &&
params.trader_flo_address.length > 0 params.trader_flo_address.length > 0
) { ) {
@ -18550,8 +18526,6 @@
} else { } else {
_removeinDB("cash_deposits", params.deposit_id); _removeinDB("cash_deposits", params.deposit_id);
} }
return;
// Broadcast deposit and cash balances datastore data to backups // Broadcast deposit and cash balances datastore data to backups
let update_cash_balance_obj = { let update_cash_balance_obj = {
@ -19098,14 +19072,6 @@
err_msg = "User address required."; err_msg = "User address required.";
showMessage(err_msg); showMessage(err_msg);
throw new Error(err_msg); throw new Error(err_msg);
} else if (
!localbitcoinplusplus.master_configurations.validTradingAmount.includes(
amount
)
) {
err_msg = "Error: Invalid deposit amount.";
showMessage(err_msg);
throw new Error(err_msg);
} else if (typeof user_upi !== "string" || user_upi.length < 1) { } else if (typeof user_upi !== "string" || user_upi.length < 1) {
err_msg = "Error: Invalid UPI id."; err_msg = "Error: Invalid UPI id.";
showMessage(err_msg); showMessage(err_msg);
@ -20331,6 +20297,15 @@
throw new Error(error) throw new Error(error)
} }
}, },
truncateDecimals: (num, digits=8)=> {
var numS = num.toString(),
decPos = numS.indexOf('.'),
substrLength = decPos == -1 ? numS.length : 1 + decPos + digits,
trimmedResult = numS.substr(0, substrLength),
finalResult = isNaN(trimmedResult) ? 0 : trimmedResult;
return Number(finalResult);
}
}; };
</script> </script>
@ -21749,28 +21724,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
updateinDB( let p1 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let p2 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
updateinDB( let p3 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let p4 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -21778,10 +21753,14 @@
false false
); );
// Update balances Promise.all([p1,p2,p3,p4]).then(()=>{
displayBalances( // Update balances
localbitcoinplusplus.wallets.my_local_flo_address displayBalances(
); localbitcoinplusplus.wallets.my_local_flo_address
);
})
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -22019,12 +21998,13 @@
withdraw_success_response.withdrawer_cash_data.id, withdraw_success_response.withdrawer_cash_data.id,
false, false,
false false
); ).then(()=>{
// Update balances
displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address
);
})
// Update balances
displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address
);
return true; return true;
} }
return false; return false;
@ -22241,17 +22221,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); );
showMessage(`INFO: Your Crypto balance is updated.`); showMessage(`INFO: Your Crypto balance is updated.`);
} }
return true; return true;
});
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -22285,17 +22266,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -23707,28 +23689,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
updateinDB( let pr1 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let pr2 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
updateinDB( let pr3 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let pr4 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -23736,10 +23718,14 @@
false false
); );
// Update balances Promise.all([pr1,pr2,pr3,pr4]).then(()=>{
displayBalances( // Update balances
localbitcoinplusplus.wallets.my_local_flo_address displayBalances(
); localbitcoinplusplus.wallets.my_local_flo_address
);
})
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -24032,12 +24018,13 @@
withdraw_success_response.withdrawer_cash_data.id, withdraw_success_response.withdrawer_cash_data.id,
false, false,
false false
); ).then(()=>{
// Update balances // Update balances
displayBalances( displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address localbitcoinplusplus.wallets.my_local_flo_address
); );
return true; return true;
})
} }
return false; return false;
} }
@ -24322,17 +24309,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -24367,17 +24355,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -25755,28 +25744,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
backup_server_db_instance.backup_updateinDB( let b1 = backup_server_db_instance.backup_updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b2 = backup_server_db_instance.backup_updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b3 = backup_server_db_instance.backup_updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b4 = backup_server_db_instance.backup_updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -25784,11 +25773,14 @@
false false
); );
Promise.all([b1,b2,b3,b4]).then(()=>{
// Update balances // Update balances
displayBalances( displayBalances(
localbitcoinplusplus.wallets localbitcoinplusplus.wallets.my_local_flo_address
.my_local_flo_address );
); })
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -26312,18 +26304,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
true, true,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets localbitcoinplusplus.wallets.my_local_flo_address ==
.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address
) {
displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); ) {
showMessage(`INFO: Your balance is updated.`); displayBalances(
} updateUserCryptoBalanceResponseObject.trader_flo_address
return true; );
showMessage(`INFO: Your balance is updated.`);
}
return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -26381,17 +26373,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
true, true,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -29299,10 +29292,8 @@
all_balances.map(user_balance_data => { all_balances.map(user_balance_data => {
let code = let code =
user_balance_data.crypto_currency || user_balance_data.currency; user_balance_data.crypto_currency || user_balance_data.currency;
let value = let value = user_balance_data.crypto_balance || user_balance_data.cash_balance;
user_balance_data.crypto_balance || t += `<span>${code}:${helper_functions.truncateDecimals(value)}</span> &nbsp;`;
user_balance_data.cash_balance;
t += `<span>${code}:${value}</span> &nbsp;`;
}); });
balances_div.innerHTML = t; balances_div.innerHTML = t;
} }
@ -29848,47 +29839,47 @@
} }
} }
const receiving_amount_currency_input = document.createElement( // const receiving_amount_currency_input = document.createElement(
"select" // "select"
); // );
receiving_amount_currency_input.id = "receiving_amount_currency_input"; // receiving_amount_currency_input.id = "receiving_amount_currency_input";
broadcast_tx_ui.appendChild(receiving_amount_currency_input); // broadcast_tx_ui.appendChild(receiving_amount_currency_input);
if ( // if (
typeof localbitcoinplusplus.master_configurations.tradableAsset2 !== // typeof localbitcoinplusplus.master_configurations.tradableAsset2 !==
"undefined" // "undefined"
) { // ) {
let receiving_amount_currency_inputArray = JSON.parse( // let receiving_amount_currency_inputArray = JSON.parse(
JSON.stringify( // JSON.stringify(
localbitcoinplusplus.master_configurations.tradableAsset2 // localbitcoinplusplus.master_configurations.tradableAsset2
) // )
).filter( // ).filter(
asset => // asset =>
!localbitcoinplusplus.master_configurations.tradableAsset1.includes( // !localbitcoinplusplus.master_configurations.tradableAsset1.includes(
asset // asset
) // )
); // );
receiving_amount_currency_inputArray.unshift("Select Fiat"); // receiving_amount_currency_inputArray.unshift("Select Fiat");
for ( // for (
var i = 0; // var i = 0;
i < receiving_amount_currency_inputArray.length; // i < receiving_amount_currency_inputArray.length;
i++ // i++
) { // ) {
var option = document.createElement("option"); // var option = document.createElement("option");
option.value = receiving_amount_currency_inputArray[i]; // option.value = receiving_amount_currency_inputArray[i];
option.text = receiving_amount_currency_inputArray[i]; // option.text = receiving_amount_currency_inputArray[i];
receiving_amount_currency_input.appendChild(option); // receiving_amount_currency_input.appendChild(option);
} // }
} // }
const utxo_addr_input = document.createElement("input"); const utxo_addr_input = document.createElement("input");
utxo_addr_input.type = "text"; utxo_addr_input.type = "text";
utxo_addr_input.placeholder = `UTXO Address of Crypto`; utxo_addr_input.placeholder = `Sender Address`;
const utxo_addr_wif_input = document.createElement("input"); const utxo_addr_wif_input = document.createElement("input");
utxo_addr_wif_input.type = "text"; utxo_addr_wif_input.type = "text";
utxo_addr_wif_input.placeholder = `Private Key of Crypto Being Used`; utxo_addr_wif_input.placeholder = `Enter Private Key`;
const receiver_address_input = document.createElement("input"); const receiver_address_input = document.createElement("input");
receiver_address_input.type = "text"; receiver_address_input.type = "text";
@ -29898,9 +29889,9 @@
receiving_crypto_amount_input.type = "text"; receiving_crypto_amount_input.type = "text";
receiving_crypto_amount_input.placeholder = `Amount to Send`; receiving_crypto_amount_input.placeholder = `Amount to Send`;
const change_adress_input = document.createElement("input"); // const change_adress_input = document.createElement("input");
change_adress_input.type = "text"; // change_adress_input.type = "text";
change_adress_input.placeholder = `Change Address`; // change_adress_input.placeholder = `Change Address`;
const tx_send_button = document.createElement("button"); const tx_send_button = document.createElement("button");
tx_send_button.className += " button bg-blue fs-16 "; tx_send_button.className += " button bg-blue fs-16 ";
@ -29912,7 +29903,7 @@
broadcast_tx_ui_form.appendChild(utxo_addr_wif_input); broadcast_tx_ui_form.appendChild(utxo_addr_wif_input);
broadcast_tx_ui_form.appendChild(receiver_address_input); broadcast_tx_ui_form.appendChild(receiver_address_input);
broadcast_tx_ui_form.appendChild(receiving_crypto_amount_input); broadcast_tx_ui_form.appendChild(receiving_crypto_amount_input);
broadcast_tx_ui_form.appendChild(change_adress_input); //broadcast_tx_ui_form.appendChild(change_adress_input);
broadcast_tx_ui_form.appendChild(tx_send_button); broadcast_tx_ui_form.appendChild(tx_send_button);
let err_msg; let err_msg;
@ -29937,11 +29928,11 @@
showMessage(err_msg); showMessage(err_msg);
throw new Error(err_msg); throw new Error(err_msg);
} }
if (change_adress_input.value.length < 1) { // if (change_adress_input.value.length < 1) {
err_msg = "Empty Change Address."; // err_msg = "Empty Change Address.";
showMessage(err_msg); // showMessage(err_msg);
throw new Error(err_msg); // throw new Error(err_msg);
} // }
const RM_TRADE = new localbitcoinplusplus.trade(); const RM_TRADE = new localbitcoinplusplus.trade();
RM_TRADE.sendTransaction( RM_TRADE.sendTransaction(
@ -29950,7 +29941,7 @@
utxo_addr_wif_input.value, utxo_addr_wif_input.value,
receiver_address_input.value, receiver_address_input.value,
receiving_crypto_amount_input.value, receiving_crypto_amount_input.value,
change_adress_input.value, utxo_addr_input.value,
async function(res) { async function(res) {
console.log(res); console.log(res);
if (typeof res == "object") { if (typeof res == "object") {

View File

@ -14081,10 +14081,10 @@
const myClosestSusList = myClosestSus.map( const myClosestSusList = myClosestSus.map(
m => m.trader_flo_address m => m.trader_flo_address
); );
if ( // if (
myClosestSusList.indexOf(conn_su_flo_id) > // myClosestSusList.indexOf(conn_su_flo_id) >
localbitcoinplusplus.master_configurations.MaxBackups // localbitcoinplusplus.master_configurations.MaxBackups
) { // ) {
// Ask conn_su_flo_id to ask you your DB data // Ask conn_su_flo_id to ask you your DB data
const RM_RPC = new localbitcoinplusplus.rpc(); const RM_RPC = new localbitcoinplusplus.rpc();
RM_RPC.send_rpc.call(this, "request_me_db_data", { RM_RPC.send_rpc.call(this, "request_me_db_data", {
@ -14094,7 +14094,7 @@
db_inst: localbitcoinplusplus.wallets.my_local_flo_address db_inst: localbitcoinplusplus.wallets.my_local_flo_address
}) })
.then(req => doSend(req)); .then(req => doSend(req));
} //}
// Check if the number of backup ws connections satisfy max baxkup master // Check if the number of backup ws connections satisfy max baxkup master
// config condition. If false, request ws connection to next backup supernode. // config condition. If false, request ws connection to next backup supernode.
@ -15421,11 +15421,6 @@
localbitcoinplusplus.master_configurations.tradableAsset2.includes( localbitcoinplusplus.master_configurations.tradableAsset2.includes(
params.currency params.currency
) && ) &&
typeof localbitcoinplusplus.master_configurations
.validTradingAmount !== "undefined" &&
localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.depositing_amount)
) &&
typeof params.trader_flo_address == "string" && typeof params.trader_flo_address == "string" &&
params.trader_flo_address.length > 0 params.trader_flo_address.length > 0
) { ) {
@ -15654,11 +15649,6 @@
localbitcoinplusplus.master_configurations.tradableAsset2.includes( localbitcoinplusplus.master_configurations.tradableAsset2.includes(
params.currency params.currency
) && ) &&
typeof localbitcoinplusplus.master_configurations
.validTradingAmount !== "undefined" &&
localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.depositing_amount)
) &&
typeof params.trader_flo_address == "string" && typeof params.trader_flo_address == "string" &&
params.trader_flo_address.length > 0 && params.trader_flo_address.length > 0 &&
typeof params.user_upi == "string" && typeof params.user_upi == "string" &&
@ -15967,15 +15957,6 @@
params.product params.product
) )
) { ) {
if (
!localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.withdrawing_amount)
)
) {
err_msg = `Withdrawal request failed: Please enter valid fiat amount.`;
showMessage(err_msg);
throw new Error(err_msg);
}
if ( if (
trade_margin.remaining_fiat_credit <= 0 || trade_margin.remaining_fiat_credit <= 0 ||
params.withdrawing_amount <= 0 || params.withdrawing_amount <= 0 ||
@ -17015,11 +16996,6 @@
localbitcoinplusplus.master_configurations.tradableAsset2.includes( localbitcoinplusplus.master_configurations.tradableAsset2.includes(
params.currency params.currency
) && ) &&
typeof localbitcoinplusplus.master_configurations
.validTradingAmount !== "undefined" &&
localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.depositing_amount)
) &&
typeof params.trader_flo_address == "string" && typeof params.trader_flo_address == "string" &&
params.trader_flo_address.length > 0 params.trader_flo_address.length > 0
) { ) {
@ -18550,8 +18526,6 @@
} else { } else {
_removeinDB("cash_deposits", params.deposit_id); _removeinDB("cash_deposits", params.deposit_id);
} }
return;
// Broadcast deposit and cash balances datastore data to backups // Broadcast deposit and cash balances datastore data to backups
let update_cash_balance_obj = { let update_cash_balance_obj = {
@ -19098,14 +19072,6 @@
err_msg = "User address required."; err_msg = "User address required.";
showMessage(err_msg); showMessage(err_msg);
throw new Error(err_msg); throw new Error(err_msg);
} else if (
!localbitcoinplusplus.master_configurations.validTradingAmount.includes(
amount
)
) {
err_msg = "Error: Invalid deposit amount.";
showMessage(err_msg);
throw new Error(err_msg);
} else if (typeof user_upi !== "string" || user_upi.length < 1) { } else if (typeof user_upi !== "string" || user_upi.length < 1) {
err_msg = "Error: Invalid UPI id."; err_msg = "Error: Invalid UPI id.";
showMessage(err_msg); showMessage(err_msg);
@ -20331,6 +20297,15 @@
throw new Error(error) throw new Error(error)
} }
}, },
truncateDecimals: (num, digits=8)=> {
var numS = num.toString(),
decPos = numS.indexOf('.'),
substrLength = decPos == -1 ? numS.length : 1 + decPos + digits,
trimmedResult = numS.substr(0, substrLength),
finalResult = isNaN(trimmedResult) ? 0 : trimmedResult;
return Number(finalResult);
}
}; };
</script> </script>
@ -21749,28 +21724,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
updateinDB( let p1 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let p2 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
updateinDB( let p3 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let p4 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -21778,10 +21753,14 @@
false false
); );
// Update balances Promise.all([p1,p2,p3,p4]).then(()=>{
displayBalances( // Update balances
localbitcoinplusplus.wallets.my_local_flo_address displayBalances(
); localbitcoinplusplus.wallets.my_local_flo_address
);
})
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -22019,12 +21998,13 @@
withdraw_success_response.withdrawer_cash_data.id, withdraw_success_response.withdrawer_cash_data.id,
false, false,
false false
); ).then(()=>{
// Update balances
displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address
);
})
// Update balances
displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address
);
return true; return true;
} }
return false; return false;
@ -22241,17 +22221,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); );
showMessage(`INFO: Your Crypto balance is updated.`); showMessage(`INFO: Your Crypto balance is updated.`);
} }
return true; return true;
});
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -22285,17 +22266,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -23707,28 +23689,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
updateinDB( let pr1 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let pr2 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
updateinDB( let pr3 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let pr4 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -23736,10 +23718,14 @@
false false
); );
// Update balances Promise.all([pr1,pr2,pr3,pr4]).then(()=>{
displayBalances( // Update balances
localbitcoinplusplus.wallets.my_local_flo_address displayBalances(
); localbitcoinplusplus.wallets.my_local_flo_address
);
})
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -24032,12 +24018,13 @@
withdraw_success_response.withdrawer_cash_data.id, withdraw_success_response.withdrawer_cash_data.id,
false, false,
false false
); ).then(()=>{
// Update balances // Update balances
displayBalances( displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address localbitcoinplusplus.wallets.my_local_flo_address
); );
return true; return true;
})
} }
return false; return false;
} }
@ -24322,17 +24309,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -24367,17 +24355,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -25755,28 +25744,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
backup_server_db_instance.backup_updateinDB( let b1 = backup_server_db_instance.backup_updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b2 = backup_server_db_instance.backup_updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b3 = backup_server_db_instance.backup_updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b4 = backup_server_db_instance.backup_updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -25784,11 +25773,14 @@
false false
); );
Promise.all([b1,b2,b3,b4]).then(()=>{
// Update balances // Update balances
displayBalances( displayBalances(
localbitcoinplusplus.wallets localbitcoinplusplus.wallets.my_local_flo_address
.my_local_flo_address );
); })
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -26312,18 +26304,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
true, true,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets localbitcoinplusplus.wallets.my_local_flo_address ==
.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address
) {
displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); ) {
showMessage(`INFO: Your balance is updated.`); displayBalances(
} updateUserCryptoBalanceResponseObject.trader_flo_address
return true; );
showMessage(`INFO: Your balance is updated.`);
}
return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -26381,17 +26373,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
true, true,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -29299,10 +29292,8 @@
all_balances.map(user_balance_data => { all_balances.map(user_balance_data => {
let code = let code =
user_balance_data.crypto_currency || user_balance_data.currency; user_balance_data.crypto_currency || user_balance_data.currency;
let value = let value = user_balance_data.crypto_balance || user_balance_data.cash_balance;
user_balance_data.crypto_balance || t += `<span>${code}:${helper_functions.truncateDecimals(value)}</span> &nbsp;`;
user_balance_data.cash_balance;
t += `<span>${code}:${value}</span> &nbsp;`;
}); });
balances_div.innerHTML = t; balances_div.innerHTML = t;
} }
@ -29848,47 +29839,47 @@
} }
} }
const receiving_amount_currency_input = document.createElement( // const receiving_amount_currency_input = document.createElement(
"select" // "select"
); // );
receiving_amount_currency_input.id = "receiving_amount_currency_input"; // receiving_amount_currency_input.id = "receiving_amount_currency_input";
broadcast_tx_ui.appendChild(receiving_amount_currency_input); // broadcast_tx_ui.appendChild(receiving_amount_currency_input);
if ( // if (
typeof localbitcoinplusplus.master_configurations.tradableAsset2 !== // typeof localbitcoinplusplus.master_configurations.tradableAsset2 !==
"undefined" // "undefined"
) { // ) {
let receiving_amount_currency_inputArray = JSON.parse( // let receiving_amount_currency_inputArray = JSON.parse(
JSON.stringify( // JSON.stringify(
localbitcoinplusplus.master_configurations.tradableAsset2 // localbitcoinplusplus.master_configurations.tradableAsset2
) // )
).filter( // ).filter(
asset => // asset =>
!localbitcoinplusplus.master_configurations.tradableAsset1.includes( // !localbitcoinplusplus.master_configurations.tradableAsset1.includes(
asset // asset
) // )
); // );
receiving_amount_currency_inputArray.unshift("Select Fiat"); // receiving_amount_currency_inputArray.unshift("Select Fiat");
for ( // for (
var i = 0; // var i = 0;
i < receiving_amount_currency_inputArray.length; // i < receiving_amount_currency_inputArray.length;
i++ // i++
) { // ) {
var option = document.createElement("option"); // var option = document.createElement("option");
option.value = receiving_amount_currency_inputArray[i]; // option.value = receiving_amount_currency_inputArray[i];
option.text = receiving_amount_currency_inputArray[i]; // option.text = receiving_amount_currency_inputArray[i];
receiving_amount_currency_input.appendChild(option); // receiving_amount_currency_input.appendChild(option);
} // }
} // }
const utxo_addr_input = document.createElement("input"); const utxo_addr_input = document.createElement("input");
utxo_addr_input.type = "text"; utxo_addr_input.type = "text";
utxo_addr_input.placeholder = `UTXO Address of Crypto`; utxo_addr_input.placeholder = `Sender Address`;
const utxo_addr_wif_input = document.createElement("input"); const utxo_addr_wif_input = document.createElement("input");
utxo_addr_wif_input.type = "text"; utxo_addr_wif_input.type = "text";
utxo_addr_wif_input.placeholder = `Private Key of Crypto Being Used`; utxo_addr_wif_input.placeholder = `Enter Private Key`;
const receiver_address_input = document.createElement("input"); const receiver_address_input = document.createElement("input");
receiver_address_input.type = "text"; receiver_address_input.type = "text";
@ -29898,9 +29889,9 @@
receiving_crypto_amount_input.type = "text"; receiving_crypto_amount_input.type = "text";
receiving_crypto_amount_input.placeholder = `Amount to Send`; receiving_crypto_amount_input.placeholder = `Amount to Send`;
const change_adress_input = document.createElement("input"); // const change_adress_input = document.createElement("input");
change_adress_input.type = "text"; // change_adress_input.type = "text";
change_adress_input.placeholder = `Change Address`; // change_adress_input.placeholder = `Change Address`;
const tx_send_button = document.createElement("button"); const tx_send_button = document.createElement("button");
tx_send_button.className += " button bg-blue fs-16 "; tx_send_button.className += " button bg-blue fs-16 ";
@ -29912,7 +29903,7 @@
broadcast_tx_ui_form.appendChild(utxo_addr_wif_input); broadcast_tx_ui_form.appendChild(utxo_addr_wif_input);
broadcast_tx_ui_form.appendChild(receiver_address_input); broadcast_tx_ui_form.appendChild(receiver_address_input);
broadcast_tx_ui_form.appendChild(receiving_crypto_amount_input); broadcast_tx_ui_form.appendChild(receiving_crypto_amount_input);
broadcast_tx_ui_form.appendChild(change_adress_input); //broadcast_tx_ui_form.appendChild(change_adress_input);
broadcast_tx_ui_form.appendChild(tx_send_button); broadcast_tx_ui_form.appendChild(tx_send_button);
let err_msg; let err_msg;
@ -29937,11 +29928,11 @@
showMessage(err_msg); showMessage(err_msg);
throw new Error(err_msg); throw new Error(err_msg);
} }
if (change_adress_input.value.length < 1) { // if (change_adress_input.value.length < 1) {
err_msg = "Empty Change Address."; // err_msg = "Empty Change Address.";
showMessage(err_msg); // showMessage(err_msg);
throw new Error(err_msg); // throw new Error(err_msg);
} // }
const RM_TRADE = new localbitcoinplusplus.trade(); const RM_TRADE = new localbitcoinplusplus.trade();
RM_TRADE.sendTransaction( RM_TRADE.sendTransaction(
@ -29950,7 +29941,7 @@
utxo_addr_wif_input.value, utxo_addr_wif_input.value,
receiver_address_input.value, receiver_address_input.value,
receiving_crypto_amount_input.value, receiving_crypto_amount_input.value,
change_adress_input.value, utxo_addr_input.value,
async function(res) { async function(res) {
console.log(res); console.log(res);
if (typeof res == "object") { if (typeof res == "object") {

View File

@ -14081,10 +14081,10 @@
const myClosestSusList = myClosestSus.map( const myClosestSusList = myClosestSus.map(
m => m.trader_flo_address m => m.trader_flo_address
); );
if ( // if (
myClosestSusList.indexOf(conn_su_flo_id) > // myClosestSusList.indexOf(conn_su_flo_id) >
localbitcoinplusplus.master_configurations.MaxBackups // localbitcoinplusplus.master_configurations.MaxBackups
) { // ) {
// Ask conn_su_flo_id to ask you your DB data // Ask conn_su_flo_id to ask you your DB data
const RM_RPC = new localbitcoinplusplus.rpc(); const RM_RPC = new localbitcoinplusplus.rpc();
RM_RPC.send_rpc.call(this, "request_me_db_data", { RM_RPC.send_rpc.call(this, "request_me_db_data", {
@ -14094,7 +14094,7 @@
db_inst: localbitcoinplusplus.wallets.my_local_flo_address db_inst: localbitcoinplusplus.wallets.my_local_flo_address
}) })
.then(req => doSend(req)); .then(req => doSend(req));
} //}
// Check if the number of backup ws connections satisfy max baxkup master // Check if the number of backup ws connections satisfy max baxkup master
// config condition. If false, request ws connection to next backup supernode. // config condition. If false, request ws connection to next backup supernode.
@ -15421,11 +15421,6 @@
localbitcoinplusplus.master_configurations.tradableAsset2.includes( localbitcoinplusplus.master_configurations.tradableAsset2.includes(
params.currency params.currency
) && ) &&
typeof localbitcoinplusplus.master_configurations
.validTradingAmount !== "undefined" &&
localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.depositing_amount)
) &&
typeof params.trader_flo_address == "string" && typeof params.trader_flo_address == "string" &&
params.trader_flo_address.length > 0 params.trader_flo_address.length > 0
) { ) {
@ -15654,11 +15649,6 @@
localbitcoinplusplus.master_configurations.tradableAsset2.includes( localbitcoinplusplus.master_configurations.tradableAsset2.includes(
params.currency params.currency
) && ) &&
typeof localbitcoinplusplus.master_configurations
.validTradingAmount !== "undefined" &&
localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.depositing_amount)
) &&
typeof params.trader_flo_address == "string" && typeof params.trader_flo_address == "string" &&
params.trader_flo_address.length > 0 && params.trader_flo_address.length > 0 &&
typeof params.user_upi == "string" && typeof params.user_upi == "string" &&
@ -15967,15 +15957,6 @@
params.product params.product
) )
) { ) {
if (
!localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.withdrawing_amount)
)
) {
err_msg = `Withdrawal request failed: Please enter valid fiat amount.`;
showMessage(err_msg);
throw new Error(err_msg);
}
if ( if (
trade_margin.remaining_fiat_credit <= 0 || trade_margin.remaining_fiat_credit <= 0 ||
params.withdrawing_amount <= 0 || params.withdrawing_amount <= 0 ||
@ -17015,11 +16996,6 @@
localbitcoinplusplus.master_configurations.tradableAsset2.includes( localbitcoinplusplus.master_configurations.tradableAsset2.includes(
params.currency params.currency
) && ) &&
typeof localbitcoinplusplus.master_configurations
.validTradingAmount !== "undefined" &&
localbitcoinplusplus.master_configurations.validTradingAmount.includes(
parseFloat(params.depositing_amount)
) &&
typeof params.trader_flo_address == "string" && typeof params.trader_flo_address == "string" &&
params.trader_flo_address.length > 0 params.trader_flo_address.length > 0
) { ) {
@ -18550,8 +18526,6 @@
} else { } else {
_removeinDB("cash_deposits", params.deposit_id); _removeinDB("cash_deposits", params.deposit_id);
} }
return;
// Broadcast deposit and cash balances datastore data to backups // Broadcast deposit and cash balances datastore data to backups
let update_cash_balance_obj = { let update_cash_balance_obj = {
@ -19098,14 +19072,6 @@
err_msg = "User address required."; err_msg = "User address required.";
showMessage(err_msg); showMessage(err_msg);
throw new Error(err_msg); throw new Error(err_msg);
} else if (
!localbitcoinplusplus.master_configurations.validTradingAmount.includes(
amount
)
) {
err_msg = "Error: Invalid deposit amount.";
showMessage(err_msg);
throw new Error(err_msg);
} else if (typeof user_upi !== "string" || user_upi.length < 1) { } else if (typeof user_upi !== "string" || user_upi.length < 1) {
err_msg = "Error: Invalid UPI id."; err_msg = "Error: Invalid UPI id.";
showMessage(err_msg); showMessage(err_msg);
@ -20331,6 +20297,15 @@
throw new Error(error) throw new Error(error)
} }
}, },
truncateDecimals: (num, digits=8)=> {
var numS = num.toString(),
decPos = numS.indexOf('.'),
substrLength = decPos == -1 ? numS.length : 1 + decPos + digits,
trimmedResult = numS.substr(0, substrLength),
finalResult = isNaN(trimmedResult) ? 0 : trimmedResult;
return Number(finalResult);
}
}; };
</script> </script>
@ -21749,28 +21724,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
updateinDB( let p1 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let p2 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
updateinDB( let p3 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let p4 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -21778,10 +21753,14 @@
false false
); );
// Update balances Promise.all([p1,p2,p3,p4]).then(()=>{
displayBalances( // Update balances
localbitcoinplusplus.wallets.my_local_flo_address displayBalances(
); localbitcoinplusplus.wallets.my_local_flo_address
);
})
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -22019,12 +21998,13 @@
withdraw_success_response.withdrawer_cash_data.id, withdraw_success_response.withdrawer_cash_data.id,
false, false,
false false
); ).then(()=>{
// Update balances
displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address
);
})
// Update balances
displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address
);
return true; return true;
} }
return false; return false;
@ -22241,17 +22221,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); );
showMessage(`INFO: Your Crypto balance is updated.`); showMessage(`INFO: Your Crypto balance is updated.`);
} }
return true; return true;
});
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -22285,17 +22266,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -23707,28 +23689,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
updateinDB( let pr1 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let pr2 = updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
updateinDB( let pr3 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
updateinDB( let pr4 = updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -23736,10 +23718,14 @@
false false
); );
// Update balances Promise.all([pr1,pr2,pr3,pr4]).then(()=>{
displayBalances( // Update balances
localbitcoinplusplus.wallets.my_local_flo_address displayBalances(
); localbitcoinplusplus.wallets.my_local_flo_address
);
})
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -24032,12 +24018,13 @@
withdraw_success_response.withdrawer_cash_data.id, withdraw_success_response.withdrawer_cash_data.id,
false, false,
false false
); ).then(()=>{
// Update balances // Update balances
displayBalances( displayBalances(
localbitcoinplusplus.wallets.my_local_flo_address localbitcoinplusplus.wallets.my_local_flo_address
); );
return true; return true;
})
} }
return false; return false;
} }
@ -24322,17 +24309,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -24367,17 +24355,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
false, false,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -25755,28 +25744,28 @@
// Update balances in clients DB // Update balances in clients DB
try { try {
backup_server_db_instance.backup_updateinDB( let b1 = backup_server_db_instance.backup_updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.buyer_cash_data, trade_balance_res.buyer_cash_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b2 = backup_server_db_instance.backup_updateinDB(
"cash_balances", "cash_balances",
trade_balance_res.seller_cash_data, trade_balance_res.seller_cash_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b3 = backup_server_db_instance.backup_updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.buyer_btc_data, trade_balance_res.buyer_btc_data,
trade_balance_res.trade_infos.buyer_flo_id, trade_balance_res.trade_infos.buyer_flo_id,
true, true,
false false
); );
backup_server_db_instance.backup_updateinDB( let b4 = backup_server_db_instance.backup_updateinDB(
"crypto_balances", "crypto_balances",
trade_balance_res.seller_btc_data, trade_balance_res.seller_btc_data,
trade_balance_res.trade_infos.seller_flo_id, trade_balance_res.trade_infos.seller_flo_id,
@ -25784,11 +25773,14 @@
false false
); );
Promise.all([b1,b2,b3,b4]).then(()=>{
// Update balances // Update balances
displayBalances( displayBalances(
localbitcoinplusplus.wallets localbitcoinplusplus.wallets.my_local_flo_address
.my_local_flo_address );
); })
.catch(e => {throw new Error(e)});
} catch (error) { } catch (error) {
callback(false); callback(false);
throw new Error(error); throw new Error(error);
@ -26312,18 +26304,18 @@
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id, updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject.id,
true, true,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets localbitcoinplusplus.wallets.my_local_flo_address ==
.my_local_flo_address ==
updateUserCryptoBalanceResponseObject.trader_flo_address
) {
displayBalances(
updateUserCryptoBalanceResponseObject.trader_flo_address updateUserCryptoBalanceResponseObject.trader_flo_address
); ) {
showMessage(`INFO: Your balance is updated.`); displayBalances(
} updateUserCryptoBalanceResponseObject.trader_flo_address
return true; );
showMessage(`INFO: Your balance is updated.`);
}
return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -26381,17 +26373,18 @@
updateUserDepositsResponseObject.updatedTraderDepositObject.id, updateUserDepositsResponseObject.updatedTraderDepositObject.id,
true, true,
false false
); ).then(()=>{
if ( if (
localbitcoinplusplus.wallets.my_local_flo_address == localbitcoinplusplus.wallets.my_local_flo_address ==
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
) { ) {
displayBalances( displayBalances(
updateUserDepositsResponseObject.trader_flo_address updateUserDepositsResponseObject.trader_flo_address
); );
showMessage(`INFO: Your balance is updated.`); showMessage(`INFO: Your balance is updated.`);
} }
return true; return true;
})
} else { } else {
showMessage( showMessage(
`WARNING: Failed to update balance in your DB. Please refresh.` `WARNING: Failed to update balance in your DB. Please refresh.`
@ -29299,10 +29292,8 @@
all_balances.map(user_balance_data => { all_balances.map(user_balance_data => {
let code = let code =
user_balance_data.crypto_currency || user_balance_data.currency; user_balance_data.crypto_currency || user_balance_data.currency;
let value = let value = user_balance_data.crypto_balance || user_balance_data.cash_balance;
user_balance_data.crypto_balance || t += `<span>${code}:${helper_functions.truncateDecimals(value)}</span> &nbsp;`;
user_balance_data.cash_balance;
t += `<span>${code}:${value}</span> &nbsp;`;
}); });
balances_div.innerHTML = t; balances_div.innerHTML = t;
} }
@ -29848,47 +29839,47 @@
} }
} }
const receiving_amount_currency_input = document.createElement( // const receiving_amount_currency_input = document.createElement(
"select" // "select"
); // );
receiving_amount_currency_input.id = "receiving_amount_currency_input"; // receiving_amount_currency_input.id = "receiving_amount_currency_input";
broadcast_tx_ui.appendChild(receiving_amount_currency_input); // broadcast_tx_ui.appendChild(receiving_amount_currency_input);
if ( // if (
typeof localbitcoinplusplus.master_configurations.tradableAsset2 !== // typeof localbitcoinplusplus.master_configurations.tradableAsset2 !==
"undefined" // "undefined"
) { // ) {
let receiving_amount_currency_inputArray = JSON.parse( // let receiving_amount_currency_inputArray = JSON.parse(
JSON.stringify( // JSON.stringify(
localbitcoinplusplus.master_configurations.tradableAsset2 // localbitcoinplusplus.master_configurations.tradableAsset2
) // )
).filter( // ).filter(
asset => // asset =>
!localbitcoinplusplus.master_configurations.tradableAsset1.includes( // !localbitcoinplusplus.master_configurations.tradableAsset1.includes(
asset // asset
) // )
); // );
receiving_amount_currency_inputArray.unshift("Select Fiat"); // receiving_amount_currency_inputArray.unshift("Select Fiat");
for ( // for (
var i = 0; // var i = 0;
i < receiving_amount_currency_inputArray.length; // i < receiving_amount_currency_inputArray.length;
i++ // i++
) { // ) {
var option = document.createElement("option"); // var option = document.createElement("option");
option.value = receiving_amount_currency_inputArray[i]; // option.value = receiving_amount_currency_inputArray[i];
option.text = receiving_amount_currency_inputArray[i]; // option.text = receiving_amount_currency_inputArray[i];
receiving_amount_currency_input.appendChild(option); // receiving_amount_currency_input.appendChild(option);
} // }
} // }
const utxo_addr_input = document.createElement("input"); const utxo_addr_input = document.createElement("input");
utxo_addr_input.type = "text"; utxo_addr_input.type = "text";
utxo_addr_input.placeholder = `UTXO Address of Crypto`; utxo_addr_input.placeholder = `Sender Address`;
const utxo_addr_wif_input = document.createElement("input"); const utxo_addr_wif_input = document.createElement("input");
utxo_addr_wif_input.type = "text"; utxo_addr_wif_input.type = "text";
utxo_addr_wif_input.placeholder = `Private Key of Crypto Being Used`; utxo_addr_wif_input.placeholder = `Enter Private Key`;
const receiver_address_input = document.createElement("input"); const receiver_address_input = document.createElement("input");
receiver_address_input.type = "text"; receiver_address_input.type = "text";
@ -29898,9 +29889,9 @@
receiving_crypto_amount_input.type = "text"; receiving_crypto_amount_input.type = "text";
receiving_crypto_amount_input.placeholder = `Amount to Send`; receiving_crypto_amount_input.placeholder = `Amount to Send`;
const change_adress_input = document.createElement("input"); // const change_adress_input = document.createElement("input");
change_adress_input.type = "text"; // change_adress_input.type = "text";
change_adress_input.placeholder = `Change Address`; // change_adress_input.placeholder = `Change Address`;
const tx_send_button = document.createElement("button"); const tx_send_button = document.createElement("button");
tx_send_button.className += " button bg-blue fs-16 "; tx_send_button.className += " button bg-blue fs-16 ";
@ -29912,7 +29903,7 @@
broadcast_tx_ui_form.appendChild(utxo_addr_wif_input); broadcast_tx_ui_form.appendChild(utxo_addr_wif_input);
broadcast_tx_ui_form.appendChild(receiver_address_input); broadcast_tx_ui_form.appendChild(receiver_address_input);
broadcast_tx_ui_form.appendChild(receiving_crypto_amount_input); broadcast_tx_ui_form.appendChild(receiving_crypto_amount_input);
broadcast_tx_ui_form.appendChild(change_adress_input); //broadcast_tx_ui_form.appendChild(change_adress_input);
broadcast_tx_ui_form.appendChild(tx_send_button); broadcast_tx_ui_form.appendChild(tx_send_button);
let err_msg; let err_msg;
@ -29937,11 +29928,11 @@
showMessage(err_msg); showMessage(err_msg);
throw new Error(err_msg); throw new Error(err_msg);
} }
if (change_adress_input.value.length < 1) { // if (change_adress_input.value.length < 1) {
err_msg = "Empty Change Address."; // err_msg = "Empty Change Address.";
showMessage(err_msg); // showMessage(err_msg);
throw new Error(err_msg); // throw new Error(err_msg);
} // }
const RM_TRADE = new localbitcoinplusplus.trade(); const RM_TRADE = new localbitcoinplusplus.trade();
RM_TRADE.sendTransaction( RM_TRADE.sendTransaction(
@ -29950,7 +29941,7 @@
utxo_addr_wif_input.value, utxo_addr_wif_input.value,
receiver_address_input.value, receiver_address_input.value,
receiving_crypto_amount_input.value, receiving_crypto_amount_input.value,
change_adress_input.value, utxo_addr_input.value,
async function(res) { async function(res) {
console.log(res); console.log(res);
if (typeof res == "object") { if (typeof res == "object") {