fixed localbitcoin object cloning error, added trade balance update function
This commit is contained in:
parent
0c402ace22
commit
9c78d2179f
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,4 +3,5 @@ json-rpc/
|
||||
supernode/playground/
|
||||
playground
|
||||
supernode/index1.html
|
||||
supernode/flosend.html
|
||||
supernode/index1 (copy).html
|
||||
@ -9340,7 +9340,6 @@
|
||||
if (buyPipe.value.length>0 && sellPipe.value.length>0) {
|
||||
for (let i = 0; i < n; i++) {
|
||||
localbitcoinplusplus.trade.prototype.launchTrade(buyPipe.value[i], sellPipe.value[i], function(supernode_res) {
|
||||
console.log(supernode_res);
|
||||
if (typeof supernode_res=="object") {
|
||||
let server_res = localbitcoinplusplus.rpc.prototype.send_rpc.call(this, "trade_balance_updates", supernode_res);
|
||||
doSend(server_res);
|
||||
@ -9475,7 +9474,7 @@
|
||||
let res_str = `${trade_infos_str}${buyerCashResponseObjectStr}${sellerCashResponseObjectStr}${buyerBTCResponseObjectStr}${sellerBTCResponseObjectStr}`;
|
||||
|
||||
let hashed_data = Crypto.SHA256(res_str);
|
||||
|
||||
|
||||
// Signing of the data by Supernode
|
||||
let signed_data = localbitcoinplusplus.wallets.prototype
|
||||
.sign(hashed_data, user_data.myLocalFLOPrivateKey);
|
||||
@ -9777,11 +9776,9 @@
|
||||
JSON.stringify(res_obj));
|
||||
break;
|
||||
case "trade_buy_request_response":
|
||||
console.log(res_obj.params);
|
||||
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object"
|
||||
) {
|
||||
let buyOrders_data = res_obj.params[0];
|
||||
console.log(buyOrders_data);
|
||||
|
||||
if (typeof localbitcoinplusplus.master_configurations.supernodesPubKeys == "object" &&
|
||||
localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(buyOrders_data
|
||||
@ -9827,7 +9824,6 @@
|
||||
response_from_sever = localbitcoinplusplus.rpc.prototype.receive_rpc_response.call(this,
|
||||
JSON.stringify(res_obj));
|
||||
case "deposit_asset_request_response":
|
||||
console.log(res_obj);
|
||||
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object" && typeof res_obj
|
||||
.params[0].data == "object") {
|
||||
let resp = res_obj.params[0];
|
||||
@ -9852,7 +9848,6 @@
|
||||
doSend(JSON.stringify(response_from_sever)); // send response to client
|
||||
break;
|
||||
case "withdrawal_request_response":
|
||||
console.log(res_obj);
|
||||
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
||||
if (localbitcoinplusplus.wallets.prototype
|
||||
.verify(res_obj.params[0].withdrawDataHash, res_obj.params[0].order_validator_sign, res_obj.params[0].order_validator_public_key)) {
|
||||
@ -9864,8 +9859,15 @@
|
||||
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
||||
const trade_balance_res = res_obj.params[0];
|
||||
// Verify data
|
||||
let res_str = `${trade_balance_res.buyer_cash_data}${trade_balance_res.seller_cash_data}${trade_balance_res.buyer_btc_data}${trade_balance_res.seller_btc_data}`;
|
||||
let trade_info_str = JSON.stringify(trade_balance_res.trade_infos);
|
||||
let buyer_cash_data_str = JSON.stringify(trade_balance_res.buyer_cash_data);
|
||||
let seller_cash_data_str = JSON.stringify(trade_balance_res.seller_cash_data);
|
||||
let buyer_btc_data_str = JSON.stringify(trade_balance_res.buyer_btc_data);
|
||||
let seller_btc_data_str = JSON.stringify(trade_balance_res.seller_btc_data);
|
||||
|
||||
let res_str = `${trade_info_str}${buyer_cash_data_str}${seller_cash_data_str}${buyer_btc_data_str}${seller_btc_data_str}`;
|
||||
let hashed_data = Crypto.SHA256(res_str);
|
||||
|
||||
if (localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(trade_balance_res.supernodePubKey)) {
|
||||
if (localbitcoinplusplus.wallets.prototype.verify(hashed_data, trade_balance_res.supernode_sign, trade_balance_res.supernodePubKey)) {
|
||||
// Delete orders in clients DB
|
||||
|
||||
Loading…
Reference in New Issue
Block a user