Electroneum
Loading...
Searching...
No Matches
cryptonote_tx_utils.h
Go to the documentation of this file.
1// Copyrights(c) 2017-2021, The Electroneum Project
2// Copyrights(c) 2014-2019, The Monero Project
3//
4// All rights reserved.
5//
6// Redistribution and use in source and binary forms, with or without modification, are
7// permitted provided that the following conditions are met:
8//
9// 1. Redistributions of source code must retain the above copyright notice, this list of
10// conditions and the following disclaimer.
11//
12// 2. Redistributions in binary form must reproduce the above copyright notice, this list
13// of conditions and the following disclaimer in the documentation and/or other
14// materials provided with the distribution.
15//
16// 3. Neither the name of the copyright holder nor the names of its contributors may be
17// used to endorse or promote products derived from this software without specific
18// prior written permission.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29//
30// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
31
32#pragma once
34#include <boost/serialization/vector.hpp>
35#include <boost/serialization/utility.hpp>
36#include "ringct/rctOps.h"
37
38namespace cryptonote
39{
40 //---------------------------------------------------------------
41 bool construct_miner_tx(size_t height, size_t median_weight, uint64_t already_generated_coins, size_t current_block_weight, uint64_t fee, const account_public_address &miner_address, transaction& tx, const blobdata& extra_nonce = blobdata(), size_t max_outs = 999, uint8_t hard_fork_version = 1, network_type nettype = MAINNET);
42
44 {
45 typedef std::pair<uint64_t, rct::ctkey> output_entry;
46
47 // OLD BLOCKCHAIN
48 //Todo: Makes more sense to label these as inputs as that's what they are
49 std::vector<output_entry> outputs; //index + key + optional ringct commitment
50 size_t real_output; //index in outputs vector of real output_entry
51 crypto::public_key real_out_tx_key; //incoming real tx public key
52 std::vector<crypto::public_key> real_out_additional_tx_keys; //incoming real tx additional public keys
53 size_t real_output_in_tx_index; //relative output index (used for v1,2,3+)
55 bool rct; //true if the output is rct
56 rct::key mask; //ringct amount mask
58
59 // NEW ADDITION FOR TRANSPARENT BLOCKCHAIN
62
63 void push_output(uint64_t idx, const crypto::public_key &k, uint64_t amount) { outputs.push_back(std::make_pair(idx, rct::ctkey({rct::pk2rct(k), rct::zeroCommit(amount)}))); }
64
72 FIELD(rct)
73 FIELD(mask)
77
79 return false;
81 };
82
103
104 //---------------------------------------------------------------
105 crypto::public_key get_destination_view_key_pub(const std::vector<tx_destination_entry> &destinations, const boost::optional<cryptonote::account_public_address>& change_addr);
106 bool construct_tx(const account_keys& sender_account_keys, std::vector<tx_source_entry> &sources, const std::vector<tx_destination_entry>& destinations, const boost::optional<cryptonote::account_public_address>& change_addr, const std::vector<uint8_t> &extra, transaction& tx, uint64_t unlock_time);
107 bool construct_tx_with_tx_key(const account_keys& sender_account_keys, const std::unordered_map<crypto::public_key, subaddress_index>& subaddresses, std::vector<tx_source_entry>& sources, std::vector<tx_destination_entry>& destinations, const boost::optional<cryptonote::account_public_address>& change_addr, const std::vector<uint8_t> &extra, transaction& tx, uint64_t unlock_time, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, bool rct = false, const rct::RCTConfig &rct_config = { rct::RangeProofBorromean, 0 }, rct::multisig_out *msout = NULL, bool shuffle_outs = true, const uint32_t account_major_offset = 0, const cryptonote::network_type = MAINNET);
108 bool construct_tx_and_get_tx_key(const account_keys& sender_account_keys, const std::unordered_map<crypto::public_key, subaddress_index>& subaddresses, std::vector<tx_source_entry>& sources, std::vector<tx_destination_entry>& destinations, const boost::optional<cryptonote::account_public_address>& change_addr, const std::vector<uint8_t> &extra, transaction& tx, uint64_t unlock_time, crypto::secret_key &tx_key, std::vector<crypto::secret_key> &additional_tx_keys, bool rct = false, const rct::RCTConfig &rct_config = { rct::RangeProofBorromean, 0 }, rct::multisig_out *msout = NULL, uint32_t account_major_offset = 0, const cryptonote::network_type = MAINNET);
109 bool generate_output_ephemeral_keys(const size_t tx_version, const cryptonote::account_keys &sender_account_keys, const crypto::public_key &txkey_pub, const crypto::secret_key &tx_key,
110 const cryptonote::tx_destination_entry &dst_entr, const boost::optional<cryptonote::account_public_address> &change_addr, const size_t output_index,
111 const bool &need_additional_txkeys, const std::vector<crypto::secret_key> &additional_tx_keys,
112 std::vector<crypto::public_key> &additional_tx_public_keys,
113 std::vector<rct::key> &amount_keys,
114 crypto::public_key &out_eph_public_key) ;
115
116 bool generate_output_ephemeral_keys(const size_t tx_version, const cryptonote::account_keys &sender_account_keys, const crypto::public_key &txkey_pub, const crypto::secret_key &tx_key,
117 const cryptonote::tx_destination_entry &dst_entr, const boost::optional<cryptonote::account_public_address> &change_addr, const size_t output_index,
118 const bool &need_additional_txkeys, const std::vector<crypto::secret_key> &additional_tx_keys,
119 std::vector<crypto::public_key> &additional_tx_public_keys,
120 std::vector<rct::key> &amount_keys,
121 crypto::public_key &out_eph_public_key) ;
122
124 block& bl
125 , std::string const & genesis_tx
126 , uint32_t nonce
127 );
128}
129
131BOOST_CLASS_VERSION(cryptonote::tx_destination_entry, 2)
132
133namespace boost
134{
135 namespace serialization
136 {
137 template <class Archive>
138 inline void serialize(Archive &a, cryptonote::tx_source_entry &x, const boost::serialization::version_type ver)
139 {
140 a & x.outputs;
141 a & x.real_output;
142 a & x.real_out_tx_key;
144 a & x.amount;
145 a & x.rct;
146 a & x.mask;
147 if (ver < 1)
148 return;
149 a & x.multisig_kLRki;
151 if (ver < 2)
152 return;
153 a & x.tx_hash;
154 a & x.subaddr_index;
155 }
156
157 template <class Archive>
158 inline void serialize(Archive& a, cryptonote::tx_destination_entry& x, const boost::serialization::version_type ver)
159 {
160 a & x.amount;
161 a & x.addr;
162 if (ver < 1)
163 return;
164 a & x.is_subaddress;
165 if (ver < 2)
166 {
167 x.is_integrated = false;
168 return;
169 }
170 a & x.original;
171 a & x.is_integrated;
172 }
173 }
174}
uint64_t height
BOOST_CLASS_VERSION(nodetool::node_server< cryptonote::t_cryptonote_protocol_handler< tests::proxy_core > >, 1)
#define AUTO_VAL_INIT(v)
crypto namespace.
Definition crypto.cpp:58
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition crypto.h:82
POD_CLASS public_key
Definition crypto.h:79
POD_CLASS hash
Definition hash.h:50
Holds cryptonote related classes and helpers.
Definition ban.cpp:40
bool construct_tx_and_get_tx_key(const account_keys &sender_account_keys, const std::unordered_map< crypto::public_key, subaddress_index > &subaddresses, std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr, const std::vector< uint8_t > &extra, transaction &tx, uint64_t unlock_time, crypto::secret_key &tx_key, std::vector< crypto::secret_key > &additional_tx_keys, bool rct, const rct::RCTConfig &rct_config, rct::multisig_out *msout, const uint32_t account_major_offset, const cryptonote::network_type nettype)
crypto::public_key get_destination_view_key_pub(const std::vector< tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr)
bool construct_tx(const account_keys &sender_account_keys, std::vector< tx_source_entry > &sources, const std::vector< tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr, const std::vector< uint8_t > &extra, transaction &tx, uint64_t unlock_time)
bool construct_tx_with_tx_key(const account_keys &sender_account_keys, const std::unordered_map< crypto::public_key, subaddress_index > &subaddresses, std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr, const std::vector< uint8_t > &extra, transaction &tx, uint64_t unlock_time, const crypto::secret_key &tx_key, const std::vector< crypto::secret_key > &additional_tx_keys, bool rct, const rct::RCTConfig &rct_config, rct::multisig_out *msout, bool shuffle_outs, const uint32_t account_major_offset, const cryptonote::network_type nettype)
bool construct_miner_tx(size_t height, size_t median_weight, uint64_t already_generated_coins, size_t current_block_weight, uint64_t fee, const account_public_address &miner_address, transaction &tx, const blobdata &extra_nonce, size_t max_outs, uint8_t hard_fork_version, network_type nettype)
std::string blobdata
bool generate_genesis_block(block &bl, std::string const &genesis_tx, uint32_t nonce)
bool generate_output_ephemeral_keys(const size_t tx_version, const cryptonote::account_keys &sender_account_keys, const crypto::public_key &txkey_pub, const crypto::secret_key &tx_key, const cryptonote::tx_destination_entry &dst_entr, const boost::optional< cryptonote::account_public_address > &change_addr, const size_t output_index, const bool &need_additional_txkeys, const std::vector< crypto::secret_key > &additional_tx_keys, std::vector< crypto::public_key > &additional_tx_public_keys, std::vector< rct::key > &amount_keys, crypto::public_key &out_eph_public_key)
key zeroCommit(etn_amount amount)
Definition rctOps.cpp:322
@ RangeProofBorromean
Definition rctTypes.h:235
STL namespace.
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1124
void serialize(Archive &a, unsigned_tx_set &x, const boost::serialization::version_type ver)
#define BEGIN_SERIALIZE_OBJECT()
#define FIELD(f)
#define false
#define END_SERIALIZE()
#define VARINT_FIELD(f)
unsigned int uint32_t
Definition stdint.h:126
unsigned char uint8_t
Definition stdint.h:124
unsigned __int64 uint64_t
Definition stdint.h:136
bool is_subaddress
tx_destination_entry()
bool is_integrated
tx_destination_entry(uint64_t a, const account_public_address &ad, bool is_subaddress)
std::string original
uint64_t amount
tx_destination_entry(const std::string &o, uint64_t a, const account_public_address &ad, bool is_subaddress)
account_public_address addr
FIELD(tx_hash)
std::vector< crypto::public_key > real_out_additional_tx_keys
crypto::public_key real_out_tx_key
uint64_t amount
rct::multisig_kLRki multisig_kLRki
bool rct
size_t real_output
crypto::hash tx_hash
subaddress_index subaddr_index
std::vector< output_entry > outputs
rct::key mask
void push_output(uint64_t idx, const crypto::public_key &k, uint64_t amount)
std::pair< uint64_t, rct::ctkey > output_entry
if(real_output >=outputs.size()) return false
size_t real_output_in_tx_index