1
0
Fork 0
forked from lthn/blockchain

Merge branch 'release' into develop

# Conflicts:
#	src/version.h.in
This commit is contained in:
sowle 2024-10-15 17:39:11 +02:00
commit 5d429e1e76
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC
3 changed files with 46 additions and 2 deletions

View file

@ -4,7 +4,7 @@
// Copyright (c) 2012-2013 The Boolberry developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <regex>
#include "include_base_utils.h"
#include <boost/foreach.hpp>
#ifndef MOBILE_WALLET_BUILD
@ -4442,6 +4442,45 @@ namespace currency
}
}
//------------------------------------------------------------------
#define ASSET_TICKER_REGEXP "[A-Z0-9]{1,10}"
#define ASSET_FULL_NAME_REGEXP "[A-Za-z0-9.,:!\\-() ]{0,400}"
bool validate_asset_ticker(const std::string& ticker)
{
static std::regex asset_ticker_regexp(ASSET_TICKER_REGEXP);
return std::regex_match(ticker, asset_ticker_regexp);
}
//------------------------------------------------------------------
bool validate_asset_full_name(const std::string& full_name)
{
static std::regex asset_full_name_regexp(ASSET_FULL_NAME_REGEXP);
return std::regex_match(full_name, asset_full_name_regexp);
}
//------------------------------------------------------------------
bool validate_asset_ticker_and_full_name(const asset_descriptor_base& adb)
{
if (!validate_asset_ticker(adb.ticker))
return false;
if (!validate_asset_full_name(adb.full_name))
return false;
//CHECK_AND_ASSERT_MES(validate_asset_ticker(adb.ticker), false, "asset's ticker isn't valid: " << adb.ticker);
//CHECK_AND_ASSERT_MES(validate_asset_full_name(adb.full_name), false, "asset's full_name isn't valid: " << adb.full_name);
return true;
}
//------------------------------------------------------------------
void replace_asset_ticker_and_full_name_if_invalid(asset_descriptor_base& adb, const crypto::public_key& asset_id)
{
if (!validate_asset_ticker(adb.ticker))
adb.ticker = "#BADASSET#";
if (!validate_asset_full_name(adb.full_name))
{
std::string abcd = crypto::pod_to_hex(asset_id).substr(60, 4); // last 4 hex chars
adb.full_name = "#bad asset name " + abcd + "#";
}
}
//------------------------------------------------------------------
std::string dump_ring_sig_data(const crypto::hash& hash_for_sig, const crypto::key_image& k_image, const std::vector<const crypto::public_key*>& output_keys_ptrs, const std::vector<crypto::signature>& sig)
{
std::stringstream s;

View file

@ -276,6 +276,11 @@ namespace currency
bool validate_asset_operation_amount_commitment(asset_op_verification_context& context);
const char* get_asset_operation_type_string(size_t asset_operation_type, bool short_name = false);
bool validate_asset_ticker(const std::string& ticker);
bool validate_asset_full_name(const std::string& full_name);
bool validate_asset_ticker_and_full_name(const asset_descriptor_base& adb);
void replace_asset_ticker_and_full_name_if_invalid(asset_descriptor_base& adb, const crypto::public_key& asset_id);
//---------------------------------------------------------------
bool construct_miner_tx(size_t height, size_t median_size, const boost::multiprecision::uint128_t& already_generated_coins,
size_t current_block_size,

View file

@ -8,6 +8,6 @@
#define PROJECT_REVISION "2"
#define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION
#define PROJECT_VERSION_BUILD_NO 351
#define PROJECT_VERSION_BUILD_NO 352
#define PROJECT_VERSION_BUILD_NO_STR STRINGIFY_EXPAND(PROJECT_VERSION_BUILD_NO)
#define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]"