fixed errors in cash functions
This commit is contained in:
parent
301e26bbae
commit
721647e1f9
@ -13845,6 +13845,7 @@
|
|||||||
localbitcoinplusplus.supernode_conns[sn.data.id].readyState===1) {
|
localbitcoinplusplus.supernode_conns[sn.data.id].readyState===1) {
|
||||||
|
|
||||||
req_body.requesting_supernode = sn.data.id;
|
req_body.requesting_supernode = sn.data.id;
|
||||||
|
req_body.receiver_flo_address = sn.data.id;
|
||||||
websocket_name = localbitcoinplusplus.supernode_conns[sn.data.id];
|
websocket_name = localbitcoinplusplus.supernode_conns[sn.data.id];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -13878,7 +13879,7 @@
|
|||||||
const RM_WALLET = new localbitcoinplusplus.wallets;
|
const RM_WALLET = new localbitcoinplusplus.wallets;
|
||||||
Array.from(recv_deposit_btn).forEach(function(element) {
|
Array.from(recv_deposit_btn).forEach(function(element) {
|
||||||
element.addEventListener("click", async function(evt) {
|
element.addEventListener("click", async function(evt) {
|
||||||
//let btn = this;
|
let btn = this;
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
const deposit_id = this.value;
|
const deposit_id = this.value;
|
||||||
const req_info = document.getElementById(`depositSpan${deposit_id}`);
|
const req_info = document.getElementById(`depositSpan${deposit_id}`);
|
||||||
@ -13902,7 +13903,7 @@
|
|||||||
let flo_txid = '';
|
let flo_txid = '';
|
||||||
|
|
||||||
const flo_tx = await RM_WALLET.sendTransaction(
|
const flo_tx = await RM_WALLET.sendTransaction(
|
||||||
localbitcoinplusplus.assets.FLO,
|
localbitcoinplusplus.BASE_BLOCKCHAIN,
|
||||||
localbitcoinplusplus.wallets.my_local_flo_address,
|
localbitcoinplusplus.wallets.my_local_flo_address,
|
||||||
localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY,
|
localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY,
|
||||||
requesting_supernode,
|
requesting_supernode,
|
||||||
@ -13940,6 +13941,7 @@
|
|||||||
.flo_api_testnet}/api/v1.0/getTransactionDetails/${flo_txid}`;
|
.flo_api_testnet}/api/v1.0/getTransactionDetails/${flo_txid}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(this);
|
||||||
let n=1;
|
let n=1;
|
||||||
(async function validateTxidInBlockchain() {
|
(async function validateTxidInBlockchain() {
|
||||||
// Validate Flo txid
|
// Validate Flo txid
|
||||||
@ -13955,10 +13957,10 @@
|
|||||||
.call(this, "cashier_confirms_user_cash_deposit", req_body)
|
.call(this, "cashier_confirms_user_cash_deposit", req_body)
|
||||||
.then(resp => doSend(websocket_conn, resp));
|
.then(resp => doSend(websocket_conn, resp));
|
||||||
|
|
||||||
this.classList.remove('cnf_deposits');
|
btn.classList.remove('cnf_deposits');
|
||||||
this.classList.remove('btn-info');
|
btn.classList.remove('btn-info');
|
||||||
this.classList.add('btn-success');
|
btn.classList.add('btn-success');
|
||||||
this.innerText = "Success";
|
btn.innerText = "Success";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -13969,14 +13971,14 @@
|
|||||||
// Failed to validate token transfer. Save in local db
|
// Failed to validate token transfer. Save in local db
|
||||||
await addDB('failed_deposit_confirms', req_body, req_body.flo_txid);
|
await addDB('failed_deposit_confirms', req_body, req_body.flo_txid);
|
||||||
|
|
||||||
this.classList.remove('cnf_deposits');
|
btn.classList.remove('cnf_deposits');
|
||||||
this.classList.remove('btn-info');
|
btn.classList.remove('btn-info');
|
||||||
this.classList.add('btn-danger');
|
btn.classList.add('btn-danger');
|
||||||
this.innerText = "Failed to inform Supernode. Please contact the Admin.";
|
btn.innerText = "Failed to inform Supernode. Please contact the Admin.";
|
||||||
|
|
||||||
throw new Error(`Failed to inform Supernode of cash deposit: ${flo_txid}`);
|
throw new Error(`Failed to inform Supernode of cash deposit: ${flo_txid}`);
|
||||||
}
|
}
|
||||||
}.bind(this))()
|
}.bind(btn))()
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -13990,7 +13992,7 @@
|
|||||||
|
|
||||||
element.addEventListener("click", function(evt) {
|
element.addEventListener("click", function(evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
//let btn = this;
|
let btn = this;
|
||||||
const withdraw_id = this.value;
|
const withdraw_id = this.value;
|
||||||
const req_info = document.getElementById(`withdrawSpan${withdraw_id}`);
|
const req_info = document.getElementById(`withdrawSpan${withdraw_id}`);
|
||||||
const req_info_arr = req_info.value.split("_");
|
const req_info_arr = req_info.value.split("_");
|
||||||
@ -14018,14 +14020,14 @@
|
|||||||
})
|
})
|
||||||
.then(resp => doSend(websocket_conn, resp));
|
.then(resp => doSend(websocket_conn, resp));
|
||||||
|
|
||||||
this.classList.remove('cnf_withdrawal');
|
btn.classList.remove('cnf_withdrawal');
|
||||||
this.classList.remove('btn-info');
|
btn.classList.remove('btn-info');
|
||||||
this.classList.add('btn-success');
|
btn.classList.add('btn-success');
|
||||||
this.innerText = "Success";
|
btn.innerText = "Success";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}.bind(this));
|
}.bind(btn));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
34
index.html
34
index.html
@ -19413,17 +19413,12 @@
|
|||||||
updateUserBalance = await _updateinDB("cash_balances", cash_obj);
|
updateUserBalance = await _updateinDB("cash_balances", cash_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete data from deposits
|
|
||||||
if (typeof updateUserBalance!=="object" && updateUserBalance==null)
|
if (typeof updateUserBalance!=="object" && updateUserBalance==null)
|
||||||
throw new Error(`Error: Failed to update balance of User Cash Id: ${user_cash_id}.`);
|
throw new Error(`Error: Failed to update balance of User Cash Id: ${user_cash_id}.`);
|
||||||
|
|
||||||
if (localbitcoinplusplus.wallets.my_local_flo_address!==parent_supernode) {
|
// Delete data from deposits
|
||||||
user_deposit_req.token_transfer_txid = params.flo_txid;
|
await _removeinDB("cash_deposits", params.deposit_id);
|
||||||
_updateinDB("cash_deposits", user_deposit_req);
|
|
||||||
} else {
|
|
||||||
_removeinDB("cash_deposits", params.deposit_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 = {
|
||||||
depositor_cash_data: updateUserBalance,
|
depositor_cash_data: updateUserBalance,
|
||||||
@ -19486,8 +19481,6 @@
|
|||||||
typeof localbitcoinplusplus.newBackupDatabase.db[parent_supernode] ==
|
typeof localbitcoinplusplus.newBackupDatabase.db[parent_supernode] ==
|
||||||
"object"
|
"object"
|
||||||
) {
|
) {
|
||||||
// Cash Withdraw or deposit not allowed in backup mode
|
|
||||||
return;
|
|
||||||
const foreign_db =
|
const foreign_db =
|
||||||
localbitcoinplusplus.newBackupDatabase.db[parent_supernode];
|
localbitcoinplusplus.newBackupDatabase.db[parent_supernode];
|
||||||
_readDB = foreign_db.backup_readDB.bind(foreign_db);
|
_readDB = foreign_db.backup_readDB.bind(foreign_db);
|
||||||
@ -19505,9 +19498,7 @@
|
|||||||
|
|
||||||
if(typeof updated_withdraw_req.id !=="string")
|
if(typeof updated_withdraw_req.id !=="string")
|
||||||
throw new Error(`Error: Failed to update "cashier_confirms_user_cash_withdraw" data.`);
|
throw new Error(`Error: Failed to update "cashier_confirms_user_cash_withdraw" data.`);
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Broadcast to backups
|
// Broadcast to backups
|
||||||
RM_RPC
|
RM_RPC
|
||||||
.send_rpc
|
.send_rpc
|
||||||
@ -19515,6 +19506,11 @@
|
|||||||
"record_upi_tx_of_successfull_withdraw",
|
"record_upi_tx_of_successfull_withdraw",
|
||||||
updated_withdraw_req)
|
updated_withdraw_req)
|
||||||
.then(resp=> doSend(resp));
|
.then(resp=> doSend(resp));
|
||||||
|
|
||||||
|
// Delete the request after 24 hours
|
||||||
|
localbitcoinplusplus.actions.delay(24 * 60 * 60 * 1000).then(function() {
|
||||||
|
_removeinDB("withdraw_cash", withdraw_req.id);
|
||||||
|
});
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
@ -24347,9 +24343,11 @@
|
|||||||
readDB("localbitcoinUser", "00-01").then(function(user) {
|
readDB("localbitcoinUser", "00-01").then(function(user) {
|
||||||
if (
|
if (
|
||||||
typeof user == "object" &&
|
typeof user == "object" &&
|
||||||
user.myLocalFLOAddress == resp.data.trader_flo_address || resp.receiver_flo_address
|
(user.myLocalFLOAddress == resp.data.trader_flo_address
|
||||||
|
|| user.myLocalFLOAddress == resp.receiver_flo_address)
|
||||||
) {
|
) {
|
||||||
let counterTraderAccountAddress = resp.msg;
|
let counterTraderAccountAddress = `Please pay ${resp.data.currency} ${resp.data.depositing_amount} to following UPI ID:
|
||||||
|
${resp.msg}`;
|
||||||
showMessage(counterTraderAccountAddress);
|
showMessage(counterTraderAccountAddress);
|
||||||
modalWindow(counterTraderAccountAddress);
|
modalWindow(counterTraderAccountAddress);
|
||||||
}
|
}
|
||||||
@ -27838,7 +27836,6 @@
|
|||||||
|
|
||||||
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
||||||
const successfull_withdraw_resp = res_obj.params[0];
|
const successfull_withdraw_resp = res_obj.params[0];
|
||||||
console.log(successfull_withdraw_resp);
|
|
||||||
|
|
||||||
localbitcoinplusplus.kademlia.determineClosestSupernode(
|
localbitcoinplusplus.kademlia.determineClosestSupernode(
|
||||||
successfull_withdraw_resp.trader_flo_address
|
successfull_withdraw_resp.trader_flo_address
|
||||||
@ -27849,9 +27846,14 @@
|
|||||||
localbitcoinplusplus.newBackupDatabase.db[primarySupernodeOfThisUser];
|
localbitcoinplusplus.newBackupDatabase.db[primarySupernodeOfThisUser];
|
||||||
|
|
||||||
_updateinDB = foreign_db.backup_updateinDB.bind(foreign_db);
|
_updateinDB = foreign_db.backup_updateinDB.bind(foreign_db);
|
||||||
|
_removeinDB = foreign_db.backup_removeinDB.bind(foreign_db);
|
||||||
|
|
||||||
_updateinDB('withdraw_cash', successfull_withdraw_resp,
|
_updateinDB('withdraw_cash', successfull_withdraw_resp,
|
||||||
successfull_withdraw_resp.id, true, false);
|
successfull_withdraw_resp.id, true, false);
|
||||||
|
|
||||||
|
localbitcoinplusplus.actions.delay(24 * 60 * 60 * 1000).then(function() {
|
||||||
|
_removeinDB('withdraw_cash', successfull_withdraw_resp.id);
|
||||||
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user