Monero
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 
38 namespace cryptonote {
39  /************************************************************************/
40  /* */
41  /************************************************************************/
42 
43 #pragma pack(push, 1)
45  {
49  };
51  {
56  };
57 #pragma pack (pop)
58 
59  namespace
60  {
61  inline std::string return_first_address(const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid)
62  {
63  if (addresses.empty())
64  return {};
65  return addresses[0];
66  }
67  }
68 
70  {
75  };
76 
77  /************************************************************************/
78  /* Cryptonote helper functions */
79  /************************************************************************/
81  size_t get_max_tx_size();
82  bool get_block_reward(size_t median_weight, size_t current_block_weight, uint64_t already_generated_coins, uint64_t &reward, uint8_t version);
85 
87  network_type nettype
88  , bool subaddress
89  , const account_public_address& adr
90  );
91 
93  network_type nettype
94  , const account_public_address& adr
95  , const crypto::hash8& payment_id
96  );
97 
100  , network_type nettype
101  , const std::string& str
102  );
103 
106  , network_type nettype
107  , const std::string& str_or_url
108  , std::function<std::string(const std::string&, const std::vector<std::string>&, bool)> dns_confirm = return_first_address
109  );
110 
111  bool is_coinbase(const transaction& tx);
112 
114  bool operator ==(const cryptonote::block& a, const cryptonote::block& b);
115 }
116 
117 bool parse_hash256(const std::string &str_hash, crypto::hash& hash);
118 
epee::net_utils::http::url_content url
Definition: parse_url.cpp:38
bool is_coinbase(const transaction &tx)
Definition: cryptonote_basic_impl.cpp:175
std::string get_account_address_as_str(network_type nettype, bool subaddress, account_public_address const &adr)
Definition: cryptonote_basic_impl.cpp:150
Definition: cryptonote_basic_impl.h:44
crypto::hash8 payment_id
Definition: cryptonote_basic_impl.h:54
::std::string string
Definition: gtest-port.h:1097
size_t get_max_tx_size()
Definition: cryptonote_basic_impl.cpp:78
Definition: cryptonote_basic.h:474
size_t get_min_block_weight(uint8_t version)
Definition: cryptonote_basic_impl.cpp:69
uint8_t get_account_integrated_address_checksum(const public_integrated_address_outer_blob &bl)
Definition: cryptonote_basic_impl.cpp:140
unsigned char uint8_t
Definition: stdint.h:124
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
bool is_subaddress
Definition: cryptonote_basic_impl.h:72
Holds cryptonote related classes and helpers.
Definition: blockchain_db.cpp:44
uint8_t m_ver
Definition: cryptonote_basic_impl.h:46
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
uint8_t get_account_address_checksum(const public_address_outer_blob &bl)
Definition: cryptonote_basic_impl.cpp:130
uint8_t check_sum
Definition: cryptonote_basic_impl.h:48
uint8_t check_sum
Definition: cryptonote_basic_impl.h:55
Definition: cryptonote_basic_impl.h:69
bool has_payment_id
Definition: cryptonote_basic_impl.h:73
account_public_address address
Definition: cryptonote_basic_impl.h:71
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
unsigned __int64 uint64_t
Definition: stdint.h:136
account_public_address m_address
Definition: cryptonote_basic_impl.h:47
static MDB_envinfo info
Definition: mdb_load.c:37
version
Supported socks variants.
Definition: socks.h:57
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
const char *const str
Definition: portlistingparse.c:23
bool operator==(const cryptonote::transaction &a, const cryptonote::transaction &b)
Definition: cryptonote_basic_impl.cpp:306
network_type
Definition: cryptonote_config.h:301
Definition: cryptonote_basic.h:511
POD_CLASS hash8
Definition: hash.h:52
bool parse_hash256(const std::string &str_hash, crypto::hash &hash)
Definition: cryptonote_basic_impl.cpp:316
account_public_address m_address
Definition: cryptonote_basic_impl.h:53
bool get_account_address_from_str(address_parse_info &info, network_type nettype, std::string const &str)
Definition: cryptonote_basic_impl.cpp:186
cryptonote::transaction tx
Definition: transaction.cpp:40
uint8_t m_ver
Definition: cryptonote_basic_impl.h:52
POD_CLASS hash
Definition: hash.h:49
crypto::hash8 payment_id
Definition: cryptonote_basic_impl.h:74
Definition: cryptonote_basic_impl.h:50
Definition: cryptonote_basic.h:204
cryptonote::block b
Definition: block.cpp:40