Debian Codegraph @

src/cryptonote_basic/cryptonote_basic_impl.h

raw symbols SCIP
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)
44 struct public_address_outer_blob
45 {
46 uint8_t m_ver;
47 account_public_address m_address;
48 uint8_t check_sum;
49 };
50 struct public_integrated_address_outer_blob
51 {
52 uint8_t m_ver;
53 account_public_address m_address;
54 crypto::hash8 payment_id;
55 uint8_t check_sum;
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
69 struct address_parse_info
70 {
71 account_public_address address;
72 bool is_subaddress;
73 bool has_payment_id;
74 crypto::hash8 payment_id;
75 };
76
77 /************************************************************************/
78 /* Cryptonote helper functions */
79 /************************************************************************/
80 size_t get_min_block_weight(uint8_t version);
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);
83 uint8_t get_account_address_checksum(const public_address_outer_blob& bl);
84 uint8_t get_account_integrated_address_checksum(const public_integrated_address_outer_blob& bl);
85
86 std::string get_account_address_as_str(
87 network_type nettype
88 , bool subaddress
89 , const account_public_address& adr
90 );
91
92 std::string get_account_integrated_address_as_str(
93 network_type nettype
94 , const account_public_address& adr
95 , const crypto::hash8& payment_id
96 );
97
98 bool get_account_address_from_str(
99 address_parse_info& info
100 , network_type nettype
101 , const std::string& str
102 );
103
104 bool get_account_address_from_str_or_url(
105 address_parse_info& info
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
113 bool operator ==(const cryptonote::transaction& a, const cryptonote::transaction& b);
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