Monero
Loading...
Searching...
No Matches
cryptonote_basic_impl.h
Go to the documentation of this file.
1// Copyright (c) 2014-2022, The Monero Project
2//
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without modification, are
6// permitted provided that the following conditions are met:
7//
8// 1. Redistributions of source code must retain the above copyright notice, this list of
9// conditions and the following disclaimer.
10//
11// 2. Redistributions in binary form must reproduce the above copyright notice, this list
12// of conditions and the following disclaimer in the documentation and/or other
13// materials provided with the distribution.
14//
15// 3. Neither the name of the copyright holder nor the names of its contributors may be
16// used to endorse or promote products derived from this software without specific
17// prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28//
29// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
30
31#pragma once
32
33#include "cryptonote_basic.h"
34#include "crypto/crypto.h"
35#include "crypto/hash.h"
36
37
38namespace cryptonote {
39 /************************************************************************/
40 /* */
41 /************************************************************************/
42 template<class t_array>
43 struct array_hasher: std::unary_function<t_array&, std::size_t>
44 {
45 std::size_t operator()(const t_array& val) const
46 {
47 return boost::hash_range(&val.data[0], &val.data[sizeof(val.data)]);
48 }
49 };
50
51
52#pragma pack(push, 1)
54 {
58 };
60 {
65 };
66#pragma pack (pop)
67
68 namespace
69 {
70 inline std::string return_first_address(const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid)
71 {
72 if (addresses.empty())
73 return {};
74 return addresses[0];
75 }
76 }
77
79 {
84 };
85
86 /************************************************************************/
87 /* Cryptonote helper functions */
88 /************************************************************************/
90 size_t get_max_tx_size();
91 bool get_block_reward(size_t median_weight, size_t current_block_weight, uint64_t already_generated_coins, uint64_t &reward, uint8_t version);
94
96 network_type nettype
97 , bool subaddress
98 , const account_public_address& adr
99 );
100
102 network_type nettype
103 , const account_public_address& adr
104 , const crypto::hash8& payment_id
105 );
106
109 , network_type nettype
110 , const std::string& str
111 );
112
115 , network_type nettype
116 , const std::string& str_or_url
117 , std::function<std::string(const std::string&, const std::vector<std::string>&, bool)> dns_confirm = return_first_address
118 );
119
120 bool is_coinbase(const transaction& tx);
121
124}
125
126bool parse_hash256(const std::string &str_hash, crypto::hash& hash);
127
cryptonote::block b
Definition: block.cpp:40
Definition: cryptonote_basic.h:205
bool parse_hash256(const std::string &str_hash, crypto::hash &hash)
Definition: cryptonote_basic_impl.cpp:316
static MDB_envinfo info
Definition: mdb_load.c:37
static int version
Definition: mdb_load.c:29
POD_CLASS hash8
Definition: hash.h:51
POD_CLASS hash
Definition: hash.h:48
Holds cryptonote related classes and helpers.
Definition: blockchain_db.cpp:45
network_type
Definition: cryptonote_config.h:289
bool operator==(const cryptonote::transaction &a, const cryptonote::transaction &b)
Definition: cryptonote_basic_impl.cpp:306
bool get_account_address_from_str(address_parse_info &info, network_type nettype, std::string const &str)
Definition: cryptonote_basic_impl.cpp:186
uint8_t get_account_address_checksum(const public_address_outer_blob &bl)
Definition: cryptonote_basic_impl.cpp:130
std::string get_account_address_as_str(network_type nettype, bool subaddress, account_public_address const &adr)
Definition: cryptonote_basic_impl.cpp:150
size_t get_min_block_weight(uint8_t version)
Definition: cryptonote_basic_impl.cpp:69
bool is_coinbase(const transaction &tx)
Definition: cryptonote_basic_impl.cpp:175
size_t get_max_tx_size()
Definition: cryptonote_basic_impl.cpp:78
uint8_t get_account_integrated_address_checksum(const public_integrated_address_outer_blob &bl)
Definition: cryptonote_basic_impl.cpp:140
bool get_account_address_from_str_or_url(address_parse_info &info, network_type nettype, const std::string &str_or_url, std::function< std::string(const std::string &, const std::vector< std::string > &, bool)> dns_confirm)
Definition: cryptonote_basic_impl.cpp:291
std::string get_account_integrated_address_as_str(network_type nettype, account_public_address const &adr, crypto::hash8 const &payment_id)
Definition: cryptonote_basic_impl.cpp:161
bool get_block_reward(size_t median_weight, size_t current_block_weight, uint64_t already_generated_coins, uint64_t &reward, uint8_t version)
Definition: cryptonote_basic_impl.cpp:83
epee::net_utils::http::url_content url
Definition: parse_url.cpp:38
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
const char *const str
Definition: portlistingparse.c:23
unsigned char uint8_t
Definition: stdint.h:124
Definition: cryptonote_basic.h:512
Definition: cryptonote_basic_impl.h:79
bool is_subaddress
Definition: cryptonote_basic_impl.h:81
bool has_payment_id
Definition: cryptonote_basic_impl.h:82
account_public_address address
Definition: cryptonote_basic_impl.h:80
crypto::hash8 payment_id
Definition: cryptonote_basic_impl.h:83
Definition: cryptonote_basic_impl.h:44
std::size_t operator()(const t_array &val) const
Definition: cryptonote_basic_impl.h:45
Definition: cryptonote_basic.h:475
Definition: cryptonote_basic_impl.h:54
account_public_address m_address
Definition: cryptonote_basic_impl.h:56
uint8_t check_sum
Definition: cryptonote_basic_impl.h:57
uint8_t m_ver
Definition: cryptonote_basic_impl.h:55
Definition: cryptonote_basic_impl.h:60
uint8_t m_ver
Definition: cryptonote_basic_impl.h:61
account_public_address m_address
Definition: cryptonote_basic_impl.h:62
uint8_t check_sum
Definition: cryptonote_basic_impl.h:64
crypto::hash8 payment_id
Definition: cryptonote_basic_impl.h:63
cryptonote::transaction tx
Definition: transaction.cpp:40