fixed functionality to withdraw crypto when backup supernode is acting supernode
This commit is contained in:
parent
a3adb867ee
commit
26ccdfec0f
@ -12568,6 +12568,12 @@
|
|||||||
|
|
||||||
if (typeof params == "object" && typeof method == "string") {
|
if (typeof params == "object" && typeof method == "string") {
|
||||||
|
|
||||||
|
if (typeof params.receiver_flo_address=="string"
|
||||||
|
&& params.receiver_flo_address.length>0) {
|
||||||
|
if(params.receiver_flo_address
|
||||||
|
!== localbitcoinplusplus.wallets.my_local_flo_address) return;
|
||||||
|
}
|
||||||
|
|
||||||
const RM_WALLET = new localbitcoinplusplus.wallets;
|
const RM_WALLET = new localbitcoinplusplus.wallets;
|
||||||
const RM_TRADE = new localbitcoinplusplus.trade;
|
const RM_TRADE = new localbitcoinplusplus.trade;
|
||||||
const RM_RPC = new localbitcoinplusplus.rpc;
|
const RM_RPC = new localbitcoinplusplus.rpc;
|
||||||
@ -12577,7 +12583,7 @@
|
|||||||
request.response = {};
|
request.response = {};
|
||||||
let err_msg;
|
let err_msg;
|
||||||
|
|
||||||
if(typeof params.trader_flo_address !="string") return;
|
if(typeof params.trader_flo_address !=="string") return;
|
||||||
const my_closest_su_list = await localbitcoinplusplus.kademlia.determineClosestSupernode(params.trader_flo_address);
|
const my_closest_su_list = await localbitcoinplusplus.kademlia.determineClosestSupernode(params.trader_flo_address);
|
||||||
const primarySupernodeOfThisUser = my_closest_su_list[0].data.id;
|
const primarySupernodeOfThisUser = my_closest_su_list[0].data.id;
|
||||||
|
|
||||||
@ -12659,15 +12665,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
let backup_server_db_instance;
|
let backup_server_db_instance;
|
||||||
if (typeof localbitcoinplusplus.newBackupDatabase.db[primarySupernodeOfThisUser] == "object") {
|
if (method !== "retrieve_shamirs_secret_btc_pvtkey") {
|
||||||
backup_server_db_instance = localbitcoinplusplus.newBackupDatabase.db[primarySupernodeOfThisUser];
|
if (typeof localbitcoinplusplus.newBackupDatabase.db[primarySupernodeOfThisUser] == "object") {
|
||||||
}
|
backup_server_db_instance = localbitcoinplusplus.newBackupDatabase.db[primarySupernodeOfThisUser];
|
||||||
|
}
|
||||||
|
|
||||||
if(typeof backup_server_db_instance !== "object") {
|
if(typeof backup_server_db_instance !== "object") {
|
||||||
let backup_db_error_msg = `WARNING: Unknown DB instance. DB Backup failed.`;
|
let backup_db_error_msg = `WARNING: Unknown DB instance. DB Backup failed.`;
|
||||||
showMessage(backup_db_error_msg);
|
showMessage(backup_db_error_msg);
|
||||||
throw new Error(backup_db_error_msg);
|
throw new Error(backup_db_error_msg);
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
RM_RPC.filter_legit_backup_requests(params.trader_flo_address, async function (is_valid_request) {
|
RM_RPC.filter_legit_backup_requests(params.trader_flo_address, async function (is_valid_request) {
|
||||||
if (is_valid_request !== true) return false;
|
if (is_valid_request !== true) return false;
|
||||||
@ -13429,7 +13437,8 @@
|
|||||||
"send_back_shamirs_secret_btc_pvtkey", {
|
"send_back_shamirs_secret_btc_pvtkey", {
|
||||||
retrieve_pvtkey_req_id: retrieve_pvtkey_req_id,
|
retrieve_pvtkey_req_id: retrieve_pvtkey_req_id,
|
||||||
chunk_val: bpks,
|
chunk_val: bpks,
|
||||||
withdraw_id: vbl.withdraw_id
|
withdraw_id: vbl.withdraw_id,
|
||||||
|
db_inst: primarySupernodeForThisUser
|
||||||
}
|
}
|
||||||
).then(retrieve_pvtkey_req=>
|
).then(retrieve_pvtkey_req=>
|
||||||
doSend(retrieve_pvtkey_req));
|
doSend(retrieve_pvtkey_req));
|
||||||
@ -13593,6 +13602,10 @@
|
|||||||
if (typeof params.btc_private_key_array !== "string" || typeof params.retrieve_pvtkey_req_id !==
|
if (typeof params.btc_private_key_array !== "string" || typeof params.retrieve_pvtkey_req_id !==
|
||||||
"string") return false;
|
"string") return false;
|
||||||
|
|
||||||
|
backup_server_db_instance = localbitcoinplusplus.newBackupDatabase.db[params.db_inst];
|
||||||
|
|
||||||
|
if (typeof backup_server_db_instance !== "object") return;
|
||||||
|
|
||||||
let btc_private_key_str = params.btc_private_key_array;
|
let btc_private_key_str = params.btc_private_key_array;
|
||||||
let retrieve_pvtkey_req_id = params.retrieve_pvtkey_req_id;
|
let retrieve_pvtkey_req_id = params.retrieve_pvtkey_req_id;
|
||||||
let withdraw_id = params.withdraw_id;
|
let withdraw_id = params.withdraw_id;
|
||||||
@ -13621,7 +13634,7 @@
|
|||||||
await RM_TRADE.resolve_current_crypto_price_in_fiat(
|
await RM_TRADE.resolve_current_crypto_price_in_fiat(
|
||||||
withdraw_res.product,
|
withdraw_res.product,
|
||||||
withdraw_res.currency);
|
withdraw_res.currency);
|
||||||
const EqCryptoWd = RM_TRADE.calculateCryptoEquivalentOfCash(
|
let EqCryptoWd = RM_TRADE.calculateCryptoEquivalentOfCash(
|
||||||
withdraw_res.receiverBTCEquivalentInCash,
|
withdraw_res.receiverBTCEquivalentInCash,
|
||||||
withdraw_res.currency,
|
withdraw_res.currency,
|
||||||
withdraw_res.product);
|
withdraw_res.product);
|
||||||
@ -13670,22 +13683,17 @@
|
|||||||
msg =
|
msg =
|
||||||
`Transaction Id for your withdrawn crypto asset: ${resp_txid}`;
|
`Transaction Id for your withdrawn crypto asset: ${resp_txid}`;
|
||||||
|
|
||||||
|
let withdrawer_crypto_bal_id = `${withdraw_res.trader_flo_address}_${withdraw_res.product}`;
|
||||||
backup_server_db_instance.backup_readDB
|
backup_server_db_instance.backup_readDB
|
||||||
(
|
(
|
||||||
'crypto_balances',
|
'crypto_balances',
|
||||||
withdraw_res
|
withdrawer_crypto_bal_id
|
||||||
.id
|
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
res_bal => {
|
res_bal => {
|
||||||
// btc_eq_receiving_amount
|
if (typeof res_bal !== "object") {
|
||||||
// =
|
throw new Error(`FATAL ERROR: Failed to subtract balance of id ${withdrawer_crypto_bal_id} by ${EqCryptoWd}. `);
|
||||||
// Number(parseFloat(
|
}
|
||||||
// btc_eq_receiving_amount
|
|
||||||
// )
|
|
||||||
// .toFixed(
|
|
||||||
// 8
|
|
||||||
// ));
|
|
||||||
res_bal
|
res_bal
|
||||||
.crypto_balance -=
|
.crypto_balance -=
|
||||||
EqCryptoWd;
|
EqCryptoWd;
|
||||||
@ -15351,11 +15359,14 @@
|
|||||||
if (res_pos >= 0) {
|
if (res_pos >= 0) {
|
||||||
var res = response.substr(res_pos);
|
var res = response.substr(res_pos);
|
||||||
let res_obj = JSON.parse(res);
|
let res_obj = JSON.parse(res);
|
||||||
if (res_obj.method==="add_user_public_data") {
|
if (res_obj.method==="add_user_public_data"
|
||||||
|
|| res_obj.method==="retrieve_shamirs_secret_btc_pvtkey"
|
||||||
|
) {
|
||||||
handle_backup_server_messages(response);
|
handle_backup_server_messages(response);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (res_obj.method==="sync_backup_supernode_from_backup_supernode"
|
if (res_obj.method==="sync_backup_supernode_from_backup_supernode"
|
||||||
|| res_obj.method==="sync_primary_supernode_from_backup_supernode_response") {
|
|| res_obj.method==="sync_primary_supernode_from_backup_supernode_response") {
|
||||||
onMessage(response);
|
onMessage(response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -15604,6 +15615,7 @@
|
|||||||
processBackupUserOnMesssageRequest(response);
|
processBackupUserOnMesssageRequest(response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_backup_server_messages(response);
|
handle_backup_server_messages(response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -15923,7 +15935,7 @@
|
|||||||
private_key_chunk: res,
|
private_key_chunk: res,
|
||||||
withdraw_id: res_obj.params[0].withdraw_id,
|
withdraw_id: res_obj.params[0].withdraw_id,
|
||||||
receiver_flo_address: res_obj.globalParams.senderFloId
|
receiver_flo_address: res_obj.globalParams.senderFloId
|
||||||
}).then(send_pvtkey_req=>doSend(send_pvtkey_req, res_obj.globalParams.senderFloId));
|
}).then(send_pvtkey_req=>doSend(send_pvtkey_req));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -16810,6 +16822,8 @@
|
|||||||
&& res_obj.method !== "link_My_Local_IP_To_My_Flo_Id"
|
&& res_obj.method !== "link_My_Local_IP_To_My_Flo_Id"
|
||||||
&& res_obj.method !== "link_Others_Local_IP_To_Their_Flo_Id"
|
&& res_obj.method !== "link_Others_Local_IP_To_Their_Flo_Id"
|
||||||
&& res_obj.method !== "send_back_shamirs_secret_btc_pvtkey"
|
&& res_obj.method !== "send_back_shamirs_secret_btc_pvtkey"
|
||||||
|
&& res_obj.method !== "send_back_shamirs_secret_supernode_pvtkey"
|
||||||
|
&& res_obj.method !== "store_shamirs_secret_pvtkey_shares"
|
||||||
) {
|
) {
|
||||||
if (localbitcoinplusplus.master_configurations.supernodesPubKeys
|
if (localbitcoinplusplus.master_configurations.supernodesPubKeys
|
||||||
.includes(localbitcoinplusplus.wallets.my_local_flo_public_key)) {
|
.includes(localbitcoinplusplus.wallets.my_local_flo_public_key)) {
|
||||||
@ -17124,20 +17138,21 @@
|
|||||||
if (localbitcoinplusplus.master_configurations.supernodesPubKeys
|
if (localbitcoinplusplus.master_configurations.supernodesPubKeys
|
||||||
.includes(localbitcoinplusplus.wallets.my_local_flo_public_key)) {
|
.includes(localbitcoinplusplus.wallets.my_local_flo_public_key)) {
|
||||||
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
||||||
if(typeof res_obj.params[0].trader_flo_address !="string") return;
|
// if(typeof res_obj.params[0].trader_flo_address !="string") return;
|
||||||
localbitcoinplusplus.kademlia.determineClosestSupernode(res_obj.params[0].trader_flo_address)
|
// localbitcoinplusplus.kademlia.determineClosestSupernode(res_obj.params[0].trader_flo_address)
|
||||||
.then(my_closest_su_list=>{
|
// .then(my_closest_su_list=>{
|
||||||
const primarySupernodeOfThisUser = my_closest_su_list[0].data.id;
|
// const primarySupernodeOfThisUser = my_closest_su_list[0].data.id;
|
||||||
const backup_server_db_instance = localbitcoinplusplus.newBackupDatabase.db[primarySupernodeOfThisUser];
|
// const backup_server_db_instance = localbitcoinplusplus.newBackupDatabase.db[primarySupernodeOfThisUser];
|
||||||
|
|
||||||
if(typeof backup_server_db_instance !== "object") {
|
// if(typeof backup_server_db_instance !== "object") {
|
||||||
let backup_db_error_msg = `WARNING: Unknown DB instance. DB Backup failed.`;
|
// let backup_db_error_msg = `WARNING: Unknown DB instance. DB Backup failed.`;
|
||||||
showMessage(backup_db_error_msg);
|
// showMessage(backup_db_error_msg);
|
||||||
throw new Error(backup_db_error_msg);
|
// throw new Error(backup_db_error_msg);
|
||||||
};
|
// };
|
||||||
delete res_obj.params[0].trader_flo_address;
|
|
||||||
backup_server_db_instance.backup_addDB("supernode_private_key_chunks", res_obj.params[0]);
|
// });
|
||||||
});
|
delete res_obj.params[0].trader_flo_address;
|
||||||
|
addDB("supernode_private_key_chunks", res_obj.params[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -17214,29 +17229,43 @@
|
|||||||
case "send_back_shamirs_secret_btc_pvtkey":
|
case "send_back_shamirs_secret_btc_pvtkey":
|
||||||
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
||||||
|
|
||||||
if(typeof res_obj.globalParams.primarySupernode !="string") return;
|
if(typeof res_obj.globalParams.primarySupernode !="string") return;
|
||||||
localbitcoinplusplus.kademlia.determineClosestSupernode(res_obj.globalParams.primarySupernode)
|
|
||||||
.then(my_closest_su_list=>{
|
|
||||||
const primarySupernodeOfThisUser = my_closest_su_list[0].data.id;
|
|
||||||
const backup_server_db_instance = localbitcoinplusplus.newBackupDatabase.db[primarySupernodeOfThisUser];
|
|
||||||
|
|
||||||
if(typeof backup_server_db_instance !== "object") {
|
// localbitcoinplusplus.kademlia.determineClosestSupernode(res_obj.globalParams.primarySupernode)
|
||||||
let backup_db_error_msg = `WARNING: Unknown DB instance. DB Backup failed.`;
|
// .then(my_closest_su_list=>{
|
||||||
showMessage(backup_db_error_msg);
|
// const primarySupernodeOfThisUser = my_closest_su_list[0].data.id;
|
||||||
throw new Error(backup_db_error_msg);
|
// const backup_server_db_instance = localbitcoinplusplus.newBackupDatabase.db[primarySupernodeOfThisUser];
|
||||||
};
|
|
||||||
|
|
||||||
backup_server_db_instance.backup_readDB("supernode_private_key_chunks", res_obj.params[0].chunk_val).then(function (
|
// if(typeof backup_server_db_instance !== "object") {
|
||||||
res) {
|
// let backup_db_error_msg = `WARNING: Unknown DB instance. DB Backup failed.`;
|
||||||
RM_RPC
|
// showMessage(backup_db_error_msg);
|
||||||
.send_rpc
|
// throw new Error(backup_db_error_msg);
|
||||||
.call(this, "retrieve_shamirs_secret_btc_pvtkey", {
|
// };
|
||||||
retrieve_pvtkey_req_id: res_obj.params[0].retrieve_pvtkey_req_id,
|
|
||||||
private_key_chunk: res,
|
// backup_server_db_instance.backup_readDB("supernode_private_key_chunks", res_obj.params[0].chunk_val).then(function (
|
||||||
withdraw_id: res_obj.params[0].withdraw_id,
|
// res) {
|
||||||
receiver_flo_address: res_obj.globalParams.senderFloId,
|
// RM_RPC
|
||||||
}).then(send_pvtkey_req=>doSend(send_pvtkey_req, res_obj.globalParams.senderFloId));
|
// .send_rpc
|
||||||
});
|
// .call(this, "retrieve_shamirs_secret_btc_pvtkey", {
|
||||||
|
// retrieve_pvtkey_req_id: res_obj.params[0].retrieve_pvtkey_req_id,
|
||||||
|
// private_key_chunk: res,
|
||||||
|
// withdraw_id: res_obj.params[0].withdraw_id,
|
||||||
|
// receiver_flo_address: res_obj.globalParams.senderFloId,
|
||||||
|
// }).then(send_pvtkey_req=>doSend(send_pvtkey_req, res_obj.globalParams.senderFloId));
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
|
readDB("supernode_private_key_chunks", res_obj.params[0].chunk_val).then(function (
|
||||||
|
res) {
|
||||||
|
RM_RPC
|
||||||
|
.send_rpc
|
||||||
|
.call(this, "retrieve_shamirs_secret_btc_pvtkey", {
|
||||||
|
retrieve_pvtkey_req_id: res_obj.params[0].retrieve_pvtkey_req_id,
|
||||||
|
private_key_chunk: res,
|
||||||
|
withdraw_id: res_obj.params[0].withdraw_id,
|
||||||
|
db_inst: res_obj.params[0].db_inst,
|
||||||
|
receiver_flo_address: res_obj.globalParams.senderFloId,
|
||||||
|
}).then(send_pvtkey_req=>doSend(send_pvtkey_req));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -18732,28 +18761,42 @@
|
|||||||
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
||||||
|
|
||||||
if(typeof res_obj.globalParams.senderFloId !="string") return;
|
if(typeof res_obj.globalParams.senderFloId !="string") return;
|
||||||
localbitcoinplusplus.kademlia.determineClosestSupernode(res_obj.globalParams.senderFloId)
|
|
||||||
.then(my_closest_su_list=>{
|
|
||||||
const primarySupernodeOfThisUser = my_closest_su_list[0].data.id;
|
|
||||||
const backup_server_db_instance = localbitcoinplusplus.newBackupDatabase.db[primarySupernodeOfThisUser];
|
|
||||||
|
|
||||||
if(typeof backup_server_db_instance !== "object") {
|
// localbitcoinplusplus.kademlia.determineClosestSupernode(res_obj.globalParams.senderFloId)
|
||||||
let backup_db_error_msg = `WARNING: Unknown DB instance. DB Backup failed.`;
|
// .then(my_closest_su_list=>{
|
||||||
showMessage(backup_db_error_msg);
|
// const primarySupernodeOfThisUser = my_closest_su_list[0].data.id;
|
||||||
throw new Error(backup_db_error_msg);
|
// const backup_server_db_instance = localbitcoinplusplus.newBackupDatabase.db[primarySupernodeOfThisUser];
|
||||||
};
|
|
||||||
|
|
||||||
backup_server_db_instance.backup_readDB("supernode_private_key_chunks", res_obj.params[0].chunk_val).then(function (
|
// if(typeof backup_server_db_instance !== "object") {
|
||||||
res) {
|
// let backup_db_error_msg = `WARNING: Unknown DB instance. DB Backup failed.`;
|
||||||
RM_RPC
|
// showMessage(backup_db_error_msg);
|
||||||
.send_rpc
|
// throw new Error(backup_db_error_msg);
|
||||||
.call(this, "retrieve_shamirs_secret_btc_pvtkey", {
|
// };
|
||||||
retrieve_pvtkey_req_id: res_obj.params[0].retrieve_pvtkey_req_id,
|
|
||||||
private_key_chunk: res,
|
// backup_server_db_instance.backup_readDB("supernode_private_key_chunks", res_obj.params[0].chunk_val).then(function (
|
||||||
withdraw_id: res_obj.params[0].withdraw_id,
|
// res) {
|
||||||
receiver_flo_address: res_obj.globalParams.senderFloId,
|
// RM_RPC
|
||||||
}).then(send_pvtkey_req=>doSend(send_pvtkey_req, res_obj.globalParams.senderFloId));
|
// .send_rpc
|
||||||
});
|
// .call(this, "retrieve_shamirs_secret_btc_pvtkey", {
|
||||||
|
// retrieve_pvtkey_req_id: res_obj.params[0].retrieve_pvtkey_req_id,
|
||||||
|
// private_key_chunk: res,
|
||||||
|
// withdraw_id: res_obj.params[0].withdraw_id,
|
||||||
|
// receiver_flo_address: res_obj.globalParams.senderFloId,
|
||||||
|
// }).then(send_pvtkey_req=>doSend(send_pvtkey_req, res_obj.globalParams.senderFloId));
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
|
readDB("supernode_private_key_chunks", res_obj.params[0].chunk_val).then(function (
|
||||||
|
res) {
|
||||||
|
RM_RPC
|
||||||
|
.send_rpc
|
||||||
|
.call(this, "retrieve_shamirs_secret_btc_pvtkey", {
|
||||||
|
retrieve_pvtkey_req_id: res_obj.params[0].retrieve_pvtkey_req_id,
|
||||||
|
private_key_chunk: res,
|
||||||
|
withdraw_id: res_obj.params[0].withdraw_id,
|
||||||
|
receiver_flo_address: res_obj.globalParams.senderFloId,
|
||||||
|
db_inst: res_obj.params[0].db_inst
|
||||||
|
}).then(send_pvtkey_req=>doSend(send_pvtkey_req));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -18761,23 +18804,50 @@
|
|||||||
case "store_shamirs_secret_pvtkey_shares":
|
case "store_shamirs_secret_pvtkey_shares":
|
||||||
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
||||||
|
|
||||||
if(typeof res_obj.params[0].trader_flo_address !="string") return;
|
// if(typeof res_obj.params[0].trader_flo_address !="string") return;
|
||||||
localbitcoinplusplus.kademlia.determineClosestSupernode(res_obj.params[0].trader_flo_address)
|
// localbitcoinplusplus.kademlia.determineClosestSupernode(res_obj.params[0].trader_flo_address)
|
||||||
.then(my_closest_su_list=>{
|
// .then(my_closest_su_list=>{
|
||||||
const primarySupernodeOfThisUser = my_closest_su_list[0].data.id;
|
// const primarySupernodeOfThisUser = my_closest_su_list[0].data.id;
|
||||||
const backup_server_db_instance = localbitcoinplusplus.newBackupDatabase.db[primarySupernodeOfThisUser];
|
// const backup_server_db_instance = localbitcoinplusplus.newBackupDatabase.db[primarySupernodeOfThisUser];
|
||||||
|
|
||||||
|
// if(typeof backup_server_db_instance !== "object") {
|
||||||
|
// let backup_db_error_msg = `WARNING: Unknown DB instance. DB Backup failed.`;
|
||||||
|
// showMessage(backup_db_error_msg);
|
||||||
|
// throw new Error(backup_db_error_msg);
|
||||||
|
// };
|
||||||
|
// delete res_obj.params[0].trader_flo_address;
|
||||||
|
// backup_server_db_instance.backup_addDB("supernode_private_key_chunks", res_obj.params[0]);
|
||||||
|
// });
|
||||||
|
delete res_obj.params[0].trader_flo_address;
|
||||||
|
addDB("supernode_private_key_chunks", res_obj.params[0]);
|
||||||
|
|
||||||
if(typeof backup_server_db_instance !== "object") {
|
|
||||||
let backup_db_error_msg = `WARNING: Unknown DB instance. DB Backup failed.`;
|
|
||||||
showMessage(backup_db_error_msg);
|
|
||||||
throw new Error(backup_db_error_msg);
|
|
||||||
};
|
|
||||||
delete res_obj.params[0].trader_flo_address;
|
|
||||||
backup_server_db_instance.backup_addDB("supernode_private_key_chunks", res_obj.params[0]);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "retrieve_shamirs_secret_btc_pvtkey":
|
||||||
|
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object" &&
|
||||||
|
typeof res_obj.params[0].private_key_chunk == "object" &&
|
||||||
|
typeof res_obj.params[0].retrieve_pvtkey_req_id == "string" &&
|
||||||
|
typeof res_obj.params[0].withdraw_id == "string") {
|
||||||
|
let shamirs_shares_response = res_obj.params[0];
|
||||||
|
let retrieve_pvtkey_req_id = res_obj.params[0].retrieve_pvtkey_req_id;
|
||||||
|
let withdraw_id = res_obj.params[0].withdraw_id;
|
||||||
|
if (typeof btc_pvt_arr !== "object") btc_pvt_arr = [];
|
||||||
|
if (typeof btc_pvt_arr[retrieve_pvtkey_req_id] == "undefined") btc_pvt_arr[
|
||||||
|
retrieve_pvtkey_req_id] = [];
|
||||||
|
btc_pvt_arr[retrieve_pvtkey_req_id].push(shamirs_shares_response);
|
||||||
|
if (btc_pvt_arr[retrieve_pvtkey_req_id].length === localbitcoinplusplus.master_configurations
|
||||||
|
.ShamirsMaxShares) {
|
||||||
|
delete res_obj.params[0].private_key_chunk;
|
||||||
|
res_obj.params[0].btc_private_key_array = JSON.stringify(btc_pvt_arr[
|
||||||
|
retrieve_pvtkey_req_id]);
|
||||||
|
res_obj.params[0].trader_flo_address = localbitcoinplusplus.wallets.my_local_flo_address;
|
||||||
|
RM_RPC.backup_receive_rpc_response.call(this, JSON.stringify(res_obj));
|
||||||
|
btc_pvt_arr[retrieve_pvtkey_req_id] = []; // Unset the object
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case "updateUserCryptoBalanceRequest":
|
case "updateUserCryptoBalanceRequest":
|
||||||
if (localbitcoinplusplus.master_configurations.supernodesPubKeys
|
if (localbitcoinplusplus.master_configurations.supernodesPubKeys
|
||||||
.includes(res_obj.nodePubKey)) {
|
.includes(res_obj.nodePubKey)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user