| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
#include "cryptonote_basic/cryptonote_format_utils.h" |
| 33 |
#include <boost/serialization/vector.hpp> |
| 34 |
#include <boost/serialization/utility.hpp> |
| 35 |
#include "ringct/rctOps.h" |
| 36 |
|
| 37 |
namespace cryptonote |
| 38 |
{ |
| 39 |
|
| 40 |
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); |
| 41 |
|
| 42 |
struct tx_source_entry |
| 43 |
{ |
| 44 |
typedef std::pair<uint64_t, rct::ctkey> output_entry; |
| 45 |
|
| 46 |
std::vector<output_entry> outputs; |
| 47 |
uint64_t real_output; |
| 48 |
crypto::public_key real_out_tx_key; |
| 49 |
std::vector<crypto::public_key> real_out_additional_tx_keys; |
| 50 |
uint64_t real_output_in_tx_index; |
| 51 |
uint64_t amount; |
| 52 |
bool rct; |
| 53 |
rct::key mask; |
| 54 |
rct::multisig_kLRki multisig_kLRki; |
| 55 |
|
| 56 |
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)}))); } |
| 57 |
|
| 58 |
BEGIN_SERIALIZE_OBJECT() |
| 59 |
FIELD(outputs) |
| 60 |
FIELD(real_output) |
| 61 |
FIELD(real_out_tx_key) |
| 62 |
FIELD(real_out_additional_tx_keys) |
| 63 |
FIELD(real_output_in_tx_index) |
| 64 |
FIELD(amount) |
| 65 |
FIELD(rct) |
| 66 |
FIELD(mask) |
| 67 |
FIELD(multisig_kLRki) |
| 68 |
|
| 69 |
if (real_output >= outputs.size()) |
| 70 |
return false; |
| 71 |
END_SERIALIZE() |
| 72 |
}; |
| 73 |
|
| 74 |
struct tx_destination_entry |
| 75 |
{ |
| 76 |
std::string original; |
| 77 |
uint64_t amount; |
| 78 |
account_public_address addr; |
| 79 |
bool is_subaddress; |
| 80 |
bool is_integrated; |
| 81 |
|
| 82 |
tx_destination_entry() : amount(0), addr(AUTO_VAL_INIT(addr)), is_subaddress(false), is_integrated(false) { } |
| 83 |
tx_destination_entry(uint64_t a, const account_public_address &ad, bool is_subaddress) : amount(a), addr(ad), is_subaddress(is_subaddress), is_integrated(false) { } |
| 84 |
tx_destination_entry(const std::string &o, uint64_t a, const account_public_address &ad, bool is_subaddress) : original(o), amount(a), addr(ad), is_subaddress(is_subaddress), is_integrated(false) { } |
| 85 |
|
| 86 |
std::string address(network_type nettype, const crypto::hash &payment_id) const |
| 87 |
{ |
| 88 |
if (!original.empty()) |
| 89 |
{ |
| 90 |
return original; |
| 91 |
} |
| 92 |
|
| 93 |
if (is_integrated) |
| 94 |
{ |
| 95 |
return get_account_integrated_address_as_str(nettype, addr, reinterpret_cast<const crypto::hash8 &>(payment_id)); |
| 96 |
} |
| 97 |
|
| 98 |
return get_account_address_as_str(nettype, is_subaddress, addr); |
| 99 |
} |
| 100 |
|
| 101 |
BEGIN_SERIALIZE_OBJECT() |
| 102 |
FIELD(original) |
| 103 |
VARINT_FIELD(amount) |
| 104 |
FIELD(addr) |
| 105 |
FIELD(is_subaddress) |
| 106 |
FIELD(is_integrated) |
| 107 |
END_SERIALIZE() |
| 108 |
}; |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
struct tx_block_template_backlog_entry |
| 113 |
{ |
| 114 |
crypto::hash id; |
| 115 |
uint64_t weight; |
| 116 |
uint64_t fee; |
| 117 |
}; |
| 118 |
|
| 119 |
|
| 120 |
crypto::public_key get_destination_view_key_pub(const std::vector<tx_destination_entry> &destinations, const boost::optional<cryptonote::account_public_address>& change_addr); |
| 121 |
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); |
| 122 |
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, 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 }, bool shuffle_outs = true, bool use_view_tags = false); |
| 123 |
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, crypto::secret_key &tx_key, std::vector<crypto::secret_key> &additional_tx_keys, bool rct = false, const rct::RCTConfig &rct_config = { rct::RangeProofBorromean, 0 }, bool use_view_tags = false); |
| 124 |
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, |
| 125 |
const cryptonote::tx_destination_entry &dst_entr, const boost::optional<cryptonote::account_public_address> &change_addr, const size_t output_index, |
| 126 |
const bool &need_additional_txkeys, const std::vector<crypto::secret_key> &additional_tx_keys, |
| 127 |
std::vector<crypto::public_key> &additional_tx_public_keys, |
| 128 |
std::vector<rct::key> &amount_keys, |
| 129 |
crypto::public_key &out_eph_public_key, |
| 130 |
const bool use_view_tags, crypto::view_tag &view_tag) ; |
| 131 |
|
| 132 |
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, |
| 133 |
const cryptonote::tx_destination_entry &dst_entr, const boost::optional<cryptonote::account_public_address> &change_addr, const size_t output_index, |
| 134 |
const bool &need_additional_txkeys, const std::vector<crypto::secret_key> &additional_tx_keys, |
| 135 |
std::vector<crypto::public_key> &additional_tx_public_keys, |
| 136 |
std::vector<rct::key> &amount_keys, |
| 137 |
crypto::public_key &out_eph_public_key, |
| 138 |
const bool use_view_tags, crypto::view_tag &view_tag) ; |
| 139 |
|
| 140 |
bool generate_genesis_block( |
| 141 |
block& bl |
| 142 |
, std::string const & genesis_tx |
| 143 |
, uint32_t nonce |
| 144 |
); |
| 145 |
|
| 146 |
class Blockchain; |
| 147 |
bool get_block_longhash(const Blockchain *pb, const blobdata& bd, crypto::hash& res, const uint64_t height, const int major_version, const crypto::hash *seed_hash, const int miners = 0); |
| 148 |
bool get_block_longhash(const Blockchain *pb, const block& b, crypto::hash& res, const uint64_t height, const crypto::hash *seed_hash = nullptr, const int miners = 0); |
| 149 |
crypto::hash get_block_longhash(const Blockchain *pb, const block& b, const uint64_t height, const crypto::hash *seed_hash = nullptr, const int miners = 0); |
| 150 |
void get_altblock_longhash(const block& b, crypto::hash& res, const crypto::hash& seed_hash); |
| 151 |
|
| 152 |
} |
| 153 |
|
| 154 |
BOOST_CLASS_VERSION(cryptonote::tx_source_entry, 1) |
| 155 |
BOOST_CLASS_VERSION(cryptonote::tx_destination_entry, 2) |
| 156 |
|
| 157 |
namespace boost |
| 158 |
{ |
| 159 |
namespace serialization |
| 160 |
{ |
| 161 |
template <class Archive> |
| 162 |
inline void serialize(Archive &a, cryptonote::tx_source_entry &x, const boost::serialization::version_type ver) |
| 163 |
{ |
| 164 |
a & x.outputs; |
| 165 |
a & x.real_output; |
| 166 |
a & x.real_out_tx_key; |
| 167 |
a & x.real_output_in_tx_index; |
| 168 |
a & x.amount; |
| 169 |
a & x.rct; |
| 170 |
a & x.mask; |
| 171 |
if (ver < 1) |
| 172 |
return; |
| 173 |
a & x.multisig_kLRki; |
| 174 |
a & x.real_out_additional_tx_keys; |
| 175 |
} |
| 176 |
|
| 177 |
template <class Archive> |
| 178 |
inline void serialize(Archive& a, cryptonote::tx_destination_entry& x, const boost::serialization::version_type ver) |
| 179 |
{ |
| 180 |
a & x.amount; |
| 181 |
a & x.addr; |
| 182 |
if (ver < 1) |
| 183 |
return; |
| 184 |
a & x.is_subaddress; |
| 185 |
if (ver < 2) |
| 186 |
{ |
| 187 |
x.is_integrated = false; |
| 188 |
return; |
| 189 |
} |
| 190 |
a & x.original; |
| 191 |
a & x.is_integrated; |
| 192 |
} |
| 193 |
} |
| 194 |
} |