upgraded cancel trade
This commit is contained in:
parent
538c983fb3
commit
e9c6f7cb97
362
index.html
362
index.html
@ -519,7 +519,7 @@
|
|||||||
|
|
||||||
.sidenav {
|
.sidenav {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: 2;
|
z-index: 1;
|
||||||
top: 20px;
|
top: 20px;
|
||||||
left: 10px;
|
left: 10px;
|
||||||
background: #eee;
|
background: #eee;
|
||||||
@ -15746,24 +15746,6 @@
|
|||||||
trade_margin.remaining_crypto_credit >= eqCrypto
|
trade_margin.remaining_crypto_credit >= eqCrypto
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// If margin is > 2% discontinue the trade
|
|
||||||
const diffPercent = Math.floor(((trade_margin.remaining_crypto_credit-eqCrypto)
|
|
||||||
/trade_margin.remaining_crypto_credit)*100);
|
|
||||||
console.log(trade_margin.remaining_crypto_credit, eqCrypto);
|
|
||||||
console.info(diffPercent);
|
|
||||||
|
|
||||||
if(diffPercent<=2) {
|
|
||||||
eqCrypto = trade_margin.remaining_crypto_credit;
|
|
||||||
} else {
|
|
||||||
err_msg = `Info: Difference between Crypto balance and trading amount is too high: ${diffPercent}`;
|
|
||||||
err_response = {
|
|
||||||
user_flo_addr: params.trader_flo_address,
|
|
||||||
msg: err_msg
|
|
||||||
}
|
|
||||||
reactor.dispatchEvent('message_for_user', err_response);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
request.response = RM_TRADE.trade_sell.call(
|
request.response = RM_TRADE.trade_sell.call(
|
||||||
this,
|
this,
|
||||||
...request.params,
|
...request.params,
|
||||||
@ -16697,6 +16679,51 @@
|
|||||||
reactor.dispatchEvent('message_for_user', err_response);
|
reactor.dispatchEvent('message_for_user', err_response);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let explorer;
|
||||||
|
let decimal = 100000000;
|
||||||
|
switch (withdraw_res.product) {
|
||||||
|
case "BTC":
|
||||||
|
explorer =
|
||||||
|
localbitcoinplusplus.server
|
||||||
|
.btc_mainnet;
|
||||||
|
break;
|
||||||
|
case "BTC_TEST":
|
||||||
|
explorer =
|
||||||
|
localbitcoinplusplus.server
|
||||||
|
.btc_testnet;
|
||||||
|
break;
|
||||||
|
case "FLO":
|
||||||
|
explorer =
|
||||||
|
localbitcoinplusplus.server
|
||||||
|
.flo_mainnet;
|
||||||
|
decimal = 1;
|
||||||
|
break;
|
||||||
|
case "FLO_TEST":
|
||||||
|
explorer =
|
||||||
|
localbitcoinplusplus.server
|
||||||
|
.flo_testnet;
|
||||||
|
decimal = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof explorer !== "string") {
|
||||||
|
throw new Error(
|
||||||
|
`WARNING: Invalid product value: ${withdraw_res.product}.`
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bal_url = `${explorer}/api/addr/${withdraw_res.utxo_addr}/balance`;
|
||||||
|
console.log(bal_url);
|
||||||
|
|
||||||
|
// Get the balance before sending the tx. It is important to get balance before
|
||||||
|
// tx than to after because fetching balance after can return older or newer balance
|
||||||
|
// on random events
|
||||||
|
let current_balance = await helper_functions.ajaxGet(bal_url);
|
||||||
|
|
||||||
const btc_reserves = await readDB("system_btc_reserves_private_keys", retrieve_pvtkey_req_id);
|
const btc_reserves = await readDB("system_btc_reserves_private_keys", retrieve_pvtkey_req_id);
|
||||||
if (typeof btc_reserves == "object") {
|
if (typeof btc_reserves == "object") {
|
||||||
// Ideally this line should never run.
|
// Ideally this line should never run.
|
||||||
@ -16764,6 +16791,8 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
withdrawer_crypto_bal_response.crypto_balance -= EqCryptoWd;
|
withdrawer_crypto_bal_response.crypto_balance -= EqCryptoWd;
|
||||||
|
withdrawer_crypto_bal_response.crypto_balance =
|
||||||
|
helper_functions.truncateDecimals(withdrawer_crypto_bal_response.crypto_balance);
|
||||||
const updated_crypto_balance = await updateinDB(
|
const updated_crypto_balance = await updateinDB(
|
||||||
"crypto_balances",
|
"crypto_balances",
|
||||||
withdrawer_crypto_bal_response,
|
withdrawer_crypto_bal_response,
|
||||||
@ -16802,49 +16831,8 @@
|
|||||||
"btc_address",
|
"btc_address",
|
||||||
withdraw_res.utxo_addr
|
withdraw_res.utxo_addr
|
||||||
);
|
);
|
||||||
if (typeof deposit_arr_resp == "object") {
|
if (typeof deposit_arr_resp[0] == "object") {
|
||||||
deposit_arr_resp.map(
|
const deposit_arr = deposit_arr_resp[0];
|
||||||
async deposit_arr => {
|
|
||||||
let explorer;
|
|
||||||
let decimal = 100000000;
|
|
||||||
switch (deposit_arr.product) {
|
|
||||||
case "BTC":
|
|
||||||
explorer =
|
|
||||||
localbitcoinplusplus.server
|
|
||||||
.btc_mainnet;
|
|
||||||
break;
|
|
||||||
case "BTC_TEST":
|
|
||||||
explorer =
|
|
||||||
localbitcoinplusplus.server
|
|
||||||
.btc_testnet;
|
|
||||||
break;
|
|
||||||
case "FLO":
|
|
||||||
explorer =
|
|
||||||
localbitcoinplusplus.server
|
|
||||||
.flo_mainnet;
|
|
||||||
decimal = 1;
|
|
||||||
break;
|
|
||||||
case "FLO_TEST":
|
|
||||||
explorer =
|
|
||||||
localbitcoinplusplus.server
|
|
||||||
.flo_testnet;
|
|
||||||
decimal = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof explorer !== "string") {
|
|
||||||
throw new Error(
|
|
||||||
`WARNING: Invalid product value: ${deposit_arr.product}.`
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const bal_url = `${explorer}/api/addr/${withdraw_res.utxo_addr}/balance`;
|
|
||||||
console.log(bal_url);
|
|
||||||
|
|
||||||
let current_balance = await helper_functions.ajaxGet(bal_url);
|
|
||||||
if (
|
if (
|
||||||
!isNaN(current_balance) &&
|
!isNaN(current_balance) &&
|
||||||
parseFloat(current_balance) > 0
|
parseFloat(current_balance) > 0
|
||||||
@ -16857,8 +16845,8 @@
|
|||||||
if (
|
if (
|
||||||
typeof current_balance == "number"
|
typeof current_balance == "number"
|
||||||
) {
|
) {
|
||||||
deposit_arr.bitcoinToBePaid = current_balance;
|
deposit_arr.bitcoinToBePaid = current_balance-EqCryptoWd;
|
||||||
btc_reserves.balance = current_balance;
|
btc_reserves.balance = current_balance-EqCryptoWd;
|
||||||
} else {
|
} else {
|
||||||
deposit_arr.bitcoinToBePaid -= EqCryptoWd;
|
deposit_arr.bitcoinToBePaid -= EqCryptoWd;
|
||||||
btc_reserves.balance -= EqCryptoWd;
|
btc_reserves.balance -= EqCryptoWd;
|
||||||
@ -16868,6 +16856,9 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deposit_arr.bitcoinToBePaid = helper_functions.truncateDecimals(deposit_arr.bitcoinToBePaid);
|
||||||
|
btc_reserves.balance = helper_functions.truncateDecimals(btc_reserves.balance);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
deposit_arr.bitcoinToBePaid > 0
|
deposit_arr.bitcoinToBePaid > 0
|
||||||
) {
|
) {
|
||||||
@ -16944,8 +16935,7 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16966,7 +16956,6 @@
|
|||||||
// may be required by a follow-up withdraw request
|
// may be required by a follow-up withdraw request
|
||||||
await localbitcoinplusplus.actions.delay(180000);
|
await localbitcoinplusplus.actions.delay(180000);
|
||||||
|
|
||||||
await removeinDB("withdraw_btc", withdraw_id);
|
|
||||||
// update deposits status back to 2 in db
|
// update deposits status back to 2 in db
|
||||||
const deposit_arr_resp = await readDBbyIndex(
|
const deposit_arr_resp = await readDBbyIndex(
|
||||||
"deposit",
|
"deposit",
|
||||||
@ -16981,6 +16970,7 @@
|
|||||||
deposit_arr_resp[0].id
|
deposit_arr_resp[0].id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
await removeinDB("withdraw_btc", withdraw_id);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -16992,6 +16982,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
|
const withdraw_res = await readDB("withdraw_btc", withdraw_id);
|
||||||
|
// update deposits status back to 2 in db
|
||||||
|
const deposit_arr_resp = await readDBbyIndex(
|
||||||
|
"deposit",
|
||||||
|
"btc_address",
|
||||||
|
withdraw_res.utxo_addr
|
||||||
|
)
|
||||||
|
if (typeof deposit_arr_resp[0] == "object") {
|
||||||
|
deposit_arr_resp[0].status = 2; // UTXO ready to be used again
|
||||||
|
await updateinDB(
|
||||||
|
"deposit",
|
||||||
|
deposit_arr_resp[0],
|
||||||
|
deposit_arr_resp[0].id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
await removeinDB("withdraw_btc", withdraw_id);
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -17372,22 +17379,6 @@
|
|||||||
trade_margin.remaining_crypto_credit > 0 &&
|
trade_margin.remaining_crypto_credit > 0 &&
|
||||||
trade_margin.remaining_crypto_credit >= eqCrypto
|
trade_margin.remaining_crypto_credit >= eqCrypto
|
||||||
) {
|
) {
|
||||||
// If margin is > 2% discontinue the trade
|
|
||||||
const diffPercent = Math.floor(((trade_margin.remaining_crypto_credit-eqCrypto)
|
|
||||||
/trade_margin.remaining_crypto_credit)*100);
|
|
||||||
console.log(trade_margin.remaining_crypto_credit, eqCrypto);
|
|
||||||
console.info(diffPercent);
|
|
||||||
|
|
||||||
if(diffPercent<=2) {
|
|
||||||
eqCrypto = trade_margin.remaining_crypto_credit;
|
|
||||||
} else {
|
|
||||||
err_response = {
|
|
||||||
user_flo_addr: params.trader_flo_address,
|
|
||||||
msg: `Info: Difference between Crypto balance and trading amount is too high: ${diffPercent}`
|
|
||||||
}
|
|
||||||
reactor.dispatchEvent('message_for_user', err_response);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
request.response = RM_TRADE.trade_sell.call(
|
request.response = RM_TRADE.trade_sell.call(
|
||||||
this,
|
this,
|
||||||
...request.params,
|
...request.params,
|
||||||
@ -18352,6 +18343,50 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let explorer;
|
||||||
|
let decimal = 100000000;
|
||||||
|
switch (withdraw_res.product) {
|
||||||
|
case "BTC":
|
||||||
|
explorer =
|
||||||
|
localbitcoinplusplus.server
|
||||||
|
.btc_mainnet;
|
||||||
|
break;
|
||||||
|
case "BTC_TEST":
|
||||||
|
explorer =
|
||||||
|
localbitcoinplusplus.server
|
||||||
|
.btc_testnet;
|
||||||
|
break;
|
||||||
|
case "FLO":
|
||||||
|
explorer =
|
||||||
|
localbitcoinplusplus.server
|
||||||
|
.flo_mainnet;
|
||||||
|
decimal = 1;
|
||||||
|
break;
|
||||||
|
case "FLO_TEST":
|
||||||
|
explorer =
|
||||||
|
localbitcoinplusplus.server
|
||||||
|
.flo_testnet;
|
||||||
|
decimal = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof explorer !== "string") {
|
||||||
|
throw new Error(
|
||||||
|
`WARNING: Invalid product value: ${withdraw_res.product}.`
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bal_url = `${explorer}/api/addr/${withdraw_res.utxo_addr}/balance`;
|
||||||
|
console.log(bal_url);
|
||||||
|
|
||||||
|
// Get the balance before sending the tx. It is important to get balance before
|
||||||
|
// tx than to after because fetching balance after can return older or newer balance
|
||||||
|
// on random events
|
||||||
|
let current_balance = await helper_functions.ajaxGet(bal_url);
|
||||||
|
|
||||||
const btc_reserves = await backup_server_db_instance
|
const btc_reserves = await backup_server_db_instance
|
||||||
.backup_readDB("system_btc_reserves_private_keys", retrieve_pvtkey_req_id);
|
.backup_readDB("system_btc_reserves_private_keys", retrieve_pvtkey_req_id);
|
||||||
|
|
||||||
@ -18431,6 +18466,9 @@
|
|||||||
let withdrawer_crypto_bal_id = `${withdraw_res.trader_flo_address}_${withdraw_res.product}`;
|
let withdrawer_crypto_bal_id = `${withdraw_res.trader_flo_address}_${withdraw_res.product}`;
|
||||||
|
|
||||||
withdrawer_crypto_bal_response.crypto_balance -= EqCryptoWd;
|
withdrawer_crypto_bal_response.crypto_balance -= EqCryptoWd;
|
||||||
|
withdrawer_crypto_bal_response.crypto_balance =
|
||||||
|
helper_functions.truncateDecimals(withdrawer_crypto_bal_response.crypto_balance);
|
||||||
|
|
||||||
const updated_crypto_balance = await backup_server_db_instance
|
const updated_crypto_balance = await backup_server_db_instance
|
||||||
.backup_updateinDB(
|
.backup_updateinDB(
|
||||||
"crypto_balances",
|
"crypto_balances",
|
||||||
@ -18483,52 +18521,7 @@
|
|||||||
typeof deposit_arr_resp ==
|
typeof deposit_arr_resp ==
|
||||||
"object"
|
"object"
|
||||||
) {
|
) {
|
||||||
deposit_arr_resp.map(
|
const deposit_arr = deposit_arr_resp[0];
|
||||||
async deposit_arr => {
|
|
||||||
let explorer;
|
|
||||||
let decimal = 100000000;
|
|
||||||
switch (deposit_arr.product) {
|
|
||||||
case "BTC":
|
|
||||||
explorer =
|
|
||||||
localbitcoinplusplus
|
|
||||||
.server.btc_mainnet;
|
|
||||||
break;
|
|
||||||
case "BTC_TEST":
|
|
||||||
explorer =
|
|
||||||
localbitcoinplusplus
|
|
||||||
.server.btc_testnet;
|
|
||||||
break;
|
|
||||||
case "FLO":
|
|
||||||
explorer =
|
|
||||||
localbitcoinplusplus
|
|
||||||
.server.flo_mainnet;
|
|
||||||
decimal = 1;
|
|
||||||
break;
|
|
||||||
case "FLO_TEST":
|
|
||||||
explorer =
|
|
||||||
localbitcoinplusplus
|
|
||||||
.server.flo_testnet;
|
|
||||||
decimal = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
typeof explorer !== "string"
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`WARNING: Invalid product value: ${deposit_arr.product}.`
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const bal_url = `${explorer}/api/addr/${withdraw_res.utxo_addr}/balance`;
|
|
||||||
console.log(bal_url);
|
|
||||||
|
|
||||||
let current_balance = await helper_functions.ajaxGet(
|
|
||||||
bal_url
|
|
||||||
);
|
|
||||||
if (
|
if (
|
||||||
!isNaN(current_balance) &&
|
!isNaN(current_balance) &&
|
||||||
parseFloat(
|
parseFloat(
|
||||||
@ -18544,8 +18537,8 @@
|
|||||||
typeof current_balance ==
|
typeof current_balance ==
|
||||||
"number"
|
"number"
|
||||||
) {
|
) {
|
||||||
deposit_arr.bitcoinToBePaid = current_balance;
|
deposit_arr.bitcoinToBePaid = current_balance-EqCryptoWd;
|
||||||
btc_reserves.balance = current_balance;
|
btc_reserves.balance = current_balance-EqCryptoWd;
|
||||||
} else {
|
} else {
|
||||||
deposit_arr.bitcoinToBePaid -= EqCryptoWd;
|
deposit_arr.bitcoinToBePaid -= EqCryptoWd;
|
||||||
btc_reserves.balance -= EqCryptoWd;
|
btc_reserves.balance -= EqCryptoWd;
|
||||||
@ -18555,6 +18548,9 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deposit_arr.bitcoinToBePaid = helper_functions.truncateDecimals(deposit_arr.bitcoinToBePaid);
|
||||||
|
btc_reserves.balance = helper_functions.truncateDecimals(btc_reserves.balance);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
deposit_arr.bitcoinToBePaid >
|
deposit_arr.bitcoinToBePaid >
|
||||||
0
|
0
|
||||||
@ -18652,8 +18648,8 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18706,10 +18702,32 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
|
const withdraw_res = await backup_server_db_instance
|
||||||
|
.backup_readDB("withdraw_btc", withdraw_id);
|
||||||
|
// update deposits status back to 2 in db
|
||||||
|
const deposit_arr_resp = await backup_server_db_instance
|
||||||
|
.backup_readDBbyIndex(
|
||||||
|
"deposit",
|
||||||
|
"btc_address",
|
||||||
|
withdraw_res.utxo_addr
|
||||||
|
)
|
||||||
|
if (typeof deposit_arr_resp[0] == "object") {
|
||||||
|
deposit_arr_resp[0].status = 2; // UTXO ready to be used again
|
||||||
|
await backup_server_db_instance
|
||||||
|
.backup_updateinDB(
|
||||||
|
"deposit",
|
||||||
|
deposit_arr_resp[0],
|
||||||
|
deposit_arr_resp[0].id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
await backup_server_db_instance
|
||||||
|
.backup_removeinDB("withdraw_btc", withdraw_id);
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "superNodeSignedAddUserPublicData":
|
case "superNodeSignedAddUserPublicData":
|
||||||
@ -22131,21 +22149,19 @@
|
|||||||
removeinDB(tradeDB, cancel_request.trade_id).then(
|
removeinDB(tradeDB, cancel_request.trade_id).then(
|
||||||
id => {
|
id => {
|
||||||
msg_response = {
|
msg_response = {
|
||||||
user_flo_addr: params.trader_flo_address,
|
user_flo_addr: cancel_request.trader_flo_address,
|
||||||
msg: `Failed to verify order for order id ${cancel_request.trade_id}`
|
msg: `Order id ${cancel_request.trade_id} is deleted.`
|
||||||
}
|
}
|
||||||
reactor.dispatchEvent('message_for_user', msg_response);
|
reactor.dispatchEvent('message_for_user', msg_response);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
err_response = {
|
err_response = {
|
||||||
user_flo_addr: params.trader_flo_address,
|
user_flo_addr: cancel_request.trader_flo_address,
|
||||||
msg: `Failed to verify order for order id ${cancel_request.trade_id}`
|
msg: `Failed to verify order for order id ${cancel_request.trade_id}`
|
||||||
}
|
}
|
||||||
reactor.dispatchEvent('message_for_user', err_response);
|
reactor.dispatchEvent('message_for_user', err_response);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
showMessage("Failed to cancel order.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -24094,24 +24110,6 @@
|
|||||||
showMessage(backup_db_error_msg);
|
showMessage(backup_db_error_msg);
|
||||||
throw new Error(backup_db_error_msg);
|
throw new Error(backup_db_error_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
backup_server_db_instance
|
|
||||||
.backup_readDB(
|
|
||||||
"userPublicData",
|
|
||||||
cancel_request.trader_flo_address
|
|
||||||
)
|
|
||||||
.then(trader_data => {
|
|
||||||
if (
|
|
||||||
typeof trader_data.trader_flo_address !==
|
|
||||||
"string" ||
|
|
||||||
typeof trader_data.trader_flo_pubKey !==
|
|
||||||
"string"
|
|
||||||
) {
|
|
||||||
err_msg =
|
|
||||||
"ERROR: Failed to cancel the order. User is unknown.";
|
|
||||||
showMessage(err_msg);
|
|
||||||
throw new Error(err_msg);
|
|
||||||
}
|
|
||||||
tradeDB =
|
tradeDB =
|
||||||
cancel_request.trade_type == "buy"
|
cancel_request.trade_type == "buy"
|
||||||
? "buyOrders"
|
? "buyOrders"
|
||||||
@ -24120,7 +24118,7 @@
|
|||||||
RM_WALLET.verify(
|
RM_WALLET.verify(
|
||||||
cancel_request.trade_id,
|
cancel_request.trade_id,
|
||||||
cancel_request.signed_trade_id,
|
cancel_request.signed_trade_id,
|
||||||
trader_data.trader_flo_pubKey
|
nodePubKey.trader_flo_pubKey
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
backup_server_db_instance
|
backup_server_db_instance
|
||||||
@ -24131,7 +24129,7 @@
|
|||||||
.then(id =>
|
.then(id =>
|
||||||
{
|
{
|
||||||
err_response = {
|
err_response = {
|
||||||
user_flo_addr: params.trader_flo_address,
|
user_flo_addr: cancel_request.trader_flo_address,
|
||||||
msg: `Order Id ${id} deleted.`
|
msg: `Order Id ${id} deleted.`
|
||||||
}
|
}
|
||||||
reactor.dispatchEvent('message_for_user', err_response);
|
reactor.dispatchEvent('message_for_user', err_response);
|
||||||
@ -24140,12 +24138,12 @@
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
err_response = {
|
err_response = {
|
||||||
user_flo_addr: params.trader_flo_address,
|
user_flo_addr: cancel_request.trader_flo_address,
|
||||||
msg: `Failed to verify order for order id ${cancel_request.trade_id}`
|
msg: `Failed to verify order for order id ${cancel_request.trade_id}`
|
||||||
}
|
}
|
||||||
reactor.dispatchEvent('message_for_user', err_response);
|
reactor.dispatchEvent('message_for_user', err_response);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
err_response = {
|
err_response = {
|
||||||
@ -26134,24 +26132,6 @@
|
|||||||
showMessage(backup_db_error_msg);
|
showMessage(backup_db_error_msg);
|
||||||
throw new Error(backup_db_error_msg);
|
throw new Error(backup_db_error_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
backup_server_db_instance
|
|
||||||
.backup_readDB(
|
|
||||||
"userPublicData",
|
|
||||||
cancel_request.trader_flo_address
|
|
||||||
)
|
|
||||||
.then(trader_data => {
|
|
||||||
if (
|
|
||||||
typeof trader_data.trader_flo_address !==
|
|
||||||
"string" ||
|
|
||||||
typeof trader_data.trader_flo_pubKey !==
|
|
||||||
"string"
|
|
||||||
) {
|
|
||||||
err_msg =
|
|
||||||
"ERROR: Failed to cancel the order. User is unknown.";
|
|
||||||
showMessage(err_msg);
|
|
||||||
throw new Error(err_msg);
|
|
||||||
}
|
|
||||||
tradeDB =
|
tradeDB =
|
||||||
cancel_request.trade_type == "buy"
|
cancel_request.trade_type == "buy"
|
||||||
? "buyOrders"
|
? "buyOrders"
|
||||||
@ -26160,7 +26140,7 @@
|
|||||||
RM_WALLET.verify(
|
RM_WALLET.verify(
|
||||||
cancel_request.trade_id,
|
cancel_request.trade_id,
|
||||||
cancel_request.signed_trade_id,
|
cancel_request.signed_trade_id,
|
||||||
trader_data.trader_flo_pubKey
|
nodePubKey.trader_flo_pubKey
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
backup_server_db_instance
|
backup_server_db_instance
|
||||||
@ -26169,16 +26149,22 @@
|
|||||||
cancel_request.trade_id
|
cancel_request.trade_id
|
||||||
)
|
)
|
||||||
.then(id =>
|
.then(id =>
|
||||||
showMessage(`Order Id ${id} deleted.`)
|
{
|
||||||
|
err_response = {
|
||||||
|
user_flo_addr: cancel_request.trader_flo_address,
|
||||||
|
msg: `Order Id ${id} is deleted.`
|
||||||
|
}
|
||||||
|
reactor.dispatchEvent('message_for_user', err_response);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
showMessage(
|
err_response = {
|
||||||
`Failed to verify order for order id ${cancel_request.trade_id}`
|
user_flo_addr: cancel_request.trader_flo_address,
|
||||||
);
|
msg: `Failed to verify order for order id ${cancel_request.trade_id}`
|
||||||
}
|
}
|
||||||
});
|
reactor.dispatchEvent('message_for_user', err_response);
|
||||||
} else {
|
}
|
||||||
showMessage("Failed to cancel order.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user