Skip to content
Merged
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
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ Portions Copyright (c) 2012-2013 The Cryptonote developers.
## Development resources

- Web: [beldex.io](https://beldex.io)
- Telegram: [t.me/beldexcoin](https://t.me/beldex_official)
- Telegram: [t.me/beldexcoin](https://t.me/beldexcoin)
- GitHub: [https://github.com/Beldex-Coin/beldex](https://github.com/Beldex-Coin/beldex)

## Vulnerability disclosure

- Check out our [Vulnerability Response Process](https://beldex-project.github.io/beldex-docs/Contributing/VULNERABILITY_RESPONSE_BELDEX), encourages prompt disclosure of any Vulnerabilities

## Information

Expand Down
17 changes: 10 additions & 7 deletions contrib/epee/include/epee/storages/portable_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,18 @@ namespace epee
bool portable_storage::get_value(const std::string& value_name, T& val, section* parent_section)
{
static_assert(variant_contains<T, storage_entry>);
//TRY_ENTRY();
if(!parent_section) parent_section = &m_root;
if (!parent_section)
parent_section = &m_root;
storage_entry* pentry = find_storage_entry(value_name, parent_section);
if(!pentry)
return false;
if (!pentry)
return false;

var::visit([&val](const auto& v) { convert_t(v, val); }, *pentry);
return true;
//CATCH_ENTRY("portable_storage::template<>get_value", false);
try {
var::visit([&val](const auto& v) { convert_t(v, val); }, *pentry);
return true;
} catch (const std::exception&) {
return false;
}
}
//---------------------------------------------------------------------------------------------------------------
template <typename T>
Expand Down
13 changes: 8 additions & 5 deletions contrib/epee/src/portable_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,18 @@ namespace epee {

bool portable_storage::get_value(const std::string& value_name, storage_entry& val, section* parent_section)
{
//TRY_ENTRY();
if(!parent_section) parent_section = &m_root;
if (!parent_section)
parent_section = &m_root;
storage_entry* pentry = find_storage_entry(value_name, parent_section);
if(!pentry)
return false;

val = *pentry;
return true;
//CATCH_ENTRY("portable_storage::template<>get_value", false);
try {
val = *pentry;
return true;
} catch (const std::exception&) {
return false;
}
}

storage_entry* portable_storage::find_storage_entry(const std::string& pentry_name, section* psection)
Expand Down
23 changes: 15 additions & 8 deletions src/cryptonote_core/cryptonote_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1758,9 +1758,10 @@ namespace cryptonote
return m_mempool.check_for_key_images(key_im, spent);
}
//-----------------------------------------------------------------------------------------------
std::optional<std::tuple<int64_t, int64_t, int64_t>> core::get_coinbase_tx_sum(uint64_t start_offset, size_t count)
std::optional<std::tuple<unsigned long long, unsigned long long, unsigned long long>>
core::get_coinbase_tx_sum(uint64_t start_offset, size_t count)
{
std::optional<std::tuple<int64_t, int64_t, int64_t>> result{{0, 0, 0}};
std::optional<std::tuple<unsigned long long, unsigned long long, unsigned long long>> result{{0ULL, 0ULL, 0ULL}};
if (count == 0)
return result;

Expand All @@ -1787,6 +1788,8 @@ namespace cryptonote
{
std::shared_lock lock{m_coinbase_cache.mutex};
if (count >= m_coinbase_cache.height) {
// NOTE: if m_coinbase_cache.emissions/fees/burnt are signed types, they will be implicitly
// converted to unsigned here. If they are signed, consider static_cast<unsigned long long>.
emission_amount = m_coinbase_cache.emissions;
total_fee_amount = m_coinbase_cache.fees;
burnt_beldex = m_coinbase_cache.burnt;
Expand Down Expand Up @@ -1837,20 +1840,24 @@ namespace cryptonote
[this, &cache_to, &result, &cache_build_started](uint64_t height, const crypto::hash& hash, const block& b){
auto& [emission_amount, total_fee_amount, burnt_beldex] = *result;
std::vector<transaction> txs;
auto coinbase_amount = static_cast<int64_t>(get_outs_money_amount(b.miner_tx));

// Convert amounts into unsigned accumulators
const unsigned long long coinbase_amount = static_cast<unsigned long long>(get_outs_money_amount(b.miner_tx));
get_transactions(b.tx_hashes, txs);
int64_t tx_fee_amount = 0;
for(const auto& tx: txs)

unsigned long long tx_fee_amount = 0ULL;
for (const auto& tx: txs)
{
tx_fee_amount += static_cast<int64_t>(get_tx_miner_fee(tx, b.major_version >= feature::FEE_BURNING));
if(b.major_version >= feature::FEE_BURNING)
tx_fee_amount += static_cast<unsigned long long>(get_tx_miner_fee(tx, b.major_version >= feature::FEE_BURNING));
if (b.major_version >= feature::FEE_BURNING)
{
burnt_beldex += static_cast<int64_t>(get_burned_amount_from_tx_extra(tx.extra));
burnt_beldex += static_cast<unsigned long long>(get_burned_amount_from_tx_extra(tx.extra));
}
}

emission_amount += coinbase_amount - tx_fee_amount;
total_fee_amount += tx_fee_amount;

if (cache_to && cache_to == height)
{
std::unique_lock lock{m_coinbase_cache.mutex};
Expand Down
2 changes: 1 addition & 1 deletion src/cryptonote_core/cryptonote_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ namespace cryptonote
* requested range. The optional value will be empty only if requesting the full chain *and*
* another thread is already calculating it.
*/
std::optional<std::tuple<int64_t, int64_t, int64_t>> get_coinbase_tx_sum(uint64_t start_offset, size_t count);
std::optional<std::tuple<unsigned long long, unsigned long long, unsigned long long>> get_coinbase_tx_sum(uint64_t start_offset, size_t count);

/**
* @brief get the network type we're on
Expand Down
1 change: 0 additions & 1 deletion src/cryptonote_core/master_node_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,6 @@ namespace master_nodes
// NOTE: No POS quorums are generated when the network has insufficient nodes to generate quorums
// Or, block specifies time after all the rounds have timed out
bool miner_block = !POS_hf || !POS_quorum;
// std::cout << "miner_block : " << miner_block << std::endl;

result = verify_block_components(m_blockchain.nettype(),
block,
Expand Down
15 changes: 14 additions & 1 deletion src/wallet/wallet_rpc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,21 @@ namespace tools
if(!ps.load_from_json(body))
return jsonrpc_error_response(res, -32700, "Parse error", {});

nlohmann::json id;
epee::serialization::storage_entry epee_id{std::string{}};
ps.get_value("id", epee_id, nullptr);
if (std::string str_val; ps.get_value("id", str_val, nullptr)) {
epee_id = str_val;
id = std::move(str_val);
} else if (int64_t i64_val; ps.get_value("id", i64_val, nullptr)) {
epee_id = i64_val;
id = i64_val;
} else {
return jsonrpc_error_response(
res,
-32700,
"Parse error, missing a valid (string or integer) JSON RPC 'id'",
{});
}

nlohmann::json id = var::get<std::string>(epee_id);

Expand Down
Loading