Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/cryptonote_core/cryptonote_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1991,7 +1991,16 @@ namespace cryptonote
bool core::handle_btencoded_uptime_proof(const NOTIFY_BTENCODED_UPTIME_PROOF::request &req, bool &my_uptime_proof_confirmation)
{
crypto::x25519_public_key pkey = {};
auto proof = std::make_unique<uptime_proof::Proof>(req.proof);
std::unique_ptr<uptime_proof::Proof> proof;
try
{
proof = std::make_unique<uptime_proof::Proof>(req.proof);
}
catch (const std::exception &e)
{
MWARNING("Failed to parse uptime proof: " << e.what());
return false;
}
proof->sig = tools::make_from_guts<crypto::signature>(req.sig);
proof->sig_ed25519 = tools::make_from_guts<crypto::ed25519_signature>(req.ed_sig);
auto pubkey = proof->pubkey;
Expand Down
6 changes: 6 additions & 0 deletions src/cryptonote_core/uptime_proof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Proof::Proof(const std::string& serialized_proof)
const bt_dict bt_proof = bt_deserialize<bt_dict>(serialized_proof);
//mnode_version <X,X,X>
const bt_list& bt_version = var::get<bt_list>(bt_proof.at("v"));
if (bt_version.size() != version.size())
throw std::invalid_argument("uptime proof: invalid mnode_version list size");
int k = 0;
for (bt_value const &i: bt_version){
version[k++] = static_cast<uint16_t>(get_int<unsigned>(i));
Expand All @@ -72,12 +74,16 @@ Proof::Proof(const std::string& serialized_proof)
storage_omq_port = get_int<unsigned>(bt_proof.at("sop"));
//storage_version
const bt_list& bt_storage_version = var::get<bt_list>(bt_proof.at("sv"));
if (bt_storage_version.size() != storage_server_version.size())
throw std::invalid_argument("uptime proof: invalid storage_version list size");
k = 0;
for (bt_value const &i: bt_storage_version){
storage_server_version[k++] = static_cast<uint16_t>(get_int<unsigned>(i));
}
//belnet_version
const bt_list& bt_belnet_version = var::get<bt_list>(bt_proof.at("lv"));
if (bt_belnet_version.size() != belnet_version.size())
throw std::invalid_argument("uptime proof: invalid belnet_version list size");
k = 0;
for (bt_value const &i: bt_belnet_version){
belnet_version[k++] = static_cast<uint16_t>(get_int<unsigned>(i));
Expand Down