| 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 |
|
| 33 |
#include <memory> |
| 34 |
|
| 35 |
#include <boost/program_options/options_description.hpp> |
| 36 |
#include <boost/program_options/variables_map.hpp> |
| 37 |
#if BOOST_VERSION >= 107400 |
| 38 |
#include <boost/serialization/library_version_type.hpp> |
| 39 |
#endif |
| 40 |
#include <boost/serialization/list.hpp> |
| 41 |
#include <boost/serialization/vector.hpp> |
| 42 |
#include <boost/serialization/deque.hpp> |
| 43 |
#include <boost/thread/lock_guard.hpp> |
| 44 |
#include <atomic> |
| 45 |
#include <random> |
| 46 |
|
| 47 |
#include "include_base_utils.h" |
| 48 |
#include "cryptonote_basic/account.h" |
| 49 |
#include "cryptonote_basic/account_boost_serialization.h" |
| 50 |
#include "cryptonote_basic/cryptonote_basic_impl.h" |
| 51 |
#include "net/http.h" |
| 52 |
#include "storages/http_abstract_invoke.h" |
| 53 |
#include "rpc/core_rpc_server_commands_defs.h" |
| 54 |
#include "cryptonote_basic/cryptonote_format_utils.h" |
| 55 |
#include "cryptonote_core/cryptonote_tx_utils.h" |
| 56 |
#include "common/unordered_containers_boost_serialization.h" |
| 57 |
#include "common/util.h" |
| 58 |
#include "crypto/chacha.h" |
| 59 |
#include "crypto/hash.h" |
| 60 |
#include "ringct/rctTypes.h" |
| 61 |
#include "ringct/rctOps.h" |
| 62 |
#include "checkpoints/checkpoints.h" |
| 63 |
#include "serialization/crypto.h" |
| 64 |
#include "serialization/string.h" |
| 65 |
#include "serialization/pair.h" |
| 66 |
#include "serialization/tuple.h" |
| 67 |
#include "serialization/containers.h" |
| 68 |
|
| 69 |
#include "wallet_errors.h" |
| 70 |
#include "common/password.h" |
| 71 |
#include "node_rpc_proxy.h" |
| 72 |
#include "message_store.h" |
| 73 |
#include "wallet_light_rpc.h" |
| 74 |
#include "wallet_rpc_helpers.h" |
| 75 |
|
| 76 |
#undef MONERO_DEFAULT_LOG_CATEGORY |
| 77 |
#define MONERO_DEFAULT_LOG_CATEGORY "wallet.wallet2" |
| 78 |
|
| 79 |
#define THROW_ON_RPC_RESPONSE_ERROR(r, error, res, method, ...) \ |
| 80 |
do { \ |
| 81 |
handle_payment_changes(res, std::integral_constant<bool, HasCredits<decltype(res)>::Has>()); \ |
| 82 |
throw_on_rpc_response_error(r, error, res.status, method); \ |
| 83 |
THROW_WALLET_EXCEPTION_IF(res.status != CORE_RPC_STATUS_OK, ## __VA_ARGS__); \ |
| 84 |
} while(0) |
| 85 |
|
| 86 |
#define THROW_ON_RPC_RESPONSE_ERROR_GENERIC(r, err, res, method) \ |
| 87 |
THROW_ON_RPC_RESPONSE_ERROR(r, err, res, method, tools::error::wallet_generic_rpc_error, method, res.status) |
| 88 |
|
| 89 |
class Serialization_portability_wallet_Test; |
| 90 |
class wallet_accessor_test; |
| 91 |
|
| 92 |
namespace tools |
| 93 |
{ |
| 94 |
class ringdb; |
| 95 |
class wallet2; |
| 96 |
class Notify; |
| 97 |
|
| 98 |
class gamma_picker |
| 99 |
{ |
| 100 |
public: |
| 101 |
uint64_t pick(); |
| 102 |
gamma_picker(const std::vector<uint64_t> &rct_offsets); |
| 103 |
gamma_picker(const std::vector<uint64_t> &rct_offsets, double shape, double scale); |
| 104 |
uint64_t get_num_rct_outs() const { return num_rct_outputs; } |
| 105 |
|
| 106 |
private: |
| 107 |
struct gamma_engine |
| 108 |
{ |
| 109 |
typedef uint64_t result_type; |
| 110 |
static constexpr result_type min() { return 0; } |
| 111 |
static constexpr result_type max() { return std::numeric_limits<result_type>::max(); } |
| 112 |
result_type operator()() { return crypto::rand<result_type>(); } |
| 113 |
} engine; |
| 114 |
|
| 115 |
private: |
| 116 |
std::gamma_distribution<double> gamma; |
| 117 |
const std::vector<uint64_t> &rct_offsets; |
| 118 |
const uint64_t *begin, *end; |
| 119 |
uint64_t num_rct_outputs; |
| 120 |
double average_output_time; |
| 121 |
}; |
| 122 |
|
| 123 |
class wallet_keys_unlocker |
| 124 |
{ |
| 125 |
public: |
| 126 |
wallet_keys_unlocker(wallet2 &w, const boost::optional<tools::password_container> &password); |
| 127 |
wallet_keys_unlocker(wallet2 &w, bool locked, const epee::wipeable_string &password); |
| 128 |
~wallet_keys_unlocker(); |
| 129 |
private: |
| 130 |
wallet2 &w; |
| 131 |
bool locked; |
| 132 |
crypto::chacha_key key; |
| 133 |
static boost::mutex lockers_lock; |
| 134 |
static unsigned int lockers; |
| 135 |
}; |
| 136 |
|
| 137 |
class i_wallet2_callback |
| 138 |
{ |
| 139 |
public: |
| 140 |
|
| 141 |
virtual void on_new_block(uint64_t height, const cryptonote::block& block) {} |
| 142 |
virtual void on_reorg(uint64_t height, uint64_t blocks_detached, size_t transfers_detached) {} |
| 143 |
virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, uint64_t burnt, const cryptonote::subaddress_index& subaddr_index, bool is_change, uint64_t unlock_time) {} |
| 144 |
virtual void on_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, const cryptonote::subaddress_index& subaddr_index) {} |
| 145 |
virtual void on_money_spent(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& in_tx, uint64_t amount, const cryptonote::transaction& spend_tx, const cryptonote::subaddress_index& subaddr_index) {} |
| 146 |
virtual void on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx) {} |
| 147 |
virtual boost::optional<epee::wipeable_string> on_get_password(const char *reason) { return boost::none; } |
| 148 |
|
| 149 |
virtual void on_lw_new_block(uint64_t height) {} |
| 150 |
virtual void on_lw_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount) {} |
| 151 |
virtual void on_lw_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount) {} |
| 152 |
virtual void on_lw_money_spent(uint64_t height, const crypto::hash &txid, uint64_t amount) {} |
| 153 |
|
| 154 |
virtual void on_device_button_request(uint64_t code) {} |
| 155 |
virtual void on_device_button_pressed() {} |
| 156 |
virtual boost::optional<epee::wipeable_string> on_device_pin_request() { return boost::none; } |
| 157 |
virtual boost::optional<epee::wipeable_string> on_device_passphrase_request(bool & on_device) { on_device = true; return boost::none; } |
| 158 |
virtual void on_device_progress(const hw::device_progress& event) {}; |
| 159 |
|
| 160 |
virtual void on_pool_tx_removed(const crypto::hash &txid) {} |
| 161 |
virtual ~i_wallet2_callback() {} |
| 162 |
}; |
| 163 |
|
| 164 |
class wallet_device_callback : public hw::i_device_callback |
| 165 |
{ |
| 166 |
public: |
| 167 |
wallet_device_callback(wallet2 * wallet): wallet(wallet) {}; |
| 168 |
void on_button_request(uint64_t code=0) override; |
| 169 |
void on_button_pressed() override; |
| 170 |
boost::optional<epee::wipeable_string> on_pin_request() override; |
| 171 |
boost::optional<epee::wipeable_string> on_passphrase_request(bool & on_device) override; |
| 172 |
void on_progress(const hw::device_progress& event) override; |
| 173 |
private: |
| 174 |
wallet2 * wallet; |
| 175 |
}; |
| 176 |
|
| 177 |
struct tx_dust_policy |
| 178 |
{ |
| 179 |
uint64_t dust_threshold; |
| 180 |
bool add_to_fee; |
| 181 |
cryptonote::account_public_address addr_for_dust; |
| 182 |
|
| 183 |
tx_dust_policy(uint64_t a_dust_threshold = 0, bool an_add_to_fee = true, cryptonote::account_public_address an_addr_for_dust = cryptonote::account_public_address()) |
| 184 |
: dust_threshold(a_dust_threshold) |
| 185 |
, add_to_fee(an_add_to_fee) |
| 186 |
, addr_for_dust(an_addr_for_dust) |
| 187 |
{ |
| 188 |
} |
| 189 |
}; |
| 190 |
|
| 191 |
class hashchain |
| 192 |
{ |
| 193 |
public: |
| 194 |
hashchain(): m_genesis(crypto::null_hash), m_offset(0) {} |
| 195 |
|
| 196 |
size_t size() const { return m_blockchain.size() + m_offset; } |
| 197 |
size_t offset() const { return m_offset; } |
| 198 |
const crypto::hash &genesis() const { return m_genesis; } |
| 199 |
void push_back(const crypto::hash &hash) { if (m_offset == 0 && m_blockchain.empty()) m_genesis = hash; m_blockchain.push_back(hash); } |
| 200 |
bool is_in_bounds(size_t idx) const { return idx >= m_offset && idx < size(); } |
| 201 |
const crypto::hash &operator[](size_t idx) const { return m_blockchain[idx - m_offset]; } |
| 202 |
crypto::hash &operator[](size_t idx) { return m_blockchain[idx - m_offset]; } |
| 203 |
void crop(size_t height) { m_blockchain.resize(height - m_offset); } |
| 204 |
void clear() { m_offset = 0; m_blockchain.clear(); } |
| 205 |
bool empty() const { return m_blockchain.empty() && m_offset == 0; } |
| 206 |
void trim(size_t height) { while (height > m_offset && m_blockchain.size() > 1) { m_blockchain.pop_front(); ++m_offset; } m_blockchain.shrink_to_fit(); } |
| 207 |
void refill(const crypto::hash &hash) { m_blockchain.push_back(hash); --m_offset; } |
| 208 |
|
| 209 |
template <class t_archive> |
| 210 |
inline void serialize(t_archive &a, const unsigned int ver) |
| 211 |
{ |
| 212 |
a & m_offset; |
| 213 |
a & m_genesis; |
| 214 |
a & m_blockchain; |
| 215 |
} |
| 216 |
|
| 217 |
BEGIN_SERIALIZE_OBJECT() |
| 218 |
VERSION_FIELD(0) |
| 219 |
VARINT_FIELD(m_offset) |
| 220 |
FIELD(m_genesis) |
| 221 |
FIELD(m_blockchain) |
| 222 |
END_SERIALIZE() |
| 223 |
|
| 224 |
private: |
| 225 |
size_t m_offset; |
| 226 |
crypto::hash m_genesis; |
| 227 |
std::deque<crypto::hash> m_blockchain; |
| 228 |
}; |
| 229 |
|
| 230 |
class wallet_keys_unlocker; |
| 231 |
class wallet2 |
| 232 |
{ |
| 233 |
friend class ::Serialization_portability_wallet_Test; |
| 234 |
friend class ::wallet_accessor_test; |
| 235 |
friend class wallet_keys_unlocker; |
| 236 |
friend class wallet_device_callback; |
| 237 |
public: |
| 238 |
static constexpr const std::chrono::seconds rpc_timeout = std::chrono::minutes(3) + std::chrono::seconds(30); |
| 239 |
|
| 240 |
enum RefreshType { |
| 241 |
RefreshFull, |
| 242 |
RefreshOptimizeCoinbase, |
| 243 |
RefreshNoCoinbase, |
| 244 |
RefreshDefault = RefreshOptimizeCoinbase, |
| 245 |
}; |
| 246 |
|
| 247 |
enum AskPasswordType { |
| 248 |
AskPasswordNever = 0, |
| 249 |
AskPasswordOnAction = 1, |
| 250 |
AskPasswordToDecrypt = 2, |
| 251 |
}; |
| 252 |
|
| 253 |
enum BackgroundMiningSetupType { |
| 254 |
BackgroundMiningMaybe = 0, |
| 255 |
BackgroundMiningYes = 1, |
| 256 |
BackgroundMiningNo = 2, |
| 257 |
}; |
| 258 |
|
| 259 |
enum BackgroundSyncType { |
| 260 |
BackgroundSyncOff = 0, |
| 261 |
BackgroundSyncReusePassword = 1, |
| 262 |
BackgroundSyncCustomPassword = 2, |
| 263 |
}; |
| 264 |
|
| 265 |
static BackgroundSyncType background_sync_type_from_str(const std::string &background_sync_type_str) |
| 266 |
{ |
| 267 |
if (background_sync_type_str == "off") return BackgroundSyncOff; |
| 268 |
if (background_sync_type_str == "reuse-wallet-password") return BackgroundSyncReusePassword; |
| 269 |
if (background_sync_type_str == "custom-background-password") return BackgroundSyncCustomPassword; |
| 270 |
throw std::logic_error("Unknown background sync type"); |
| 271 |
}; |
| 272 |
|
| 273 |
enum ExportFormat { |
| 274 |
Binary = 0, |
| 275 |
Ascii, |
| 276 |
}; |
| 277 |
|
| 278 |
static const char* tr(const char* str); |
| 279 |
|
| 280 |
static bool has_testnet_option(const boost::program_options::variables_map& vm); |
| 281 |
static bool has_stagenet_option(const boost::program_options::variables_map& vm); |
| 282 |
static std::string device_name_option(const boost::program_options::variables_map& vm); |
| 283 |
static std::string device_derivation_path_option(const boost::program_options::variables_map &vm); |
| 284 |
static void init_options(boost::program_options::options_description& desc_params); |
| 285 |
|
| 286 |
|
| 287 |
static std::pair<std::unique_ptr<wallet2>, password_container> make_from_json(const boost::program_options::variables_map& vm, bool unattended, const std::string& json_file, const std::function<boost::optional<password_container>(const char *, bool)> &password_prompter); |
| 288 |
|
| 289 |
|
| 290 |
static std::pair<std::unique_ptr<wallet2>, password_container> |
| 291 |
make_from_file(const boost::program_options::variables_map& vm, bool unattended, const std::string& wallet_file, const std::function<boost::optional<password_container>(const char *, bool)> &password_prompter); |
| 292 |
|
| 293 |
|
| 294 |
static std::pair<std::unique_ptr<wallet2>, password_container> make_new(const boost::program_options::variables_map& vm, bool unattended, const std::function<boost::optional<password_container>(const char *, bool)> &password_prompter); |
| 295 |
|
| 296 |
|
| 297 |
static std::unique_ptr<wallet2> make_dummy(const boost::program_options::variables_map& vm, bool unattended, const std::function<boost::optional<password_container>(const char *, bool)> &password_prompter); |
| 298 |
|
| 299 |
static bool verify_password(const std::string& keys_file_name, const epee::wipeable_string& password, bool no_spend_key, hw::device &hwdev, uint64_t kdf_rounds) |
| 300 |
{ |
| 301 |
crypto::secret_key spend_key = crypto::null_skey; |
| 302 |
return verify_password(keys_file_name, password, no_spend_key, hwdev, kdf_rounds, spend_key); |
| 303 |
}; |
| 304 |
static bool verify_password(const std::string& keys_file_name, const epee::wipeable_string& password, bool no_spend_key, hw::device &hwdev, uint64_t kdf_rounds, crypto::secret_key &spend_key_out); |
| 305 |
static bool query_device(hw::device::device_type& device_type, const std::string& keys_file_name, const epee::wipeable_string& password, uint64_t kdf_rounds = 1); |
| 306 |
|
| 307 |
wallet2(cryptonote::network_type nettype = cryptonote::MAINNET, uint64_t kdf_rounds = 1, bool unattended = false, std::unique_ptr<epee::net_utils::http::http_client_factory> http_client_factory = std::unique_ptr<epee::net_utils::http::http_client_factory>(new net::http::client_factory())); |
| 308 |
~wallet2(); |
| 309 |
|
| 310 |
struct multisig_info |
| 311 |
{ |
| 312 |
struct LR |
| 313 |
{ |
| 314 |
rct::key m_L; |
| 315 |
rct::key m_R; |
| 316 |
|
| 317 |
BEGIN_SERIALIZE_OBJECT() |
| 318 |
FIELD(m_L) |
| 319 |
FIELD(m_R) |
| 320 |
END_SERIALIZE() |
| 321 |
}; |
| 322 |
|
| 323 |
crypto::public_key m_signer; |
| 324 |
std::vector<LR> m_LR; |
| 325 |
std::vector<crypto::key_image> m_partial_key_images; |
| 326 |
|
| 327 |
BEGIN_SERIALIZE_OBJECT() |
| 328 |
FIELD(m_signer) |
| 329 |
FIELD(m_LR) |
| 330 |
FIELD(m_partial_key_images) |
| 331 |
END_SERIALIZE() |
| 332 |
}; |
| 333 |
|
| 334 |
struct tx_scan_info_t |
| 335 |
{ |
| 336 |
cryptonote::keypair in_ephemeral; |
| 337 |
crypto::key_image ki; |
| 338 |
rct::key mask; |
| 339 |
uint64_t amount; |
| 340 |
uint64_t money_transfered; |
| 341 |
bool error; |
| 342 |
boost::optional<cryptonote::subaddress_receive_info> received; |
| 343 |
|
| 344 |
tx_scan_info_t(): amount(0), money_transfered(0), error(true) {} |
| 345 |
}; |
| 346 |
|
| 347 |
struct transfer_details |
| 348 |
{ |
| 349 |
uint64_t m_block_height; |
| 350 |
cryptonote::transaction_prefix m_tx; |
| 351 |
crypto::hash m_txid; |
| 352 |
uint64_t m_internal_output_index; |
| 353 |
uint64_t m_global_output_index; |
| 354 |
bool m_spent; |
| 355 |
bool m_frozen; |
| 356 |
uint64_t m_spent_height; |
| 357 |
crypto::key_image m_key_image; |
| 358 |
rct::key m_mask; |
| 359 |
uint64_t m_amount; |
| 360 |
bool m_rct; |
| 361 |
bool m_key_image_known; |
| 362 |
bool m_key_image_request; |
| 363 |
uint64_t m_pk_index; |
| 364 |
cryptonote::subaddress_index m_subaddr_index; |
| 365 |
bool m_key_image_partial; |
| 366 |
std::vector<rct::key> m_multisig_k; |
| 367 |
std::vector<multisig_info> m_multisig_info; |
| 368 |
std::vector<std::pair<uint64_t, crypto::hash>> m_uses; |
| 369 |
|
| 370 |
bool is_rct() const { return m_rct; } |
| 371 |
uint64_t amount() const { return m_amount; } |
| 372 |
const crypto::public_key get_public_key() const { |
| 373 |
crypto::public_key output_public_key; |
| 374 |
THROW_WALLET_EXCEPTION_IF(m_tx.vout.size() <= m_internal_output_index, |
| 375 |
error::wallet_internal_error, "Too few outputs, outputs may be corrupted"); |
| 376 |
THROW_WALLET_EXCEPTION_IF(!get_output_public_key(m_tx.vout[m_internal_output_index], output_public_key), |
| 377 |
error::wallet_internal_error, "Unable to get output public key from output"); |
| 378 |
return output_public_key; |
| 379 |
}; |
| 380 |
|
| 381 |
BEGIN_SERIALIZE_OBJECT() |
| 382 |
FIELD(m_block_height) |
| 383 |
FIELD(m_tx) |
| 384 |
FIELD(m_txid) |
| 385 |
FIELD(m_internal_output_index) |
| 386 |
FIELD(m_global_output_index) |
| 387 |
FIELD(m_spent) |
| 388 |
FIELD(m_frozen) |
| 389 |
FIELD(m_spent_height) |
| 390 |
FIELD(m_key_image) |
| 391 |
FIELD(m_mask) |
| 392 |
FIELD(m_amount) |
| 393 |
FIELD(m_rct) |
| 394 |
FIELD(m_key_image_known) |
| 395 |
FIELD(m_key_image_request) |
| 396 |
FIELD(m_pk_index) |
| 397 |
FIELD(m_subaddr_index) |
| 398 |
FIELD(m_key_image_partial) |
| 399 |
FIELD(m_multisig_k) |
| 400 |
FIELD(m_multisig_info) |
| 401 |
FIELD(m_uses) |
| 402 |
END_SERIALIZE() |
| 403 |
}; |
| 404 |
|
| 405 |
struct exported_transfer_details |
| 406 |
{ |
| 407 |
crypto::public_key m_pubkey; |
| 408 |
uint64_t m_internal_output_index; |
| 409 |
uint64_t m_global_output_index; |
| 410 |
crypto::public_key m_tx_pubkey; |
| 411 |
union |
| 412 |
{ |
| 413 |
struct |
| 414 |
{ |
| 415 |
uint8_t m_spent: 1; |
| 416 |
uint8_t m_frozen: 1; |
| 417 |
uint8_t m_rct: 1; |
| 418 |
uint8_t m_key_image_known: 1; |
| 419 |
uint8_t m_key_image_request: 1; |
| 420 |
uint8_t m_key_image_partial: 1; |
| 421 |
}; |
| 422 |
uint8_t flags; |
| 423 |
} m_flags; |
| 424 |
uint64_t m_amount; |
| 425 |
std::vector<crypto::public_key> m_additional_tx_keys; |
| 426 |
uint32_t m_subaddr_index_major; |
| 427 |
uint32_t m_subaddr_index_minor; |
| 428 |
|
| 429 |
BEGIN_SERIALIZE_OBJECT() |
| 430 |
VERSION_FIELD(1) |
| 431 |
if (version < 1) |
| 432 |
return false; |
| 433 |
FIELD(m_pubkey) |
| 434 |
VARINT_FIELD(m_internal_output_index) |
| 435 |
VARINT_FIELD(m_global_output_index) |
| 436 |
FIELD(m_tx_pubkey) |
| 437 |
FIELD(m_flags.flags) |
| 438 |
VARINT_FIELD(m_amount) |
| 439 |
FIELD(m_additional_tx_keys) |
| 440 |
VARINT_FIELD(m_subaddr_index_major) |
| 441 |
VARINT_FIELD(m_subaddr_index_minor) |
| 442 |
END_SERIALIZE() |
| 443 |
}; |
| 444 |
|
| 445 |
typedef std::vector<uint64_t> amounts_container; |
| 446 |
struct payment_details |
| 447 |
{ |
| 448 |
crypto::hash m_tx_hash; |
| 449 |
uint64_t m_amount; |
| 450 |
amounts_container m_amounts; |
| 451 |
uint64_t m_fee; |
| 452 |
uint64_t m_block_height; |
| 453 |
uint64_t m_unlock_time; |
| 454 |
uint64_t m_timestamp; |
| 455 |
bool m_coinbase; |
| 456 |
cryptonote::subaddress_index m_subaddr_index; |
| 457 |
|
| 458 |
BEGIN_SERIALIZE_OBJECT() |
| 459 |
VERSION_FIELD(0) |
| 460 |
FIELD(m_tx_hash) |
| 461 |
VARINT_FIELD(m_amount) |
| 462 |
FIELD(m_amounts) |
| 463 |
VARINT_FIELD(m_fee) |
| 464 |
VARINT_FIELD(m_block_height) |
| 465 |
VARINT_FIELD(m_unlock_time) |
| 466 |
VARINT_FIELD(m_timestamp) |
| 467 |
FIELD(m_coinbase) |
| 468 |
FIELD(m_subaddr_index) |
| 469 |
END_SERIALIZE() |
| 470 |
}; |
| 471 |
|
| 472 |
struct address_tx : payment_details |
| 473 |
{ |
| 474 |
bool m_mempool; |
| 475 |
bool m_incoming; |
| 476 |
}; |
| 477 |
|
| 478 |
struct pool_payment_details |
| 479 |
{ |
| 480 |
payment_details m_pd; |
| 481 |
bool m_double_spend_seen; |
| 482 |
|
| 483 |
BEGIN_SERIALIZE_OBJECT() |
| 484 |
VERSION_FIELD(0) |
| 485 |
FIELD(m_pd) |
| 486 |
FIELD(m_double_spend_seen) |
| 487 |
END_SERIALIZE() |
| 488 |
}; |
| 489 |
|
| 490 |
struct unconfirmed_transfer_details |
| 491 |
{ |
| 492 |
cryptonote::transaction_prefix m_tx; |
| 493 |
uint64_t m_amount_in; |
| 494 |
uint64_t m_amount_out; |
| 495 |
uint64_t m_change; |
| 496 |
time_t m_sent_time; |
| 497 |
std::vector<cryptonote::tx_destination_entry> m_dests; |
| 498 |
crypto::hash m_payment_id; |
| 499 |
enum { pending, pending_in_pool, failed } m_state; |
| 500 |
uint64_t m_timestamp; |
| 501 |
uint32_t m_subaddr_account; |
| 502 |
std::set<uint32_t> m_subaddr_indices; |
| 503 |
std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> m_rings; |
| 504 |
|
| 505 |
BEGIN_SERIALIZE_OBJECT() |
| 506 |
VERSION_FIELD(1) |
| 507 |
FIELD(m_tx) |
| 508 |
VARINT_FIELD(m_amount_in) |
| 509 |
VARINT_FIELD(m_amount_out) |
| 510 |
VARINT_FIELD(m_change) |
| 511 |
VARINT_FIELD(m_sent_time) |
| 512 |
FIELD(m_dests) |
| 513 |
FIELD(m_payment_id) |
| 514 |
if (version >= 1) |
| 515 |
VARINT_FIELD(m_state) |
| 516 |
VARINT_FIELD(m_timestamp) |
| 517 |
VARINT_FIELD(m_subaddr_account) |
| 518 |
FIELD(m_subaddr_indices) |
| 519 |
FIELD(m_rings) |
| 520 |
END_SERIALIZE() |
| 521 |
}; |
| 522 |
|
| 523 |
struct confirmed_transfer_details |
| 524 |
{ |
| 525 |
cryptonote::transaction_prefix m_tx; |
| 526 |
uint64_t m_amount_in; |
| 527 |
uint64_t m_amount_out; |
| 528 |
uint64_t m_change; |
| 529 |
uint64_t m_block_height; |
| 530 |
std::vector<cryptonote::tx_destination_entry> m_dests; |
| 531 |
crypto::hash m_payment_id; |
| 532 |
uint64_t m_timestamp; |
| 533 |
uint64_t m_unlock_time; |
| 534 |
uint32_t m_subaddr_account; |
| 535 |
std::set<uint32_t> m_subaddr_indices; |
| 536 |
std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> m_rings; |
| 537 |
|
| 538 |
confirmed_transfer_details(): m_amount_in(0), m_amount_out(0), m_change((uint64_t)-1), m_block_height(0), m_payment_id(crypto::null_hash), m_timestamp(0), m_unlock_time(0), m_subaddr_account((uint32_t)-1) {} |
| 539 |
confirmed_transfer_details(const unconfirmed_transfer_details &utd, uint64_t height): |
| 540 |
m_tx(utd.m_tx), m_amount_in(utd.m_amount_in), m_amount_out(utd.m_amount_out), m_change(utd.m_change), m_block_height(height), m_dests(utd.m_dests), m_payment_id(utd.m_payment_id), m_timestamp(utd.m_timestamp), m_unlock_time(utd.m_tx.unlock_time), m_subaddr_account(utd.m_subaddr_account), m_subaddr_indices(utd.m_subaddr_indices), m_rings(utd.m_rings) {} |
| 541 |
|
| 542 |
BEGIN_SERIALIZE_OBJECT() |
| 543 |
VERSION_FIELD(1) |
| 544 |
if (version >= 1) |
| 545 |
FIELD(m_tx) |
| 546 |
VARINT_FIELD(m_amount_in) |
| 547 |
VARINT_FIELD(m_amount_out) |
| 548 |
VARINT_FIELD(m_change) |
| 549 |
VARINT_FIELD(m_block_height) |
| 550 |
FIELD(m_dests) |
| 551 |
FIELD(m_payment_id) |
| 552 |
VARINT_FIELD(m_timestamp) |
| 553 |
VARINT_FIELD(m_unlock_time) |
| 554 |
VARINT_FIELD(m_subaddr_account) |
| 555 |
FIELD(m_subaddr_indices) |
| 556 |
FIELD(m_rings) |
| 557 |
END_SERIALIZE() |
| 558 |
}; |
| 559 |
|
| 560 |
struct tx_construction_data |
| 561 |
{ |
| 562 |
std::vector<cryptonote::tx_source_entry> sources; |
| 563 |
cryptonote::tx_destination_entry change_dts; |
| 564 |
std::vector<cryptonote::tx_destination_entry> splitted_dsts; |
| 565 |
std::vector<size_t> selected_transfers; |
| 566 |
std::vector<uint8_t> extra; |
| 567 |
uint64_t unlock_time; |
| 568 |
bool use_rct; |
| 569 |
rct::RCTConfig rct_config; |
| 570 |
bool use_view_tags; |
| 571 |
std::vector<cryptonote::tx_destination_entry> dests; |
| 572 |
uint32_t subaddr_account; |
| 573 |
std::set<uint32_t> subaddr_indices; |
| 574 |
|
| 575 |
enum construction_flags_ : uint8_t |
| 576 |
{ |
| 577 |
_use_rct = 1 << 0, |
| 578 |
_use_view_tags = 1 << 1 |
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
}; |
| 583 |
uint8_t construction_flags; |
| 584 |
|
| 585 |
BEGIN_SERIALIZE_OBJECT() |
| 586 |
FIELD(sources) |
| 587 |
FIELD(change_dts) |
| 588 |
FIELD(splitted_dsts) |
| 589 |
FIELD(selected_transfers) |
| 590 |
FIELD(extra) |
| 591 |
FIELD(unlock_time) |
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
if (!typename Archive<W>::is_saving()) |
| 596 |
{ |
| 597 |
FIELD_N("use_rct", construction_flags) |
| 598 |
use_rct = (construction_flags & _use_rct) > 0; |
| 599 |
use_view_tags = (construction_flags & _use_view_tags) > 0; |
| 600 |
} |
| 601 |
else |
| 602 |
{ |
| 603 |
construction_flags = 0; |
| 604 |
if (use_rct) |
| 605 |
construction_flags ^= _use_rct; |
| 606 |
if (use_view_tags) |
| 607 |
construction_flags ^= _use_view_tags; |
| 608 |
|
| 609 |
FIELD_N("use_rct", construction_flags) |
| 610 |
} |
| 611 |
|
| 612 |
FIELD(rct_config) |
| 613 |
FIELD(dests) |
| 614 |
FIELD(subaddr_account) |
| 615 |
FIELD(subaddr_indices) |
| 616 |
END_SERIALIZE() |
| 617 |
}; |
| 618 |
|
| 619 |
typedef std::vector<transfer_details> transfer_container; |
| 620 |
typedef serializable_unordered_multimap<crypto::hash, payment_details> payment_container; |
| 621 |
typedef std::set<uint32_t> unique_index_container; |
| 622 |
|
| 623 |
struct multisig_sig |
| 624 |
{ |
| 625 |
rct::rctSig sigs; |
| 626 |
std::unordered_set<crypto::public_key> ignore; |
| 627 |
std::unordered_set<rct::key> used_L; |
| 628 |
std::unordered_set<crypto::public_key> signing_keys; |
| 629 |
rct::multisig_out msout; |
| 630 |
|
| 631 |
rct::keyM total_alpha_G; |
| 632 |
rct::keyM total_alpha_H; |
| 633 |
rct::keyV c_0; |
| 634 |
rct::keyV s; |
| 635 |
|
| 636 |
BEGIN_SERIALIZE_OBJECT() |
| 637 |
VERSION_FIELD(1) |
| 638 |
if (version < 1) |
| 639 |
return false; |
| 640 |
FIELD(sigs) |
| 641 |
FIELD(ignore) |
| 642 |
FIELD(used_L) |
| 643 |
FIELD(signing_keys) |
| 644 |
FIELD(msout) |
| 645 |
FIELD(total_alpha_G) |
| 646 |
FIELD(total_alpha_H) |
| 647 |
FIELD(c_0) |
| 648 |
FIELD(s) |
| 649 |
END_SERIALIZE() |
| 650 |
}; |
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
struct pending_tx |
| 656 |
{ |
| 657 |
cryptonote::transaction tx; |
| 658 |
uint64_t dust, fee; |
| 659 |
bool dust_added_to_fee; |
| 660 |
cryptonote::tx_destination_entry change_dts; |
| 661 |
std::vector<size_t> selected_transfers; |
| 662 |
std::string key_images; |
| 663 |
crypto::secret_key tx_key; |
| 664 |
std::vector<crypto::secret_key> additional_tx_keys; |
| 665 |
std::vector<cryptonote::tx_destination_entry> dests; |
| 666 |
std::vector<multisig_sig> multisig_sigs; |
| 667 |
crypto::secret_key multisig_tx_key_entropy; |
| 668 |
|
| 669 |
tx_construction_data construction_data; |
| 670 |
|
| 671 |
BEGIN_SERIALIZE_OBJECT() |
| 672 |
VERSION_FIELD(1) |
| 673 |
FIELD(tx) |
| 674 |
FIELD(dust) |
| 675 |
FIELD(fee) |
| 676 |
FIELD(dust_added_to_fee) |
| 677 |
FIELD(change_dts) |
| 678 |
FIELD(selected_transfers) |
| 679 |
FIELD(key_images) |
| 680 |
FIELD(tx_key) |
| 681 |
FIELD(additional_tx_keys) |
| 682 |
FIELD(dests) |
| 683 |
FIELD(construction_data) |
| 684 |
FIELD(multisig_sigs) |
| 685 |
if (version < 1) |
| 686 |
{ |
| 687 |
multisig_tx_key_entropy = crypto::null_skey; |
| 688 |
return true; |
| 689 |
} |
| 690 |
FIELD(multisig_tx_key_entropy) |
| 691 |
END_SERIALIZE() |
| 692 |
}; |
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
struct unsigned_tx_set |
| 697 |
{ |
| 698 |
std::vector<tx_construction_data> txes; |
| 699 |
std::tuple<uint64_t, uint64_t, wallet2::transfer_container> transfers; |
| 700 |
std::tuple<uint64_t, uint64_t, std::vector<wallet2::exported_transfer_details>> new_transfers; |
| 701 |
|
| 702 |
BEGIN_SERIALIZE_OBJECT() |
| 703 |
VERSION_FIELD(2) |
| 704 |
FIELD(txes) |
| 705 |
if (version == 0) |
| 706 |
{ |
| 707 |
std::pair<size_t, wallet2::transfer_container> v0_transfers; |
| 708 |
FIELD(v0_transfers); |
| 709 |
std::get<0>(transfers) = std::get<0>(v0_transfers); |
| 710 |
std::get<1>(transfers) = std::get<0>(v0_transfers) + std::get<1>(v0_transfers).size(); |
| 711 |
std::get<2>(transfers) = std::get<1>(v0_transfers); |
| 712 |
return true; |
| 713 |
} |
| 714 |
if (version == 1) |
| 715 |
{ |
| 716 |
std::pair<size_t, std::vector<wallet2::exported_transfer_details>> v1_transfers; |
| 717 |
FIELD(v1_transfers); |
| 718 |
std::get<0>(new_transfers) = std::get<0>(v1_transfers); |
| 719 |
std::get<1>(new_transfers) = std::get<0>(v1_transfers) + std::get<1>(v1_transfers).size(); |
| 720 |
std::get<2>(new_transfers) = std::get<1>(v1_transfers); |
| 721 |
return true; |
| 722 |
} |
| 723 |
|
| 724 |
FIELD(new_transfers) |
| 725 |
END_SERIALIZE() |
| 726 |
}; |
| 727 |
|
| 728 |
struct signed_tx_set |
| 729 |
{ |
| 730 |
std::vector<pending_tx> ptx; |
| 731 |
std::vector<crypto::key_image> key_images; |
| 732 |
serializable_unordered_map<crypto::public_key, crypto::key_image> tx_key_images; |
| 733 |
|
| 734 |
BEGIN_SERIALIZE_OBJECT() |
| 735 |
VERSION_FIELD(0) |
| 736 |
FIELD(ptx) |
| 737 |
FIELD(key_images) |
| 738 |
FIELD(tx_key_images) |
| 739 |
END_SERIALIZE() |
| 740 |
}; |
| 741 |
|
| 742 |
struct multisig_tx_set |
| 743 |
{ |
| 744 |
std::vector<pending_tx> m_ptx; |
| 745 |
std::unordered_set<crypto::public_key> m_signers; |
| 746 |
|
| 747 |
BEGIN_SERIALIZE_OBJECT() |
| 748 |
FIELD(m_ptx) |
| 749 |
FIELD(m_signers) |
| 750 |
END_SERIALIZE() |
| 751 |
}; |
| 752 |
|
| 753 |
struct keys_file_data |
| 754 |
{ |
| 755 |
crypto::chacha_iv iv; |
| 756 |
std::string account_data; |
| 757 |
|
| 758 |
BEGIN_SERIALIZE_OBJECT() |
| 759 |
FIELD(iv) |
| 760 |
FIELD(account_data) |
| 761 |
END_SERIALIZE() |
| 762 |
}; |
| 763 |
|
| 764 |
struct cache_file_data |
| 765 |
{ |
| 766 |
crypto::chacha_iv iv; |
| 767 |
std::string cache_data; |
| 768 |
|
| 769 |
BEGIN_SERIALIZE_OBJECT() |
| 770 |
FIELD(iv) |
| 771 |
FIELD(cache_data) |
| 772 |
END_SERIALIZE() |
| 773 |
}; |
| 774 |
|
| 775 |
|
| 776 |
struct address_book_row |
| 777 |
{ |
| 778 |
cryptonote::account_public_address m_address; |
| 779 |
crypto::hash8 m_payment_id; |
| 780 |
std::string m_description; |
| 781 |
bool m_is_subaddress; |
| 782 |
bool m_has_payment_id; |
| 783 |
|
| 784 |
BEGIN_SERIALIZE_OBJECT() |
| 785 |
VERSION_FIELD(0) |
| 786 |
FIELD(m_address) |
| 787 |
FIELD(m_payment_id) |
| 788 |
FIELD(m_description) |
| 789 |
FIELD(m_is_subaddress) |
| 790 |
FIELD(m_has_payment_id) |
| 791 |
END_SERIALIZE() |
| 792 |
}; |
| 793 |
|
| 794 |
struct reserve_proof_entry |
| 795 |
{ |
| 796 |
crypto::hash txid; |
| 797 |
uint64_t index_in_tx; |
| 798 |
crypto::public_key shared_secret; |
| 799 |
crypto::key_image key_image; |
| 800 |
crypto::signature shared_secret_sig; |
| 801 |
crypto::signature key_image_sig; |
| 802 |
|
| 803 |
BEGIN_SERIALIZE_OBJECT() |
| 804 |
VERSION_FIELD(0) |
| 805 |
FIELD(txid) |
| 806 |
VARINT_FIELD(index_in_tx) |
| 807 |
FIELD(shared_secret) |
| 808 |
FIELD(key_image) |
| 809 |
FIELD(shared_secret_sig) |
| 810 |
FIELD(key_image_sig) |
| 811 |
END_SERIALIZE() |
| 812 |
}; |
| 813 |
|
| 814 |
struct background_synced_tx_t |
| 815 |
{ |
| 816 |
uint64_t index_in_background_sync_data; |
| 817 |
cryptonote::transaction tx; |
| 818 |
std::vector<uint64_t> output_indices; |
| 819 |
uint64_t height; |
| 820 |
uint64_t block_timestamp; |
| 821 |
bool double_spend_seen; |
| 822 |
|
| 823 |
BEGIN_SERIALIZE_OBJECT() |
| 824 |
VERSION_FIELD(0) |
| 825 |
VARINT_FIELD(index_in_background_sync_data) |
| 826 |
|
| 827 |
|
| 828 |
if (!tx.serialize_base(ar)) |
| 829 |
return false; |
| 830 |
|
| 831 |
FIELD(output_indices) |
| 832 |
VARINT_FIELD(height) |
| 833 |
VARINT_FIELD(block_timestamp) |
| 834 |
FIELD(double_spend_seen) |
| 835 |
END_SERIALIZE() |
| 836 |
}; |
| 837 |
|
| 838 |
struct background_sync_data_t |
| 839 |
{ |
| 840 |
bool first_refresh_done = false; |
| 841 |
uint64_t start_height = 0; |
| 842 |
serializable_unordered_map<crypto::hash, background_synced_tx_t> txs; |
| 843 |
|
| 844 |
|
| 845 |
uint64_t wallet_refresh_from_block_height; |
| 846 |
size_t subaddress_lookahead_major; |
| 847 |
size_t subaddress_lookahead_minor; |
| 848 |
RefreshType wallet_refresh_type; |
| 849 |
|
| 850 |
BEGIN_SERIALIZE_OBJECT() |
| 851 |
VERSION_FIELD(0) |
| 852 |
FIELD(first_refresh_done) |
| 853 |
FIELD(start_height) |
| 854 |
FIELD(txs) |
| 855 |
FIELD(wallet_refresh_from_block_height) |
| 856 |
VARINT_FIELD(subaddress_lookahead_major) |
| 857 |
VARINT_FIELD(subaddress_lookahead_minor) |
| 858 |
VARINT_FIELD(wallet_refresh_type) |
| 859 |
END_SERIALIZE() |
| 860 |
}; |
| 861 |
|
| 862 |
typedef std::tuple<uint64_t, crypto::public_key, rct::key> get_outs_entry; |
| 863 |
|
| 864 |
struct parsed_block |
| 865 |
{ |
| 866 |
crypto::hash hash; |
| 867 |
cryptonote::block block; |
| 868 |
std::vector<cryptonote::transaction> txes; |
| 869 |
cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices o_indices; |
| 870 |
bool error; |
| 871 |
}; |
| 872 |
|
| 873 |
struct is_out_data |
| 874 |
{ |
| 875 |
crypto::public_key pkey; |
| 876 |
crypto::key_derivation derivation; |
| 877 |
std::vector<boost::optional<cryptonote::subaddress_receive_info>> received; |
| 878 |
}; |
| 879 |
|
| 880 |
struct tx_cache_data |
| 881 |
{ |
| 882 |
std::vector<cryptonote::tx_extra_field> tx_extra_fields; |
| 883 |
std::vector<is_out_data> primary; |
| 884 |
std::vector<is_out_data> additional; |
| 885 |
|
| 886 |
bool empty() const { return tx_extra_fields.empty() && primary.empty() && additional.empty(); } |
| 887 |
}; |
| 888 |
|
| 889 |
struct detached_blockchain_data |
| 890 |
{ |
| 891 |
hashchain detached_blockchain; |
| 892 |
size_t original_chain_size; |
| 893 |
std::unordered_set<crypto::hash> detached_tx_hashes; |
| 894 |
std::unordered_map<crypto::hash, std::vector<cryptonote::tx_destination_entry>> detached_confirmed_txs_dests; |
| 895 |
}; |
| 896 |
|
| 897 |
struct process_tx_entry_t |
| 898 |
{ |
| 899 |
cryptonote::COMMAND_RPC_GET_TRANSACTIONS::entry tx_entry; |
| 900 |
cryptonote::transaction tx; |
| 901 |
crypto::hash tx_hash; |
| 902 |
}; |
| 903 |
|
| 904 |
struct tx_entry_data |
| 905 |
{ |
| 906 |
std::vector<process_tx_entry_t> tx_entries; |
| 907 |
uint64_t lowest_height; |
| 908 |
uint64_t highest_height; |
| 909 |
|
| 910 |
tx_entry_data(): lowest_height((uint64_t)-1), highest_height(0) {} |
| 911 |
}; |
| 912 |
|
| 913 |
|
| 914 |
|
| 915 |
|
| 916 |
|
| 917 |
|
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
void generate(const std::string& wallet_, const epee::wipeable_string& password, |
| 922 |
const epee::wipeable_string& multisig_data, bool create_address_file = false); |
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
|
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
crypto::secret_key generate(const std::string& wallet, const epee::wipeable_string& password, |
| 935 |
const crypto::secret_key& recovery_param = crypto::secret_key(), bool recover = false, |
| 936 |
bool two_random = false, bool create_address_file = false); |
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
|
| 941 |
|
| 942 |
|
| 943 |
|
| 944 |
|
| 945 |
|
| 946 |
void generate(const std::string& wallet, const epee::wipeable_string& password, |
| 947 |
const cryptonote::account_public_address &account_public_address, |
| 948 |
const crypto::secret_key& spendkey, const crypto::secret_key& viewkey, bool create_address_file = false); |
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
|
| 953 |
|
| 954 |
|
| 955 |
|
| 956 |
|
| 957 |
void generate(const std::string& wallet, const epee::wipeable_string& password, |
| 958 |
const cryptonote::account_public_address &account_public_address, |
| 959 |
const crypto::secret_key& viewkey = crypto::secret_key(), bool create_address_file = false); |
| 960 |
|
| 961 |
|
| 962 |
|
| 963 |
|
| 964 |
|
| 965 |
|
| 966 |
|
| 967 |
void restore(const std::string& wallet_, const epee::wipeable_string& password, const std::string &device_name, bool create_address_file = false); |
| 968 |
|
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
std::string make_multisig(const epee::wipeable_string &password, |
| 975 |
const std::vector<std::string> &kex_messages, |
| 976 |
const std::uint32_t threshold); |
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
std::string exchange_multisig_keys(const epee::wipeable_string &password, |
| 983 |
const std::vector<std::string> &kex_messages, |
| 984 |
const bool force_update_use_with_caution = false); |
| 985 |
|
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
std::string get_multisig_first_kex_msg() const; |
| 990 |
|
| 991 |
|
| 992 |
|
| 993 |
|
| 994 |
cryptonote::blobdata export_multisig(); |
| 995 |
|
| 996 |
|
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
size_t import_multisig(std::vector<cryptonote::blobdata> info, bool refresh_after_import = true); |
| 1002 |
|
| 1003 |
|
| 1004 |
|
| 1005 |
|
| 1006 |
|
| 1007 |
void rewrite(const std::string& wallet_name, const epee::wipeable_string& password); |
| 1008 |
void write_watch_only_wallet(const std::string& wallet_name, const epee::wipeable_string& password, std::string &new_keys_filename); |
| 1009 |
void load(const std::string& wallet, const epee::wipeable_string& password, const std::string& keys_buf = "", const std::string& cache_buf = ""); |
| 1010 |
void store(); |
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
|
| 1015 |
|
| 1016 |
|
| 1017 |
|
| 1018 |
|
| 1019 |
|
| 1020 |
|
| 1021 |
|
| 1022 |
|
| 1023 |
|
| 1024 |
|
| 1025 |
|
| 1026 |
void store_to(const std::string &path, const epee::wipeable_string &password, bool force_rewrite_keys = false); |
| 1027 |
|
| 1028 |
|
| 1029 |
|
| 1030 |
|
| 1031 |
|
| 1032 |
|
| 1033 |
|
| 1034 |
boost::optional<wallet2::keys_file_data> get_keys_file_data(const epee::wipeable_string& password, bool watch_only); |
| 1035 |
|
| 1036 |
|
| 1037 |
|
| 1038 |
|
| 1039 |
boost::optional<wallet2::cache_file_data> get_cache_file_data(); |
| 1040 |
|
| 1041 |
std::string path() const; |
| 1042 |
|
| 1043 |
|
| 1044 |
|
| 1045 |
|
| 1046 |
|
| 1047 |
bool has_proxy_option() const; |
| 1048 |
|
| 1049 |
|
| 1050 |
|
| 1051 |
|
| 1052 |
bool verify_password(const epee::wipeable_string& password) {crypto::secret_key key = crypto::null_skey; return verify_password(password, key);}; |
| 1053 |
bool verify_password(const epee::wipeable_string& password, crypto::secret_key &spend_key_out); |
| 1054 |
cryptonote::account_base& get_account(){return m_account;} |
| 1055 |
const cryptonote::account_base& get_account()const{return m_account;} |
| 1056 |
|
| 1057 |
void encrypt_keys(const crypto::chacha_key &key); |
| 1058 |
void encrypt_keys(const epee::wipeable_string &password); |
| 1059 |
void decrypt_keys(const crypto::chacha_key &key); |
| 1060 |
void decrypt_keys(const epee::wipeable_string &password); |
| 1061 |
|
| 1062 |
void set_refresh_from_block_height(uint64_t height) {m_refresh_from_block_height = height;} |
| 1063 |
uint64_t get_refresh_from_block_height() const {return m_refresh_from_block_height;} |
| 1064 |
|
| 1065 |
void explicit_refresh_from_block_height(bool expl) {m_explicit_refresh_from_block_height = expl;} |
| 1066 |
bool explicit_refresh_from_block_height() const {return m_explicit_refresh_from_block_height;} |
| 1067 |
|
| 1068 |
void max_reorg_depth(uint64_t depth) {m_max_reorg_depth = depth;} |
| 1069 |
uint64_t max_reorg_depth() const {return m_max_reorg_depth;} |
| 1070 |
|
| 1071 |
bool deinit(); |
| 1072 |
bool init(std::string daemon_address = "http: |
| 1073 |
boost::optional<epee::net_utils::http::login> daemon_login = boost::none, |
| 1074 |
const std::string &proxy = "", |
| 1075 |
uint64_t upper_transaction_weight_limit = 0, |
| 1076 |
bool trusted_daemon = true, |
| 1077 |
epee::net_utils::ssl_options_t ssl_options = epee::net_utils::ssl_support_t::e_ssl_support_autodetect); |
| 1078 |
bool set_daemon(std::string daemon_address = "http: |
| 1079 |
boost::optional<epee::net_utils::http::login> daemon_login = boost::none, bool trusted_daemon = true, |
| 1080 |
epee::net_utils::ssl_options_t ssl_options = epee::net_utils::ssl_support_t::e_ssl_support_autodetect, |
| 1081 |
const std::string &proxy = ""); |
| 1082 |
bool set_proxy(const std::string &address); |
| 1083 |
|
| 1084 |
void stop() { m_run.store(false, std::memory_order_relaxed); m_message_store.stop(); } |
| 1085 |
|
| 1086 |
i_wallet2_callback* callback() const { return m_callback; } |
| 1087 |
void callback(i_wallet2_callback* callback) { m_callback = callback; } |
| 1088 |
|
| 1089 |
bool is_trusted_daemon() const { return m_trusted_daemon; } |
| 1090 |
void set_trusted_daemon(bool trusted) { m_trusted_daemon = trusted; } |
| 1091 |
|
| 1092 |
|
| 1093 |
|
| 1094 |
|
| 1095 |
bool is_deterministic() const; |
| 1096 |
bool get_seed(epee::wipeable_string& electrum_words, const epee::wipeable_string &passphrase = epee::wipeable_string()) const; |
| 1097 |
|
| 1098 |
|
| 1099 |
|
| 1100 |
|
| 1101 |
bool light_wallet() const { return m_light_wallet; } |
| 1102 |
void set_light_wallet(bool light_wallet) { m_light_wallet = light_wallet; } |
| 1103 |
uint64_t get_light_wallet_scanned_block_height() const { return m_light_wallet_scanned_block_height; } |
| 1104 |
uint64_t get_light_wallet_blockchain_height() const { return m_light_wallet_blockchain_height; } |
| 1105 |
|
| 1106 |
|
| 1107 |
|
| 1108 |
|
| 1109 |
const std::string &get_seed_language() const; |
| 1110 |
|
| 1111 |
|
| 1112 |
|
| 1113 |
void set_seed_language(const std::string &language); |
| 1114 |
|
| 1115 |
|
| 1116 |
cryptonote::account_public_address get_subaddress(const cryptonote::subaddress_index& index) const; |
| 1117 |
cryptonote::account_public_address get_address() const { return get_subaddress({0,0}); } |
| 1118 |
boost::optional<cryptonote::subaddress_index> get_subaddress_index(const cryptonote::account_public_address& address) const; |
| 1119 |
crypto::public_key get_subaddress_spend_public_key(const cryptonote::subaddress_index& index) const; |
| 1120 |
std::vector<crypto::public_key> get_subaddress_spend_public_keys(uint32_t account, uint32_t begin, uint32_t end) const; |
| 1121 |
std::string get_subaddress_as_str(const cryptonote::subaddress_index& index) const; |
| 1122 |
std::string get_address_as_str() const { return get_subaddress_as_str({0, 0}); } |
| 1123 |
std::string get_integrated_address_as_str(const crypto::hash8& payment_id) const; |
| 1124 |
void add_subaddress_account(const std::string& label); |
| 1125 |
size_t get_num_subaddress_accounts() const { return m_subaddress_labels.size(); } |
| 1126 |
size_t get_num_subaddresses(uint32_t index_major) const { return index_major < m_subaddress_labels.size() ? m_subaddress_labels[index_major].size() : 0; } |
| 1127 |
void add_subaddress(uint32_t index_major, const std::string& label); |
| 1128 |
|
| 1129 |
|
| 1130 |
|
| 1131 |
|
| 1132 |
|
| 1133 |
|
| 1134 |
|
| 1135 |
void expand_subaddresses(const cryptonote::subaddress_index& index); |
| 1136 |
void create_one_off_subaddress(const cryptonote::subaddress_index& index); |
| 1137 |
std::string get_subaddress_label(const cryptonote::subaddress_index& index) const; |
| 1138 |
void set_subaddress_label(const cryptonote::subaddress_index &index, const std::string &label); |
| 1139 |
void set_subaddress_lookahead(size_t major, size_t minor); |
| 1140 |
std::pair<size_t, size_t> get_subaddress_lookahead() const { return {m_subaddress_lookahead_major, m_subaddress_lookahead_minor}; } |
| 1141 |
|
| 1142 |
|
| 1143 |
|
| 1144 |
bool is_deprecated() const; |
| 1145 |
void refresh(bool trusted_daemon); |
| 1146 |
void refresh(bool trusted_daemon, uint64_t start_height, uint64_t & blocks_fetched); |
| 1147 |
void refresh(bool trusted_daemon, uint64_t start_height, uint64_t & blocks_fetched, bool& received_money, bool check_pool = true, bool try_incremental = true, uint64_t max_blocks = std::numeric_limits<uint64_t>::max()); |
| 1148 |
bool refresh(bool trusted_daemon, uint64_t & blocks_fetched, bool& received_money, bool& ok); |
| 1149 |
|
| 1150 |
void set_refresh_type(RefreshType refresh_type) { m_refresh_type = refresh_type; } |
| 1151 |
RefreshType get_refresh_type() const { return m_refresh_type; } |
| 1152 |
|
| 1153 |
cryptonote::network_type nettype() const { return m_nettype; } |
| 1154 |
bool watch_only() const { return m_watch_only; } |
| 1155 |
bool multisig(bool *ready = NULL, uint32_t *threshold = NULL, uint32_t *total = NULL) const; |
| 1156 |
bool is_background_wallet() const { return m_is_background_wallet; } |
| 1157 |
bool has_multisig_partial_key_images() const; |
| 1158 |
bool has_unknown_key_images() const; |
| 1159 |
bool get_multisig_seed(epee::wipeable_string& seed, const epee::wipeable_string &passphrase = std::string()) const; |
| 1160 |
bool key_on_device() const { return get_device_type() != hw::device::device_type::SOFTWARE; } |
| 1161 |
hw::device::device_type get_device_type() const { return m_key_device_type; } |
| 1162 |
bool reconnect_device(); |
| 1163 |
|
| 1164 |
|
| 1165 |
uint64_t balance(uint32_t subaddr_index_major, bool strict) const; |
| 1166 |
uint64_t unlocked_balance(uint32_t subaddr_index_major, bool strict, uint64_t *blocks_to_unlock = NULL, uint64_t *time_to_unlock = NULL); |
| 1167 |
|
| 1168 |
std::map<uint32_t, uint64_t> balance_per_subaddress(uint32_t subaddr_index_major, bool strict) const; |
| 1169 |
std::map<uint32_t, std::pair<uint64_t, std::pair<uint64_t, uint64_t>>> unlocked_balance_per_subaddress(uint32_t subaddr_index_major, bool strict); |
| 1170 |
|
| 1171 |
uint64_t balance_all(bool strict) const; |
| 1172 |
uint64_t unlocked_balance_all(bool strict, uint64_t *blocks_to_unlock = NULL, uint64_t *time_to_unlock = NULL); |
| 1173 |
template<typename T> |
| 1174 |
void transfer_selected(const std::vector<cryptonote::tx_destination_entry>& dsts, const std::vector<size_t>& selected_transfers, size_t fake_outputs_count, |
| 1175 |
std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs, std::unordered_set<crypto::public_key> &valid_public_keys_cache, |
| 1176 |
uint64_t fee, const std::vector<uint8_t>& extra, T destination_split_strategy, const tx_dust_policy& dust_policy, cryptonote::transaction& tx, pending_tx &ptx, const bool use_view_tags); |
| 1177 |
void transfer_selected_rct(std::vector<cryptonote::tx_destination_entry> dsts, const std::vector<size_t>& selected_transfers, size_t fake_outputs_count, |
| 1178 |
std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs, std::unordered_set<crypto::public_key> &valid_public_keys_cache, |
| 1179 |
uint64_t fee, const std::vector<uint8_t>& extra, cryptonote::transaction& tx, pending_tx &ptx, const rct::RCTConfig &rct_config, const bool use_view_tags); |
| 1180 |
|
| 1181 |
void commit_tx(pending_tx& ptx_vector); |
| 1182 |
void commit_tx(std::vector<pending_tx>& ptx_vector); |
| 1183 |
bool save_tx(const std::vector<pending_tx>& ptx_vector, const std::string &filename) const; |
| 1184 |
std::string dump_tx_to_str(const std::vector<pending_tx> &ptx_vector) const; |
| 1185 |
std::string save_multisig_tx(multisig_tx_set txs); |
| 1186 |
bool save_multisig_tx(const multisig_tx_set &txs, const std::string &filename); |
| 1187 |
std::string save_multisig_tx(const std::vector<pending_tx>& ptx_vector); |
| 1188 |
bool save_multisig_tx(const std::vector<pending_tx>& ptx_vector, const std::string &filename); |
| 1189 |
multisig_tx_set make_multisig_tx_set(const std::vector<pending_tx>& ptx_vector) const; |
| 1190 |
|
| 1191 |
bool sign_tx(const std::string &unsigned_filename, const std::string &signed_filename, std::vector<wallet2::pending_tx> &ptx, std::function<bool(const unsigned_tx_set&)> accept_func = NULL, bool export_raw = false); |
| 1192 |
|
| 1193 |
bool sign_tx(unsigned_tx_set &exported_txs, const std::string &signed_filename, std::vector<wallet2::pending_tx> &ptx, bool export_raw = false); |
| 1194 |
bool sign_tx(unsigned_tx_set &exported_txs, std::vector<wallet2::pending_tx> &ptx, signed_tx_set &signed_txs); |
| 1195 |
std::string sign_tx_dump_to_str(unsigned_tx_set &exported_txs, std::vector<wallet2::pending_tx> &ptx, signed_tx_set &signed_txes); |
| 1196 |
|
| 1197 |
bool load_unsigned_tx(const std::string &unsigned_filename, unsigned_tx_set &exported_txs) const; |
| 1198 |
bool parse_unsigned_tx_from_str(const std::string &unsigned_tx_st, unsigned_tx_set &exported_txs) const; |
| 1199 |
bool load_tx(const std::string &signed_filename, std::vector<tools::wallet2::pending_tx> &ptx, std::function<bool(const signed_tx_set&)> accept_func = NULL); |
| 1200 |
bool parse_tx_from_str(const std::string &signed_tx_st, std::vector<tools::wallet2::pending_tx> &ptx, std::function<bool(const signed_tx_set &)> accept_func); |
| 1201 |
std::vector<wallet2::pending_tx> create_transactions_2(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, uint32_t priority, const std::vector<uint8_t>& extra, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices, const unique_index_container& subtract_fee_from_outputs = {}); |
| 1202 |
std::vector<wallet2::pending_tx> create_transactions_all(uint64_t below, const cryptonote::account_public_address &address, bool is_subaddress, const size_t outputs, const size_t fake_outs_count, uint32_t priority, const std::vector<uint8_t>& extra, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices); |
| 1203 |
std::vector<wallet2::pending_tx> create_transactions_single(const crypto::key_image &ki, const cryptonote::account_public_address &address, bool is_subaddress, const size_t outputs, const size_t fake_outs_count, uint32_t priority, const std::vector<uint8_t>& extra); |
| 1204 |
std::vector<wallet2::pending_tx> create_transactions_from(const cryptonote::account_public_address &address, bool is_subaddress, const size_t outputs, std::vector<size_t> unused_transfers_indices, std::vector<size_t> unused_dust_indices, const size_t fake_outs_count, uint32_t priority, const std::vector<uint8_t>& extra); |
| 1205 |
bool sanity_check(const std::vector<wallet2::pending_tx> &ptx_vector, const std::vector<cryptonote::tx_destination_entry>& dsts, const unique_index_container& subtract_fee_from_outputs = {}) const; |
| 1206 |
void cold_tx_aux_import(const std::vector<pending_tx>& ptx, const std::vector<std::string>& tx_device_aux); |
| 1207 |
void cold_sign_tx(const std::vector<pending_tx>& ptx_vector, signed_tx_set &exported_txs, std::vector<cryptonote::address_parse_info> &dsts_info, std::vector<std::string> & tx_device_aux); |
| 1208 |
uint64_t cold_key_image_sync(uint64_t &spent, uint64_t &unspent); |
| 1209 |
void device_show_address(uint32_t account_index, uint32_t address_index, const boost::optional<crypto::hash8> &payment_id); |
| 1210 |
bool parse_multisig_tx_from_str(std::string multisig_tx_st, multisig_tx_set &exported_txs) const; |
| 1211 |
bool load_multisig_tx(cryptonote::blobdata blob, multisig_tx_set &exported_txs, std::function<bool(const multisig_tx_set&)> accept_func = NULL); |
| 1212 |
bool load_multisig_tx_from_file(const std::string &filename, multisig_tx_set &exported_txs, std::function<bool(const multisig_tx_set&)> accept_func = NULL); |
| 1213 |
bool sign_multisig_tx_from_file(const std::string &filename, std::vector<crypto::hash> &txids, std::function<bool(const multisig_tx_set&)> accept_func); |
| 1214 |
bool sign_multisig_tx(multisig_tx_set &exported_txs, std::vector<crypto::hash> &txids); |
| 1215 |
bool sign_multisig_tx_to_file(multisig_tx_set &exported_txs, const std::string &filename, std::vector<crypto::hash> &txids); |
| 1216 |
std::vector<pending_tx> create_unmixable_sweep_transactions(); |
| 1217 |
void discard_unmixable_outputs(); |
| 1218 |
bool check_connection(uint32_t *version = NULL, bool *ssl = NULL, uint32_t timeout = 200000, bool *wallet_is_outdated = NULL, bool *daemon_is_outdated = NULL); |
| 1219 |
bool check_version(uint32_t *version, bool *wallet_is_outdated, bool *daemon_is_outdated); |
| 1220 |
bool check_hard_fork_version(cryptonote::network_type nettype, const std::vector<std::pair<uint8_t, uint64_t>> &daemon_hard_forks, const uint64_t height, const uint64_t target_height, bool *wallet_is_outdated, bool *daemon_is_outdated); |
| 1221 |
void get_transfers(wallet2::transfer_container& incoming_transfers) const; |
| 1222 |
void get_payments(const crypto::hash& payment_id, std::list<wallet2::payment_details>& payments, uint64_t min_height = 0, const boost::optional<uint32_t>& subaddr_account = boost::none, const std::set<uint32_t>& subaddr_indices = {}) const; |
| 1223 |
void get_payments(std::list<std::pair<crypto::hash,wallet2::payment_details>>& payments, uint64_t min_height, uint64_t max_height = (uint64_t)-1, const boost::optional<uint32_t>& subaddr_account = boost::none, const std::set<uint32_t>& subaddr_indices = {}) const; |
| 1224 |
void get_payments_out(std::list<std::pair<crypto::hash,wallet2::confirmed_transfer_details>>& confirmed_payments, |
| 1225 |
uint64_t min_height, uint64_t max_height = (uint64_t)-1, const boost::optional<uint32_t>& subaddr_account = boost::none, const std::set<uint32_t>& subaddr_indices = {}) const; |
| 1226 |
void get_unconfirmed_payments_out(std::list<std::pair<crypto::hash,wallet2::unconfirmed_transfer_details>>& unconfirmed_payments, const boost::optional<uint32_t>& subaddr_account = boost::none, const std::set<uint32_t>& subaddr_indices = {}) const; |
| 1227 |
void get_unconfirmed_payments(std::list<std::pair<crypto::hash,wallet2::pool_payment_details>>& unconfirmed_payments, const boost::optional<uint32_t>& subaddr_account = boost::none, const std::set<uint32_t>& subaddr_indices = {}) const; |
| 1228 |
|
| 1229 |
uint64_t get_blockchain_current_height() const { return m_light_wallet_blockchain_height ? m_light_wallet_blockchain_height : m_blockchain.size(); } |
| 1230 |
void rescan_spent(); |
| 1231 |
void rescan_blockchain(bool hard, bool refresh = true, bool keep_key_images = false); |
| 1232 |
bool is_transfer_unlocked(const transfer_details& td); |
| 1233 |
bool is_transfer_unlocked(uint64_t unlock_time, uint64_t block_height); |
| 1234 |
|
| 1235 |
uint64_t get_last_block_reward() const { return m_last_block_reward; } |
| 1236 |
uint64_t get_device_last_key_image_sync() const { return m_device_last_key_image_sync; } |
| 1237 |
|
| 1238 |
std::vector<cryptonote::public_node> get_public_nodes(bool white_only = true); |
| 1239 |
|
| 1240 |
template <class t_archive> |
| 1241 |
inline void serialize(t_archive &a, const unsigned int ver) |
| 1242 |
{ |
| 1243 |
uint64_t dummy_refresh_height = 0; |
| 1244 |
if(ver < 5) |
| 1245 |
return; |
| 1246 |
if (ver < 19) |
| 1247 |
{ |
| 1248 |
std::vector<crypto::hash> blockchain; |
| 1249 |
a & blockchain; |
| 1250 |
m_blockchain.clear(); |
| 1251 |
for (const auto &b: blockchain) |
| 1252 |
{ |
| 1253 |
m_blockchain.push_back(b); |
| 1254 |
} |
| 1255 |
} |
| 1256 |
else |
| 1257 |
{ |
| 1258 |
a & m_blockchain; |
| 1259 |
} |
| 1260 |
a & m_transfers; |
| 1261 |
a & m_account_public_address; |
| 1262 |
a & m_key_images.parent(); |
| 1263 |
if(ver < 6) |
| 1264 |
return; |
| 1265 |
a & m_unconfirmed_txs.parent(); |
| 1266 |
if(ver < 7) |
| 1267 |
return; |
| 1268 |
a & m_payments.parent(); |
| 1269 |
if(ver < 8) |
| 1270 |
return; |
| 1271 |
a & m_tx_keys.parent(); |
| 1272 |
if(ver < 9) |
| 1273 |
return; |
| 1274 |
a & m_confirmed_txs.parent(); |
| 1275 |
if(ver < 11) |
| 1276 |
return; |
| 1277 |
a & dummy_refresh_height; |
| 1278 |
if(ver < 12) |
| 1279 |
return; |
| 1280 |
a & m_tx_notes.parent(); |
| 1281 |
if(ver < 13) |
| 1282 |
return; |
| 1283 |
if (ver < 17) |
| 1284 |
{ |
| 1285 |
|
| 1286 |
std::unordered_map<crypto::hash, payment_details> m; |
| 1287 |
a & m; |
| 1288 |
m_unconfirmed_payments.clear(); |
| 1289 |
for (std::unordered_map<crypto::hash, payment_details>::const_iterator i = m.begin(); i != m.end(); ++i) |
| 1290 |
m_unconfirmed_payments.insert(std::make_pair(i->first, pool_payment_details{i->second, false})); |
| 1291 |
} |
| 1292 |
if(ver < 14) |
| 1293 |
return; |
| 1294 |
if(ver < 15) |
| 1295 |
{ |
| 1296 |
|
| 1297 |
m_pub_keys.clear(); |
| 1298 |
for (size_t i = 0; i < m_transfers.size(); ++i) |
| 1299 |
{ |
| 1300 |
const transfer_details &td = m_transfers[i]; |
| 1301 |
m_pub_keys.emplace(td.get_public_key(), i); |
| 1302 |
} |
| 1303 |
return; |
| 1304 |
} |
| 1305 |
a & m_pub_keys.parent(); |
| 1306 |
if(ver < 16) |
| 1307 |
return; |
| 1308 |
a & m_address_book; |
| 1309 |
if(ver < 17) |
| 1310 |
return; |
| 1311 |
if (ver < 22) |
| 1312 |
{ |
| 1313 |
|
| 1314 |
std::unordered_multimap<crypto::hash, payment_details> m; |
| 1315 |
a & m; |
| 1316 |
m_unconfirmed_payments.clear(); |
| 1317 |
for (const auto &i: m) |
| 1318 |
m_unconfirmed_payments.insert(std::make_pair(i.first, pool_payment_details{i.second, false})); |
| 1319 |
} |
| 1320 |
if(ver < 18) |
| 1321 |
return; |
| 1322 |
a & m_scanned_pool_txs[0]; |
| 1323 |
a & m_scanned_pool_txs[1]; |
| 1324 |
if (ver < 20) |
| 1325 |
return; |
| 1326 |
a & m_subaddresses.parent(); |
| 1327 |
std::unordered_map<cryptonote::subaddress_index, crypto::public_key> dummy_subaddresses_inv; |
| 1328 |
a & dummy_subaddresses_inv; |
| 1329 |
a & m_subaddress_labels; |
| 1330 |
a & m_additional_tx_keys.parent(); |
| 1331 |
if(ver < 21) |
| 1332 |
return; |
| 1333 |
a & m_attributes.parent(); |
| 1334 |
if(ver < 22) |
| 1335 |
return; |
| 1336 |
a & m_unconfirmed_payments.parent(); |
| 1337 |
if(ver < 23) |
| 1338 |
return; |
| 1339 |
a & (std::pair<std::map<std::string, std::string>, std::vector<std::string>>&)m_account_tags; |
| 1340 |
if(ver < 24) |
| 1341 |
return; |
| 1342 |
a & m_ring_history_saved; |
| 1343 |
if(ver < 25) |
| 1344 |
return; |
| 1345 |
a & m_last_block_reward; |
| 1346 |
if(ver < 26) |
| 1347 |
return; |
| 1348 |
a & m_tx_device.parent(); |
| 1349 |
if(ver < 27) |
| 1350 |
return; |
| 1351 |
a & m_device_last_key_image_sync; |
| 1352 |
if(ver < 28) |
| 1353 |
return; |
| 1354 |
a & m_cold_key_images.parent(); |
| 1355 |
if(ver < 29) |
| 1356 |
return; |
| 1357 |
a & m_rpc_client_secret_key; |
| 1358 |
if(ver < 30) |
| 1359 |
{ |
| 1360 |
m_has_ever_refreshed_from_node = false; |
| 1361 |
return; |
| 1362 |
} |
| 1363 |
a & m_has_ever_refreshed_from_node; |
| 1364 |
if(ver < 31) |
| 1365 |
{ |
| 1366 |
m_background_sync_data = background_sync_data_t{}; |
| 1367 |
return; |
| 1368 |
} |
| 1369 |
a & m_background_sync_data; |
| 1370 |
} |
| 1371 |
|
| 1372 |
BEGIN_SERIALIZE_OBJECT() |
| 1373 |
MAGIC_FIELD("monero wallet cache") |
| 1374 |
VERSION_FIELD(2) |
| 1375 |
FIELD(m_blockchain) |
| 1376 |
FIELD(m_transfers) |
| 1377 |
FIELD(m_account_public_address) |
| 1378 |
FIELD(m_key_images) |
| 1379 |
FIELD(m_unconfirmed_txs) |
| 1380 |
FIELD(m_payments) |
| 1381 |
FIELD(m_tx_keys) |
| 1382 |
FIELD(m_confirmed_txs) |
| 1383 |
FIELD(m_tx_notes) |
| 1384 |
FIELD(m_unconfirmed_payments) |
| 1385 |
FIELD(m_pub_keys) |
| 1386 |
FIELD(m_address_book) |
| 1387 |
FIELD(m_scanned_pool_txs[0]) |
| 1388 |
FIELD(m_scanned_pool_txs[1]) |
| 1389 |
FIELD(m_subaddresses) |
| 1390 |
FIELD(m_subaddress_labels) |
| 1391 |
FIELD(m_additional_tx_keys) |
| 1392 |
FIELD(m_attributes) |
| 1393 |
FIELD(m_account_tags) |
| 1394 |
FIELD(m_ring_history_saved) |
| 1395 |
FIELD(m_last_block_reward) |
| 1396 |
FIELD(m_tx_device) |
| 1397 |
FIELD(m_device_last_key_image_sync) |
| 1398 |
FIELD(m_cold_key_images) |
| 1399 |
FIELD(m_rpc_client_secret_key) |
| 1400 |
if (version < 1) |
| 1401 |
{ |
| 1402 |
m_has_ever_refreshed_from_node = false; |
| 1403 |
return true; |
| 1404 |
} |
| 1405 |
FIELD(m_has_ever_refreshed_from_node) |
| 1406 |
if (version < 2) |
| 1407 |
{ |
| 1408 |
m_background_sync_data = background_sync_data_t{}; |
| 1409 |
return true; |
| 1410 |
} |
| 1411 |
FIELD(m_background_sync_data) |
| 1412 |
END_SERIALIZE() |
| 1413 |
|
| 1414 |
|
| 1415 |
|
| 1416 |
|
| 1417 |
|
| 1418 |
|
| 1419 |
|
| 1420 |
static void wallet_exists(const std::string& file_path, bool& keys_file_exists, bool& wallet_file_exists); |
| 1421 |
|
| 1422 |
|
| 1423 |
|
| 1424 |
|
| 1425 |
|
| 1426 |
static bool wallet_valid_path_format(const std::string& file_path); |
| 1427 |
static std::string make_background_wallet_file_name(const std::string &wallet_file); |
| 1428 |
static std::string make_background_keys_file_name(const std::string &wallet_file); |
| 1429 |
static bool parse_long_payment_id(const std::string& payment_id_str, crypto::hash& payment_id); |
| 1430 |
static bool parse_short_payment_id(const std::string& payment_id_str, crypto::hash8& payment_id); |
| 1431 |
static bool parse_payment_id(const std::string& payment_id_str, crypto::hash& payment_id); |
| 1432 |
|
| 1433 |
bool always_confirm_transfers() const { return m_always_confirm_transfers; } |
| 1434 |
void always_confirm_transfers(bool always) { m_always_confirm_transfers = always; } |
| 1435 |
bool print_ring_members() const { return m_print_ring_members; } |
| 1436 |
void print_ring_members(bool value) { m_print_ring_members = value; } |
| 1437 |
bool store_tx_info() const { return m_store_tx_info; } |
| 1438 |
void store_tx_info(bool store) { m_store_tx_info = store; } |
| 1439 |
uint32_t default_mixin() const { return m_default_mixin; } |
| 1440 |
void default_mixin(uint32_t m) { m_default_mixin = m; } |
| 1441 |
uint32_t get_default_priority() const { return m_default_priority; } |
| 1442 |
void set_default_priority(uint32_t p) { m_default_priority = p; } |
| 1443 |
bool auto_refresh() const { return m_auto_refresh; } |
| 1444 |
void auto_refresh(bool r) { m_auto_refresh = r; } |
| 1445 |
AskPasswordType ask_password() const { return m_ask_password; } |
| 1446 |
void ask_password(AskPasswordType ask) { m_ask_password = ask; } |
| 1447 |
void set_min_output_count(uint32_t count) { m_min_output_count = count; } |
| 1448 |
uint32_t get_min_output_count() const { return m_min_output_count; } |
| 1449 |
void set_min_output_value(uint64_t value) { m_min_output_value = value; } |
| 1450 |
uint64_t get_min_output_value() const { return m_min_output_value; } |
| 1451 |
void merge_destinations(bool merge) { m_merge_destinations = merge; } |
| 1452 |
bool merge_destinations() const { return m_merge_destinations; } |
| 1453 |
bool confirm_backlog() const { return m_confirm_backlog; } |
| 1454 |
void confirm_backlog(bool always) { m_confirm_backlog = always; } |
| 1455 |
void set_confirm_backlog_threshold(uint32_t threshold) { m_confirm_backlog_threshold = threshold; }; |
| 1456 |
uint32_t get_confirm_backlog_threshold() const { return m_confirm_backlog_threshold; }; |
| 1457 |
bool confirm_export_overwrite() const { return m_confirm_export_overwrite; } |
| 1458 |
void confirm_export_overwrite(bool always) { m_confirm_export_overwrite = always; } |
| 1459 |
bool auto_low_priority() const { return m_auto_low_priority; } |
| 1460 |
void auto_low_priority(bool value) { m_auto_low_priority = value; } |
| 1461 |
bool segregate_pre_fork_outputs() const { return m_segregate_pre_fork_outputs; } |
| 1462 |
void segregate_pre_fork_outputs(bool value) { m_segregate_pre_fork_outputs = value; } |
| 1463 |
bool key_reuse_mitigation2() const { return m_key_reuse_mitigation2; } |
| 1464 |
void key_reuse_mitigation2(bool value) { m_key_reuse_mitigation2 = value; } |
| 1465 |
uint64_t segregation_height() const { return m_segregation_height; } |
| 1466 |
void segregation_height(uint64_t height) { m_segregation_height = height; } |
| 1467 |
bool ignore_fractional_outputs() const { return m_ignore_fractional_outputs; } |
| 1468 |
void ignore_fractional_outputs(bool value) { m_ignore_fractional_outputs = value; } |
| 1469 |
bool confirm_non_default_ring_size() const { return m_confirm_non_default_ring_size; } |
| 1470 |
void confirm_non_default_ring_size(bool always) { m_confirm_non_default_ring_size = always; } |
| 1471 |
uint64_t ignore_outputs_above() const { return m_ignore_outputs_above; } |
| 1472 |
void ignore_outputs_above(uint64_t value) { m_ignore_outputs_above = value; } |
| 1473 |
uint64_t ignore_outputs_below() const { return m_ignore_outputs_below; } |
| 1474 |
void ignore_outputs_below(uint64_t value) { m_ignore_outputs_below = value; } |
| 1475 |
bool track_uses() const { return m_track_uses; } |
| 1476 |
void track_uses(bool value) { m_track_uses = value; } |
| 1477 |
BackgroundSyncType background_sync_type() const { return m_background_sync_type; } |
| 1478 |
void setup_background_sync(BackgroundSyncType background_sync_type, const epee::wipeable_string &wallet_password, const boost::optional<epee::wipeable_string> &background_cache_password); |
| 1479 |
bool is_background_syncing() const { return m_background_syncing; } |
| 1480 |
bool show_wallet_name_when_locked() const { return m_show_wallet_name_when_locked; } |
| 1481 |
void show_wallet_name_when_locked(bool value) { m_show_wallet_name_when_locked = value; } |
| 1482 |
BackgroundMiningSetupType setup_background_mining() const { return m_setup_background_mining; } |
| 1483 |
void setup_background_mining(BackgroundMiningSetupType value) { m_setup_background_mining = value; } |
| 1484 |
uint32_t inactivity_lock_timeout() const { return m_inactivity_lock_timeout; } |
| 1485 |
void inactivity_lock_timeout(uint32_t seconds) { m_inactivity_lock_timeout = seconds; } |
| 1486 |
const std::string & device_name() const { return m_device_name; } |
| 1487 |
void device_name(const std::string & device_name) { m_device_name = device_name; } |
| 1488 |
const std::string & device_derivation_path() const { return m_device_derivation_path; } |
| 1489 |
void device_derivation_path(const std::string &device_derivation_path) { m_device_derivation_path = device_derivation_path; } |
| 1490 |
const ExportFormat & export_format() const { return m_export_format; } |
| 1491 |
inline void set_export_format(const ExportFormat& export_format) { m_export_format = export_format; } |
| 1492 |
bool load_deprecated_formats() const { return m_load_deprecated_formats; } |
| 1493 |
void load_deprecated_formats(bool load) { m_load_deprecated_formats = load; } |
| 1494 |
bool persistent_rpc_client_id() const { return m_persistent_rpc_client_id; } |
| 1495 |
void persistent_rpc_client_id(bool persistent) { m_persistent_rpc_client_id = persistent; } |
| 1496 |
void auto_mine_for_rpc_payment_threshold(float threshold) { m_auto_mine_for_rpc_payment_threshold = threshold; } |
| 1497 |
float auto_mine_for_rpc_payment_threshold() const { return m_auto_mine_for_rpc_payment_threshold; } |
| 1498 |
crypto::secret_key get_rpc_client_secret_key() const { return m_rpc_client_secret_key; } |
| 1499 |
void set_rpc_client_secret_key(const crypto::secret_key &key) { m_rpc_client_secret_key = key; m_node_rpc_proxy.set_client_secret_key(key); } |
| 1500 |
uint64_t credits_target() const { return m_credits_target; } |
| 1501 |
void credits_target(uint64_t threshold) { m_credits_target = threshold; } |
| 1502 |
bool is_multisig_enabled() const { return m_enable_multisig; } |
| 1503 |
void enable_multisig(bool enable) { m_enable_multisig = enable; } |
| 1504 |
bool is_mismatched_daemon_version_allowed() const { return m_allow_mismatched_daemon_version; } |
| 1505 |
void allow_mismatched_daemon_version(bool allow_mismatch) { m_allow_mismatched_daemon_version = allow_mismatch; } |
| 1506 |
|
| 1507 |
bool get_tx_key_cached(const crypto::hash &txid, crypto::secret_key &tx_key, std::vector<crypto::secret_key> &additional_tx_keys) const; |
| 1508 |
void set_tx_key(const crypto::hash &txid, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, const boost::optional<cryptonote::account_public_address> &single_destination_subaddress = boost::none); |
| 1509 |
bool get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key, std::vector<crypto::secret_key> &additional_tx_keys); |
| 1510 |
void check_tx_key(const crypto::hash &txid, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, const cryptonote::account_public_address &address, uint64_t &received, bool &in_pool, uint64_t &confirmations); |
| 1511 |
void check_tx_key_helper(const crypto::hash &txid, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, const cryptonote::account_public_address &address, uint64_t &received, bool &in_pool, uint64_t &confirmations); |
| 1512 |
void check_tx_key_helper(const cryptonote::transaction &tx, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, const cryptonote::account_public_address &address, uint64_t &received) const; |
| 1513 |
bool is_out_to_acc(const cryptonote::account_public_address &address, const crypto::public_key& out_key, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, const size_t output_index, const boost::optional<crypto::view_tag> &view_tag_opt, crypto::key_derivation &found_derivation) const; |
| 1514 |
std::string get_tx_proof(const crypto::hash &txid, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message); |
| 1515 |
std::string get_tx_proof(const cryptonote::transaction &tx, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message) const; |
| 1516 |
bool check_tx_proof(const crypto::hash &txid, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message, const std::string &sig_str, uint64_t &received, bool &in_pool, uint64_t &confirmations); |
| 1517 |
bool check_tx_proof(const cryptonote::transaction &tx, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message, const std::string &sig_str, uint64_t &received) const; |
| 1518 |
|
| 1519 |
std::string get_spend_proof(const crypto::hash &txid, const std::string &message); |
| 1520 |
bool check_spend_proof(const crypto::hash &txid, const std::string &message, const std::string &sig_str); |
| 1521 |
|
| 1522 |
void scan_tx(const std::unordered_set<crypto::hash> &txids); |
| 1523 |
|
| 1524 |
|
| 1525 |
|
| 1526 |
|
| 1527 |
|
| 1528 |
|
| 1529 |
|
| 1530 |
|
| 1531 |
std::string get_reserve_proof(const boost::optional<std::pair<uint32_t, uint64_t>> &account_minreserve, const std::string &message); |
| 1532 |
|
| 1533 |
|
| 1534 |
|
| 1535 |
|
| 1536 |
|
| 1537 |
|
| 1538 |
|
| 1539 |
|
| 1540 |
|
| 1541 |
bool check_reserve_proof(const cryptonote::account_public_address &address, const std::string &message, const std::string &sig_str, uint64_t &total, uint64_t &spent); |
| 1542 |
|
| 1543 |
|
| 1544 |
|
| 1545 |
|
| 1546 |
std::vector<address_book_row> get_address_book() const { return m_address_book; } |
| 1547 |
bool add_address_book_row(const cryptonote::account_public_address &address, const crypto::hash8 *payment_id, const std::string &description, bool is_subaddress); |
| 1548 |
bool set_address_book_row(size_t row_id, const cryptonote::account_public_address &address, const crypto::hash8 *payment_id, const std::string &description, bool is_subaddress); |
| 1549 |
bool delete_address_book_row(std::size_t row_id); |
| 1550 |
|
| 1551 |
uint64_t get_num_rct_outputs(); |
| 1552 |
size_t get_num_transfer_details() const { return m_transfers.size(); } |
| 1553 |
const transfer_details &get_transfer_details(size_t idx) const; |
| 1554 |
|
| 1555 |
uint8_t get_current_hard_fork(); |
| 1556 |
void get_hard_fork_info(uint8_t version, uint64_t &earliest_height); |
| 1557 |
bool use_fork_rules(uint8_t version, int64_t early_blocks = 0); |
| 1558 |
int get_fee_algorithm(); |
| 1559 |
|
| 1560 |
std::string get_wallet_file() const; |
| 1561 |
std::string get_keys_file() const; |
| 1562 |
std::string get_daemon_address() const; |
| 1563 |
const boost::optional<epee::net_utils::http::login>& get_daemon_login() const { return m_daemon_login; } |
| 1564 |
std::string get_daemon_proxy() const { return m_proxy; } |
| 1565 |
uint64_t get_daemon_blockchain_height(std::string& err); |
| 1566 |
uint64_t get_daemon_blockchain_target_height(std::string& err); |
| 1567 |
uint64_t get_daemon_adjusted_time(); |
| 1568 |
|
| 1569 |
|
| 1570 |
|
| 1571 |
|
| 1572 |
uint64_t get_approximate_blockchain_height() const; |
| 1573 |
uint64_t estimate_blockchain_height(); |
| 1574 |
std::vector<size_t> select_available_outputs_from_histogram(uint64_t count, bool atleast, bool unlocked, bool allow_rct); |
| 1575 |
std::vector<size_t> select_available_outputs(const std::function<bool(const transfer_details &td)> &f); |
| 1576 |
std::vector<size_t> select_available_unmixable_outputs(); |
| 1577 |
std::vector<size_t> select_available_mixable_outputs(); |
| 1578 |
|
| 1579 |
size_t pop_best_value_from(const transfer_container &transfers, std::vector<size_t> &unused_dust_indices, const std::vector<size_t>& selected_transfers, bool smallest = false) const; |
| 1580 |
size_t pop_best_value(std::vector<size_t> &unused_dust_indices, const std::vector<size_t>& selected_transfers, bool smallest = false) const; |
| 1581 |
|
| 1582 |
void set_tx_note(const crypto::hash &txid, const std::string ¬e); |
| 1583 |
std::string get_tx_note(const crypto::hash &txid) const; |
| 1584 |
|
| 1585 |
void set_tx_device_aux(const crypto::hash &txid, const std::string &aux); |
| 1586 |
std::string get_tx_device_aux(const crypto::hash &txid) const; |
| 1587 |
|
| 1588 |
void set_description(const std::string &description); |
| 1589 |
std::string get_description() const; |
| 1590 |
|
| 1591 |
|
| 1592 |
|
| 1593 |
|
| 1594 |
|
| 1595 |
const std::pair<serializable_map<std::string, std::string>, std::vector<std::string>>& get_account_tags(); |
| 1596 |
|
| 1597 |
|
| 1598 |
|
| 1599 |
|
| 1600 |
|
| 1601 |
void set_account_tag(const std::set<uint32_t> &account_indices, const std::string& tag); |
| 1602 |
|
| 1603 |
|
| 1604 |
|
| 1605 |
|
| 1606 |
|
| 1607 |
void set_account_tag_description(const std::string& tag, const std::string& description); |
| 1608 |
|
| 1609 |
enum message_signature_type_t { sign_with_spend_key, sign_with_view_key }; |
| 1610 |
std::string sign(const std::string &data, message_signature_type_t signature_type, cryptonote::subaddress_index index = {0, 0}) const; |
| 1611 |
struct message_signature_result_t { bool valid; unsigned version; bool old; message_signature_type_t type; }; |
| 1612 |
message_signature_result_t verify(const std::string &data, const cryptonote::account_public_address &address, const std::string &signature) const; |
| 1613 |
|
| 1614 |
|
| 1615 |
|
| 1616 |
|
| 1617 |
|
| 1618 |
|
| 1619 |
|
| 1620 |
std::string sign_multisig_participant(const std::string& data) const; |
| 1621 |
|
| 1622 |
|
| 1623 |
|
| 1624 |
|
| 1625 |
|
| 1626 |
|
| 1627 |
|
| 1628 |
bool verify_with_public_key(const std::string &data, const crypto::public_key &public_key, const std::string &signature) const; |
| 1629 |
|
| 1630 |
|
| 1631 |
std::tuple<uint64_t, uint64_t, std::vector<tools::wallet2::exported_transfer_details>> export_outputs(bool all = false, uint32_t start = 0, uint32_t count = 0xffffffff) const; |
| 1632 |
std::string export_outputs_to_str(bool all = false, uint32_t start = 0, uint32_t count = 0xffffffff) const; |
| 1633 |
size_t import_outputs(const std::tuple<uint64_t, uint64_t, std::vector<tools::wallet2::exported_transfer_details>> &outputs); |
| 1634 |
size_t import_outputs(const std::tuple<uint64_t, uint64_t, std::vector<tools::wallet2::transfer_details>> &outputs); |
| 1635 |
size_t import_outputs_from_str(const std::string &outputs_st); |
| 1636 |
payment_container export_payments() const; |
| 1637 |
void import_payments(const payment_container &payments); |
| 1638 |
void import_payments_out(const std::list<std::pair<crypto::hash,wallet2::confirmed_transfer_details>> &confirmed_payments); |
| 1639 |
std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> export_blockchain() const; |
| 1640 |
void import_blockchain(const std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> &bc); |
| 1641 |
bool export_key_images(const std::string &filename, bool all = false) const; |
| 1642 |
std::pair<uint64_t, std::vector<std::pair<crypto::key_image, crypto::signature>>> export_key_images(bool all = false) const; |
| 1643 |
uint64_t import_key_images(const std::vector<std::pair<crypto::key_image, crypto::signature>> &signed_key_images, size_t offset, uint64_t &spent, uint64_t &unspent, bool check_spent = true); |
| 1644 |
uint64_t import_key_images(const std::string &filename, uint64_t &spent, uint64_t &unspent); |
| 1645 |
bool import_key_images(std::vector<crypto::key_image> key_images, size_t offset=0, boost::optional<std::unordered_set<size_t>> selected_transfers=boost::none); |
| 1646 |
bool import_key_images(signed_tx_set & signed_tx, size_t offset=0, bool only_selected_transfers=false); |
| 1647 |
crypto::public_key get_tx_pub_key_from_received_outs(const tools::wallet2::transfer_details &td) const; |
| 1648 |
|
| 1649 |
void update_pool_state(std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> &process_txs, bool refreshed = false, bool try_incremental = false); |
| 1650 |
void process_pool_state(const std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> &txs); |
| 1651 |
void remove_obsolete_pool_txs(const std::vector<crypto::hash> &tx_hashes, bool remove_if_found); |
| 1652 |
|
| 1653 |
std::string encrypt(const char *plaintext, size_t len, const crypto::secret_key &skey, bool authenticated = true) const; |
| 1654 |
std::string encrypt(const epee::span<char> &span, const crypto::secret_key &skey, bool authenticated = true) const; |
| 1655 |
std::string encrypt(const std::string &plaintext, const crypto::secret_key &skey, bool authenticated = true) const; |
| 1656 |
std::string encrypt(const epee::wipeable_string &plaintext, const crypto::secret_key &skey, bool authenticated = true) const; |
| 1657 |
std::string encrypt_with_view_secret_key(const std::string &plaintext, bool authenticated = true) const; |
| 1658 |
template<typename T=std::string> T decrypt(const std::string &ciphertext, const crypto::secret_key &skey, bool authenticated = true) const; |
| 1659 |
std::string decrypt_with_view_secret_key(const std::string &ciphertext, bool authenticated = true) const; |
| 1660 |
|
| 1661 |
std::string make_uri(const std::string &address, const std::string &payment_id, uint64_t amount, const std::string &tx_description, const std::string &recipient_name, std::string &error) const; |
| 1662 |
bool parse_uri(const std::string &uri, std::string &address, std::string &payment_id, uint64_t &amount, std::string &tx_description, std::string &recipient_name, std::vector<std::string> &unknown_parameters, std::string &error); |
| 1663 |
|
| 1664 |
uint64_t get_blockchain_height_by_date(uint16_t year, uint8_t month, uint8_t day); |
| 1665 |
|
| 1666 |
bool is_synced(); |
| 1667 |
|
| 1668 |
std::vector<std::pair<uint64_t, uint64_t>> estimate_backlog(const std::vector<std::pair<double, double>> &fee_levels); |
| 1669 |
std::vector<std::pair<uint64_t, uint64_t>> estimate_backlog(uint64_t min_tx_weight, uint64_t max_tx_weight, const std::vector<uint64_t> &fees); |
| 1670 |
|
| 1671 |
static uint64_t estimate_fee(bool use_per_byte_fee, bool use_rct, int n_inputs, int mixin, int n_outputs, size_t extra_size, bool bulletproof, bool clsag, bool bulletproof_plus, bool use_view_tags, uint64_t base_fee, uint64_t fee_quantization_mask); |
| 1672 |
uint64_t get_fee_multiplier(uint32_t priority, int fee_algorithm = -1); |
| 1673 |
uint64_t get_base_fee(uint32_t priority); |
| 1674 |
uint64_t get_base_fee(); |
| 1675 |
uint64_t get_fee_quantization_mask(); |
| 1676 |
uint64_t get_min_ring_size(); |
| 1677 |
uint64_t get_max_ring_size(); |
| 1678 |
uint64_t adjust_mixin(uint64_t mixin); |
| 1679 |
|
| 1680 |
uint32_t adjust_priority(uint32_t priority); |
| 1681 |
|
| 1682 |
bool is_unattended() const { return m_unattended; } |
| 1683 |
|
| 1684 |
std::pair<size_t, uint64_t> estimate_tx_size_and_weight(bool use_rct, int n_inputs, int ring_size, int n_outputs, size_t extra_size); |
| 1685 |
|
| 1686 |
bool get_rpc_payment_info(bool mining, bool &payment_required, uint64_t &credits, uint64_t &diff, uint64_t &credits_per_hash_found, cryptonote::blobdata &hashing_blob, uint64_t &height, uint64_t &seed_height, crypto::hash &seed_hash, crypto::hash &next_seed_hash, uint32_t &cookie); |
| 1687 |
bool daemon_requires_payment(); |
| 1688 |
bool make_rpc_payment(uint32_t nonce, uint32_t cookie, uint64_t &credits, uint64_t &balance); |
| 1689 |
bool search_for_rpc_payment(uint64_t credits_target, uint32_t n_threads, const std::function<bool(uint64_t, uint64_t)> &startfunc, const std::function<bool(unsigned)> &contfunc, const std::function<bool(uint64_t)> &foundfunc = NULL, const std::function<void(const std::string&)> &errorfunc = NULL); |
| 1690 |
template<typename T> void handle_payment_changes(const T &res, std::true_type) { |
| 1691 |
if (res.status == CORE_RPC_STATUS_OK || res.status == CORE_RPC_STATUS_PAYMENT_REQUIRED) |
| 1692 |
m_rpc_payment_state.credits = res.credits; |
| 1693 |
if (res.top_hash != m_rpc_payment_state.top_hash) |
| 1694 |
{ |
| 1695 |
m_rpc_payment_state.top_hash = res.top_hash; |
| 1696 |
m_rpc_payment_state.stale = true; |
| 1697 |
} |
| 1698 |
} |
| 1699 |
template<typename T> void handle_payment_changes(const T &res, std::false_type) {} |
| 1700 |
|
| 1701 |
|
| 1702 |
|
| 1703 |
void light_wallet_get_unspent_outs(); |
| 1704 |
|
| 1705 |
void light_wallet_get_address_txs(); |
| 1706 |
|
| 1707 |
bool light_wallet_get_address_info(tools::COMMAND_RPC_GET_ADDRESS_INFO::response &response); |
| 1708 |
|
| 1709 |
bool light_wallet_login(bool &new_address); |
| 1710 |
|
| 1711 |
bool light_wallet_import_wallet_request(tools::COMMAND_RPC_IMPORT_WALLET_REQUEST::response &response); |
| 1712 |
|
| 1713 |
void light_wallet_get_outs(std::vector<std::vector<get_outs_entry>> &outs, const std::vector<size_t> &selected_transfers, size_t fake_outputs_count); |
| 1714 |
|
| 1715 |
bool light_wallet_parse_rct_str(const std::string& rct_string, const crypto::public_key& tx_pub_key, uint64_t internal_output_index, rct::key& decrypted_mask, rct::key& rct_commit, bool decrypt) const; |
| 1716 |
|
| 1717 |
bool light_wallet_key_image_is_ours(const crypto::key_image& key_image, const crypto::public_key& tx_public_key, uint64_t out_index); |
| 1718 |
|
| 1719 |
|
| 1720 |
|
| 1721 |
|
| 1722 |
|
| 1723 |
|
| 1724 |
|
| 1725 |
|
| 1726 |
|
| 1727 |
|
| 1728 |
|
| 1729 |
|
| 1730 |
|
| 1731 |
|
| 1732 |
|
| 1733 |
|
| 1734 |
const char* const ATTRIBUTE_DESCRIPTION = "wallet2.description"; |
| 1735 |
void set_attribute(const std::string &key, const std::string &value); |
| 1736 |
bool get_attribute(const std::string &key, std::string &value) const; |
| 1737 |
|
| 1738 |
crypto::public_key get_multisig_signer_public_key() const; |
| 1739 |
crypto::public_key get_multisig_signing_public_key(size_t idx) const; |
| 1740 |
crypto::public_key get_multisig_signing_public_key(const crypto::secret_key &skey) const; |
| 1741 |
|
| 1742 |
template<class t_request, class t_response> |
| 1743 |
inline bool invoke_http_json(const boost::string_ref uri, const t_request& req, t_response& res, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "POST") |
| 1744 |
{ |
| 1745 |
if (m_offline) return false; |
| 1746 |
boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex); |
| 1747 |
return epee::net_utils::invoke_http_json(uri, req, res, *m_http_client, timeout, http_method); |
| 1748 |
} |
| 1749 |
template<class t_request, class t_response> |
| 1750 |
inline bool invoke_http_bin(const boost::string_ref uri, const t_request& req, t_response& res, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "POST") |
| 1751 |
{ |
| 1752 |
if (m_offline) return false; |
| 1753 |
boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex); |
| 1754 |
return epee::net_utils::invoke_http_bin(uri, req, res, *m_http_client, timeout, http_method); |
| 1755 |
} |
| 1756 |
template<class t_request, class t_response> |
| 1757 |
inline bool invoke_http_json_rpc(const boost::string_ref uri, const std::string& method_name, const t_request& req, t_response& res, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "POST", const std::string& req_id = "0") |
| 1758 |
{ |
| 1759 |
if (m_offline) return false; |
| 1760 |
boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex); |
| 1761 |
return epee::net_utils::invoke_http_json_rpc(uri, method_name, req, res, *m_http_client, timeout, http_method, req_id); |
| 1762 |
} |
| 1763 |
|
| 1764 |
bool set_ring_database(const std::string &filename); |
| 1765 |
const std::string get_ring_database() const { return m_ring_database; } |
| 1766 |
bool get_ring(const crypto::key_image &key_image, std::vector<uint64_t> &outs); |
| 1767 |
bool get_rings(const crypto::hash &txid, std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> &outs); |
| 1768 |
bool get_rings(const crypto::chacha_key &key, const std::vector<crypto::key_image> &key_images, std::vector<std::vector<uint64_t>> &outs); |
| 1769 |
bool set_ring(const crypto::key_image &key_image, const std::vector<uint64_t> &outs, bool relative); |
| 1770 |
bool set_rings(const std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> &rings, bool relative); |
| 1771 |
bool unset_ring(const std::vector<crypto::key_image> &key_images); |
| 1772 |
bool unset_ring(const crypto::hash &txid); |
| 1773 |
[[deprecated]] bool find_and_save_rings(bool force = true); |
| 1774 |
|
| 1775 |
bool blackball_output(const std::pair<uint64_t, uint64_t> &output); |
| 1776 |
bool set_blackballed_outputs(const std::vector<std::pair<uint64_t, uint64_t>> &outputs, bool add = false); |
| 1777 |
bool unblackball_output(const std::pair<uint64_t, uint64_t> &output); |
| 1778 |
bool is_output_blackballed(const std::pair<uint64_t, uint64_t> &output) const; |
| 1779 |
|
| 1780 |
void freeze(size_t idx); |
| 1781 |
void thaw(size_t idx); |
| 1782 |
bool frozen(size_t idx) const; |
| 1783 |
void freeze(const crypto::key_image &ki); |
| 1784 |
void thaw(const crypto::key_image &ki); |
| 1785 |
bool frozen(const crypto::key_image &ki) const; |
| 1786 |
bool frozen(const transfer_details &td) const; |
| 1787 |
bool frozen(const multisig_tx_set& txs) const; |
| 1788 |
|
| 1789 |
bool save_to_file(const std::string& path_to_file, const std::string& binary, bool is_printable = false) const; |
| 1790 |
static bool load_from_file(const std::string& path_to_file, std::string& target_str, size_t max_size = 1000000000); |
| 1791 |
|
| 1792 |
uint64_t get_bytes_sent() const; |
| 1793 |
uint64_t get_bytes_received() const; |
| 1794 |
|
| 1795 |
void start_background_sync(); |
| 1796 |
void stop_background_sync(const epee::wipeable_string &wallet_password, const crypto::secret_key &spend_secret_key = crypto::null_skey); |
| 1797 |
|
| 1798 |
|
| 1799 |
mms::message_store& get_message_store() { return m_message_store; }; |
| 1800 |
const mms::message_store& get_message_store() const { return m_message_store; }; |
| 1801 |
mms::multisig_wallet_state get_multisig_wallet_state() const; |
| 1802 |
|
| 1803 |
bool lock_keys_file(); |
| 1804 |
bool unlock_keys_file(); |
| 1805 |
bool is_keys_file_locked() const; |
| 1806 |
|
| 1807 |
void change_password(const std::string &filename, const epee::wipeable_string &original_password, const epee::wipeable_string &new_password); |
| 1808 |
|
| 1809 |
void set_tx_notify(const std::shared_ptr<tools::Notify> ¬ify) { m_tx_notify = notify; } |
| 1810 |
|
| 1811 |
bool is_tx_spendtime_unlocked(uint64_t unlock_time, uint64_t block_height); |
| 1812 |
void hash_m_transfer(const transfer_details & transfer, crypto::hash &hash) const; |
| 1813 |
uint64_t hash_m_transfers(boost::optional<uint64_t> transfer_height, crypto::hash &hash) const; |
| 1814 |
void finish_rescan_bc_keep_key_images(uint64_t transfer_height, const crypto::hash &hash); |
| 1815 |
void enable_dns(bool enable) { m_use_dns = enable; } |
| 1816 |
void set_offline(bool offline = true); |
| 1817 |
bool is_offline() const { return m_offline; } |
| 1818 |
|
| 1819 |
uint64_t credits() const { return m_rpc_payment_state.credits; } |
| 1820 |
void credit_report(uint64_t &expected_spent, uint64_t &discrepancy) const { expected_spent = m_rpc_payment_state.expected_spent; discrepancy = m_rpc_payment_state.discrepancy; } |
| 1821 |
|
| 1822 |
static std::string get_default_daemon_address() { CRITICAL_REGION_LOCAL(default_daemon_address_lock); return default_daemon_address; } |
| 1823 |
|
| 1824 |
private: |
| 1825 |
|
| 1826 |
|
| 1827 |
|
| 1828 |
|
| 1829 |
|
| 1830 |
|
| 1831 |
|
| 1832 |
bool store_keys(const std::string& keys_file_name, const epee::wipeable_string& password, bool watch_only = false); |
| 1833 |
bool store_keys(const std::string& keys_file_name, const crypto::chacha_key& key, bool watch_only = false, bool background_keys_file = false); |
| 1834 |
boost::optional<wallet2::keys_file_data> get_keys_file_data(const crypto::chacha_key& key, bool watch_only = false, bool background_keys_file = false); |
| 1835 |
bool store_keys_file_data(const std::string& keys_file_name, wallet2::keys_file_data &keys_file_data, bool background_keys_file = false); |
| 1836 |
|
| 1837 |
|
| 1838 |
|
| 1839 |
|
| 1840 |
|
| 1841 |
bool load_keys(const std::string& keys_file_name, const epee::wipeable_string& password); |
| 1842 |
|
| 1843 |
|
| 1844 |
|
| 1845 |
|
| 1846 |
|
| 1847 |
bool load_keys_buf(const std::string& keys_buf, const epee::wipeable_string& password); |
| 1848 |
bool load_keys_buf(const std::string& keys_buf, const epee::wipeable_string& password, boost::optional<crypto::chacha_key>& keys_to_encrypt); |
| 1849 |
void load_wallet_cache(const bool use_fs, const std::string& cache_buf = ""); |
| 1850 |
void process_new_transaction(const crypto::hash &txid, const cryptonote::transaction& tx, const std::vector<uint64_t> &o_indices, uint64_t height, uint8_t block_version, uint64_t ts, bool miner_tx, bool pool, bool double_spend_seen, const tx_cache_data &tx_cache_data, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL, bool ignore_callbacks = false); |
| 1851 |
bool should_skip_block(const cryptonote::block &b, uint64_t height) const; |
| 1852 |
void process_new_blockchain_entry(const cryptonote::block& b, const cryptonote::block_complete_entry& bche, const parsed_block &parsed_block, const crypto::hash& bl_id, uint64_t height, const std::vector<tx_cache_data> &tx_cache_data, size_t tx_cache_data_offset, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL); |
| 1853 |
detached_blockchain_data detach_blockchain(uint64_t height, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL); |
| 1854 |
void handle_reorg(uint64_t height, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL); |
| 1855 |
void get_short_chain_history(std::list<crypto::hash>& ids, uint64_t granularity = 1) const; |
| 1856 |
bool clear(); |
| 1857 |
void clear_soft(bool keep_key_images=false); |
| 1858 |
|
| 1859 |
|
| 1860 |
|
| 1861 |
|
| 1862 |
|
| 1863 |
|
| 1864 |
|
| 1865 |
|
| 1866 |
void clear_user_data(); |
| 1867 |
void pull_blocks(bool first, bool try_incremental, uint64_t start_height, uint64_t& blocks_start_height, const std::list<crypto::hash> &short_chain_history, std::vector<cryptonote::block_complete_entry> &blocks, std::vector<cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices> &o_indices, uint64_t ¤t_height); |
| 1868 |
void pull_hashes(uint64_t start_height, uint64_t& blocks_start_height, const std::list<crypto::hash> &short_chain_history, std::vector<crypto::hash> &hashes); |
| 1869 |
void fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height, std::list<crypto::hash> &short_chain_history, bool force = false); |
| 1870 |
void pull_and_parse_next_blocks(bool first, bool try_incremental, uint64_t start_height, uint64_t &blocks_start_height, std::list<crypto::hash> &short_chain_history, const std::vector<cryptonote::block_complete_entry> &prev_blocks, const std::vector<parsed_block> &prev_parsed_blocks, std::vector<cryptonote::block_complete_entry> &blocks, std::vector<parsed_block> &parsed_blocks, bool &last, bool &error, std::exception_ptr &exception); |
| 1871 |
void process_parsed_blocks(uint64_t start_height, const std::vector<cryptonote::block_complete_entry> &blocks, const std::vector<parsed_block> &parsed_blocks, uint64_t& blocks_added, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL); |
| 1872 |
bool accept_pool_tx_for_processing(const crypto::hash &txid); |
| 1873 |
void process_unconfirmed_transfer(bool incremental, const crypto::hash &txid, wallet2::unconfirmed_transfer_details &tx_details, bool seen_in_pool, std::chrono::system_clock::time_point now, bool refreshed); |
| 1874 |
void process_pool_info_extent(const cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::response &res, std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> &process_txs, bool refreshed); |
| 1875 |
void update_pool_state_by_pool_query(std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> &process_txs, bool refreshed = false); |
| 1876 |
void update_pool_state_from_pool_data(bool incremental, const std::vector<crypto::hash> &removed_pool_txids, const std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> &added_pool_txs, std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> &process_txs, bool refreshed); |
| 1877 |
uint64_t select_transfers(uint64_t needed_money, std::vector<size_t> unused_transfers_indices, std::vector<size_t>& selected_transfers) const; |
| 1878 |
bool prepare_file_names(const std::string& file_path); |
| 1879 |
void process_unconfirmed(const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t height); |
| 1880 |
void process_outgoing(const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t height, uint64_t ts, uint64_t spent, uint64_t received, uint32_t subaddr_account, const std::set<uint32_t>& subaddr_indices); |
| 1881 |
void add_unconfirmed_tx(const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount_in, const std::vector<cryptonote::tx_destination_entry> &dests, const crypto::hash &payment_id, uint64_t change_amount, uint32_t subaddr_account, const std::set<uint32_t>& subaddr_indices); |
| 1882 |
void generate_genesis(cryptonote::block& b) const; |
| 1883 |
void check_genesis(const crypto::hash& genesis_hash) const; |
| 1884 |
bool generate_chacha_key_from_secret_keys(crypto::chacha_key &key) const; |
| 1885 |
void generate_chacha_key_from_password(const epee::wipeable_string &pass, crypto::chacha_key &key) const; |
| 1886 |
crypto::hash get_payment_id(const pending_tx &ptx) const; |
| 1887 |
void check_acc_out_precomp(const cryptonote::tx_out &o, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, size_t i, tx_scan_info_t &tx_scan_info) const; |
| 1888 |
void check_acc_out_precomp(const cryptonote::tx_out &o, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, size_t i, const is_out_data *is_out_data, tx_scan_info_t &tx_scan_info) const; |
| 1889 |
void check_acc_out_precomp_once(const cryptonote::tx_out &o, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, size_t i, const is_out_data *is_out_data, tx_scan_info_t &tx_scan_info, bool &already_seen) const; |
| 1890 |
void parse_block_round(const cryptonote::blobdata &blob, cryptonote::block &bl, crypto::hash &bl_id, bool &error) const; |
| 1891 |
uint64_t get_upper_transaction_weight_limit(); |
| 1892 |
std::vector<uint64_t> get_unspent_amounts_vector(bool strict); |
| 1893 |
uint64_t get_dynamic_base_fee_estimate(); |
| 1894 |
float get_output_relatedness(const transfer_details &td0, const transfer_details &td1) const; |
| 1895 |
std::vector<size_t> pick_preferred_rct_inputs(uint64_t needed_money, uint32_t subaddr_account, const std::set<uint32_t> &subaddr_indices); |
| 1896 |
void set_spent(size_t idx, uint64_t height); |
| 1897 |
void set_unspent(size_t idx); |
| 1898 |
bool is_spent(const transfer_details &td, bool strict = true) const; |
| 1899 |
bool is_spent(size_t idx, bool strict = true) const; |
| 1900 |
void get_outs(std::vector<std::vector<get_outs_entry>> &outs, const std::vector<size_t> &selected_transfers, size_t fake_outputs_count, bool rct, std::unordered_set<crypto::public_key> &valid_public_keys_cache); |
| 1901 |
void get_outs(std::vector<std::vector<get_outs_entry>> &outs, const std::vector<size_t> &selected_transfers, size_t fake_outputs_count, std::vector<uint64_t> &rct_offsets, std::unordered_set<crypto::public_key> &valid_public_keys_cache); |
| 1902 |
bool tx_add_fake_output(std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs, uint64_t global_index, const crypto::public_key& tx_public_key, const rct::key& mask, uint64_t real_index, bool unlocked, std::unordered_set<crypto::public_key> &valid_public_keys_cache) const; |
| 1903 |
bool should_pick_a_second_output(bool use_rct, size_t n_transfers, const std::vector<size_t> &unused_transfers_indices, const std::vector<size_t> &unused_dust_indices) const; |
| 1904 |
std::vector<size_t> get_only_rct(const std::vector<size_t> &unused_dust_indices, const std::vector<size_t> &unused_transfers_indices) const; |
| 1905 |
void scan_output(const cryptonote::transaction &tx, bool miner_tx, const crypto::public_key &tx_pub_key, size_t i, tx_scan_info_t &tx_scan_info, int &num_vouts_received, std::unordered_map<cryptonote::subaddress_index, uint64_t> &tx_money_got_in_outs, std::vector<size_t> &outs, bool pool); |
| 1906 |
void trim_hashchain(); |
| 1907 |
crypto::key_image get_multisig_composite_key_image(size_t n) const; |
| 1908 |
rct::multisig_kLRki get_multisig_composite_kLRki(size_t n, const std::unordered_set<crypto::public_key> &ignore_set, std::unordered_set<rct::key> &used_L, std::unordered_set<rct::key> &new_used_L) const; |
| 1909 |
rct::multisig_kLRki get_multisig_kLRki(size_t n, const rct::key &k) const; |
| 1910 |
void get_multisig_k(size_t idx, const std::unordered_set<rct::key> &used_L, rct::key &nonce); |
| 1911 |
void update_multisig_rescan_info(const std::vector<std::vector<rct::key>> &multisig_k, const std::vector<std::vector<tools::wallet2::multisig_info>> &info, size_t n); |
| 1912 |
bool add_rings(const crypto::chacha_key &key, const cryptonote::transaction_prefix &tx); |
| 1913 |
bool add_rings(const cryptonote::transaction_prefix &tx); |
| 1914 |
bool remove_rings(const cryptonote::transaction_prefix &tx); |
| 1915 |
bool get_ring(const crypto::chacha_key &key, const crypto::key_image &key_image, std::vector<uint64_t> &outs); |
| 1916 |
crypto::chacha_key get_ringdb_key(); |
| 1917 |
void setup_keys(const epee::wipeable_string &password); |
| 1918 |
const crypto::chacha_key get_cache_key(); |
| 1919 |
void verify_password_with_cached_key(const epee::wipeable_string &password); |
| 1920 |
void verify_password_with_cached_key(const crypto::chacha_key &key); |
| 1921 |
size_t get_transfer_details(const crypto::key_image &ki) const; |
| 1922 |
tx_entry_data get_tx_entries(const std::unordered_set<crypto::hash> &txids); |
| 1923 |
void sort_scan_tx_entries(std::vector<process_tx_entry_t> &unsorted_tx_entries); |
| 1924 |
void process_scan_txs(const tx_entry_data &txs_to_scan, const tx_entry_data &txs_to_reprocess, const std::unordered_set<crypto::hash> &tx_hashes_to_reprocess, detached_blockchain_data &dbd); |
| 1925 |
void write_background_sync_wallet(const epee::wipeable_string &wallet_password, const epee::wipeable_string &background_cache_password); |
| 1926 |
void process_background_cache_on_open(); |
| 1927 |
void process_background_cache(const background_sync_data_t &background_sync_data, const hashchain &background_chain, uint64_t last_block_reward); |
| 1928 |
void reset_background_sync_data(background_sync_data_t &background_sync_data); |
| 1929 |
void store_background_cache(const crypto::chacha_key &custom_background_key, const bool do_reset_background_sync_data = true); |
| 1930 |
void store_background_keys(const crypto::chacha_key &custom_background_key); |
| 1931 |
|
| 1932 |
bool lock_background_keys_file(const std::string &background_keys_file); |
| 1933 |
bool unlock_background_keys_file(); |
| 1934 |
bool is_background_keys_file_locked() const; |
| 1935 |
|
| 1936 |
void register_devices(); |
| 1937 |
hw::device& lookup_device(const std::string & device_descriptor); |
| 1938 |
|
| 1939 |
bool get_rct_distribution(uint64_t &start_height, std::vector<uint64_t> &distribution); |
| 1940 |
|
| 1941 |
uint64_t get_segregation_fork_height() const; |
| 1942 |
|
| 1943 |
void cache_tx_data(const cryptonote::transaction& tx, const crypto::hash &txid, tx_cache_data &tx_cache_data) const; |
| 1944 |
std::shared_ptr<std::map<std::pair<uint64_t, uint64_t>, size_t>> create_output_tracker_cache() const; |
| 1945 |
|
| 1946 |
void init_type(hw::device::device_type device_type); |
| 1947 |
void setup_new_blockchain(); |
| 1948 |
void create_keys_file(const std::string &wallet_, bool watch_only, const epee::wipeable_string &password, bool create_address_file); |
| 1949 |
|
| 1950 |
wallet_device_callback * get_device_callback(); |
| 1951 |
void on_device_button_request(uint64_t code); |
| 1952 |
void on_device_button_pressed(); |
| 1953 |
boost::optional<epee::wipeable_string> on_device_pin_request(); |
| 1954 |
boost::optional<epee::wipeable_string> on_device_passphrase_request(bool & on_device); |
| 1955 |
void on_device_progress(const hw::device_progress& event); |
| 1956 |
|
| 1957 |
std::string get_rpc_status(const std::string &s) const; |
| 1958 |
void throw_on_rpc_response_error(bool r, const epee::json_rpc::error &error, const std::string &status, const char *method) const; |
| 1959 |
|
| 1960 |
std::string get_client_signature() const; |
| 1961 |
void check_rpc_cost(const char *call, uint64_t post_call_credits, uint64_t pre_credits, double expected_cost); |
| 1962 |
|
| 1963 |
bool should_expand(const cryptonote::subaddress_index &index) const; |
| 1964 |
bool spends_one_of_ours(const cryptonote::transaction &tx) const; |
| 1965 |
|
| 1966 |
cryptonote::account_base m_account; |
| 1967 |
boost::optional<epee::net_utils::http::login> m_daemon_login; |
| 1968 |
std::string m_daemon_address; |
| 1969 |
std::string m_proxy; |
| 1970 |
std::string m_wallet_file; |
| 1971 |
std::string m_keys_file; |
| 1972 |
std::string m_mms_file; |
| 1973 |
const std::unique_ptr<epee::net_utils::http::abstract_http_client> m_http_client; |
| 1974 |
hashchain m_blockchain; |
| 1975 |
serializable_unordered_map<crypto::hash, unconfirmed_transfer_details> m_unconfirmed_txs; |
| 1976 |
serializable_unordered_map<crypto::hash, confirmed_transfer_details> m_confirmed_txs; |
| 1977 |
serializable_unordered_multimap<crypto::hash, pool_payment_details> m_unconfirmed_payments; |
| 1978 |
serializable_unordered_map<crypto::hash, crypto::secret_key> m_tx_keys; |
| 1979 |
cryptonote::checkpoints m_checkpoints; |
| 1980 |
serializable_unordered_map<crypto::hash, std::vector<crypto::secret_key>> m_additional_tx_keys; |
| 1981 |
|
| 1982 |
transfer_container m_transfers; |
| 1983 |
payment_container m_payments; |
| 1984 |
serializable_unordered_map<crypto::key_image, size_t> m_key_images; |
| 1985 |
serializable_unordered_map<crypto::public_key, size_t> m_pub_keys; |
| 1986 |
cryptonote::account_public_address m_account_public_address; |
| 1987 |
serializable_unordered_map<crypto::public_key, cryptonote::subaddress_index> m_subaddresses; |
| 1988 |
std::vector<std::vector<std::string>> m_subaddress_labels; |
| 1989 |
serializable_unordered_map<crypto::hash, std::string> m_tx_notes; |
| 1990 |
serializable_unordered_map<std::string, std::string> m_attributes; |
| 1991 |
std::vector<tools::wallet2::address_book_row> m_address_book; |
| 1992 |
std::pair<serializable_map<std::string, std::string>, std::vector<std::string>> m_account_tags; |
| 1993 |
uint64_t m_upper_transaction_weight_limit; |
| 1994 |
std::vector<std::vector<tools::wallet2::multisig_info>> m_multisig_rescan_info; |
| 1995 |
std::vector<std::vector<rct::key>> m_multisig_rescan_k; |
| 1996 |
serializable_unordered_map<crypto::public_key, crypto::key_image> m_cold_key_images; |
| 1997 |
|
| 1998 |
std::atomic<bool> m_run; |
| 1999 |
|
| 2000 |
boost::recursive_mutex m_daemon_rpc_mutex; |
| 2001 |
|
| 2002 |
bool m_trusted_daemon; |
| 2003 |
i_wallet2_callback* m_callback; |
| 2004 |
hw::device::device_type m_key_device_type; |
| 2005 |
cryptonote::network_type m_nettype; |
| 2006 |
uint64_t m_kdf_rounds; |
| 2007 |
std::string seed_language; |
| 2008 |
bool is_old_file_format; |
| 2009 |
bool m_watch_only; |
| 2010 |
bool m_multisig; |
| 2011 |
uint32_t m_multisig_threshold; |
| 2012 |
std::vector<crypto::public_key> m_multisig_signers; |
| 2013 |
|
| 2014 |
uint32_t m_multisig_rounds_passed; |
| 2015 |
std::vector<crypto::public_key> m_multisig_derivations; |
| 2016 |
bool m_always_confirm_transfers; |
| 2017 |
bool m_print_ring_members; |
| 2018 |
bool m_store_tx_info; |
| 2019 |
uint32_t m_default_mixin; |
| 2020 |
uint32_t m_default_priority; |
| 2021 |
RefreshType m_refresh_type; |
| 2022 |
bool m_auto_refresh; |
| 2023 |
bool m_first_refresh_done; |
| 2024 |
uint64_t m_refresh_from_block_height; |
| 2025 |
|
| 2026 |
|
| 2027 |
bool m_explicit_refresh_from_block_height; |
| 2028 |
uint64_t m_pool_info_query_time; |
| 2029 |
std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> m_process_pool_txs; |
| 2030 |
uint64_t m_skip_to_height; |
| 2031 |
|
| 2032 |
|
| 2033 |
bool m_confirm_non_default_ring_size; |
| 2034 |
AskPasswordType m_ask_password; |
| 2035 |
uint64_t m_max_reorg_depth; |
| 2036 |
uint32_t m_min_output_count; |
| 2037 |
uint64_t m_min_output_value; |
| 2038 |
bool m_merge_destinations; |
| 2039 |
bool m_confirm_backlog; |
| 2040 |
uint32_t m_confirm_backlog_threshold; |
| 2041 |
bool m_confirm_export_overwrite; |
| 2042 |
bool m_auto_low_priority; |
| 2043 |
bool m_segregate_pre_fork_outputs; |
| 2044 |
bool m_key_reuse_mitigation2; |
| 2045 |
uint64_t m_segregation_height; |
| 2046 |
bool m_ignore_fractional_outputs; |
| 2047 |
uint64_t m_ignore_outputs_above; |
| 2048 |
uint64_t m_ignore_outputs_below; |
| 2049 |
bool m_track_uses; |
| 2050 |
bool m_is_background_wallet; |
| 2051 |
BackgroundSyncType m_background_sync_type; |
| 2052 |
bool m_show_wallet_name_when_locked; |
| 2053 |
uint32_t m_inactivity_lock_timeout; |
| 2054 |
BackgroundMiningSetupType m_setup_background_mining; |
| 2055 |
bool m_persistent_rpc_client_id; |
| 2056 |
float m_auto_mine_for_rpc_payment_threshold; |
| 2057 |
bool m_is_initialized; |
| 2058 |
NodeRPCProxy m_node_rpc_proxy; |
| 2059 |
std::unordered_set<crypto::hash> m_scanned_pool_txs[2]; |
| 2060 |
size_t m_subaddress_lookahead_major, m_subaddress_lookahead_minor; |
| 2061 |
std::string m_device_name; |
| 2062 |
std::string m_device_derivation_path; |
| 2063 |
uint64_t m_device_last_key_image_sync; |
| 2064 |
bool m_use_dns; |
| 2065 |
bool m_offline; |
| 2066 |
uint32_t m_rpc_version; |
| 2067 |
crypto::secret_key m_rpc_client_secret_key; |
| 2068 |
rpc_payment_state_t m_rpc_payment_state; |
| 2069 |
uint64_t m_credits_target; |
| 2070 |
bool m_enable_multisig; |
| 2071 |
bool m_allow_mismatched_daemon_version; |
| 2072 |
|
| 2073 |
|
| 2074 |
serializable_unordered_map<crypto::hash, std::string> m_tx_device; |
| 2075 |
|
| 2076 |
|
| 2077 |
bool m_light_wallet; |
| 2078 |
uint64_t m_light_wallet_scanned_block_height; |
| 2079 |
uint64_t m_light_wallet_blockchain_height; |
| 2080 |
uint64_t m_light_wallet_per_kb_fee = FEE_PER_KB; |
| 2081 |
bool m_light_wallet_connected; |
| 2082 |
uint64_t m_light_wallet_balance; |
| 2083 |
uint64_t m_light_wallet_unlocked_balance; |
| 2084 |
|
| 2085 |
|
| 2086 |
std::unordered_map<crypto::hash, address_tx> m_light_wallet_address_txs; |
| 2087 |
|
| 2088 |
serializable_unordered_map<crypto::public_key, serializable_map<uint64_t, crypto::key_image> > m_key_image_cache; |
| 2089 |
|
| 2090 |
std::string m_ring_database; |
| 2091 |
bool m_ring_history_saved; |
| 2092 |
std::unique_ptr<ringdb> m_ringdb; |
| 2093 |
boost::optional<crypto::chacha_key> m_ringdb_key; |
| 2094 |
|
| 2095 |
uint64_t m_last_block_reward; |
| 2096 |
std::unique_ptr<tools::file_locker> m_keys_file_locker; |
| 2097 |
std::unique_ptr<tools::file_locker> m_background_keys_file_locker; |
| 2098 |
|
| 2099 |
mms::message_store m_message_store; |
| 2100 |
bool m_original_keys_available; |
| 2101 |
cryptonote::account_public_address m_original_address; |
| 2102 |
crypto::secret_key m_original_view_secret_key; |
| 2103 |
|
| 2104 |
crypto::chacha_key m_cache_key; |
| 2105 |
boost::optional<crypto::chacha_key> m_custom_background_key = boost::none; |
| 2106 |
std::shared_ptr<wallet_keys_unlocker> m_encrypt_keys_after_refresh; |
| 2107 |
|
| 2108 |
bool m_unattended; |
| 2109 |
bool m_devices_registered; |
| 2110 |
|
| 2111 |
std::shared_ptr<tools::Notify> m_tx_notify; |
| 2112 |
std::unique_ptr<wallet_device_callback> m_device_callback; |
| 2113 |
|
| 2114 |
ExportFormat m_export_format; |
| 2115 |
bool m_load_deprecated_formats; |
| 2116 |
|
| 2117 |
bool m_has_ever_refreshed_from_node; |
| 2118 |
|
| 2119 |
static boost::mutex default_daemon_address_lock; |
| 2120 |
static std::string default_daemon_address; |
| 2121 |
|
| 2122 |
bool m_background_syncing; |
| 2123 |
bool m_processing_background_cache; |
| 2124 |
background_sync_data_t m_background_sync_data; |
| 2125 |
}; |
| 2126 |
} |
| 2127 |
BOOST_CLASS_VERSION(tools::wallet2, 31) |
| 2128 |
BOOST_CLASS_VERSION(tools::wallet2::transfer_details, 12) |
| 2129 |
BOOST_CLASS_VERSION(tools::wallet2::multisig_info, 1) |
| 2130 |
BOOST_CLASS_VERSION(tools::wallet2::multisig_info::LR, 0) |
| 2131 |
BOOST_CLASS_VERSION(tools::wallet2::multisig_tx_set, 1) |
| 2132 |
BOOST_CLASS_VERSION(tools::wallet2::payment_details, 5) |
| 2133 |
BOOST_CLASS_VERSION(tools::wallet2::pool_payment_details, 1) |
| 2134 |
BOOST_CLASS_VERSION(tools::wallet2::unconfirmed_transfer_details, 8) |
| 2135 |
BOOST_CLASS_VERSION(tools::wallet2::confirmed_transfer_details, 6) |
| 2136 |
BOOST_CLASS_VERSION(tools::wallet2::address_book_row, 18) |
| 2137 |
BOOST_CLASS_VERSION(tools::wallet2::reserve_proof_entry, 0) |
| 2138 |
BOOST_CLASS_VERSION(tools::wallet2::unsigned_tx_set, 1) |
| 2139 |
BOOST_CLASS_VERSION(tools::wallet2::signed_tx_set, 1) |
| 2140 |
BOOST_CLASS_VERSION(tools::wallet2::tx_construction_data, 4) |
| 2141 |
BOOST_CLASS_VERSION(tools::wallet2::pending_tx, 3) |
| 2142 |
BOOST_CLASS_VERSION(tools::wallet2::multisig_sig, 1) |
| 2143 |
BOOST_CLASS_VERSION(tools::wallet2::background_synced_tx_t, 0) |
| 2144 |
BOOST_CLASS_VERSION(tools::wallet2::background_sync_data_t, 0) |
| 2145 |
|
| 2146 |
namespace boost |
| 2147 |
{ |
| 2148 |
namespace serialization |
| 2149 |
{ |
| 2150 |
template<class Archive, class F, class S, class T> |
| 2151 |
inline void serialize( |
| 2152 |
Archive & ar, |
| 2153 |
std::tuple<F, S, T> & t, |
| 2154 |
const unsigned int |
| 2155 |
){ |
| 2156 |
ar & boost::serialization::make_nvp("f", std::get<0>(t)); |
| 2157 |
ar & boost::serialization::make_nvp("s", std::get<1>(t)); |
| 2158 |
ar & boost::serialization::make_nvp("t", std::get<2>(t)); |
| 2159 |
} |
| 2160 |
|
| 2161 |
template <class Archive> |
| 2162 |
inline typename std::enable_if<!Archive::is_loading::value, void>::type initialize_transfer_details(Archive &a, tools::wallet2::transfer_details &x, const boost::serialization::version_type ver) |
| 2163 |
{ |
| 2164 |
} |
| 2165 |
template <class Archive> |
| 2166 |
inline typename std::enable_if<Archive::is_loading::value, void>::type initialize_transfer_details(Archive &a, tools::wallet2::transfer_details &x, const boost::serialization::version_type ver) |
| 2167 |
{ |
| 2168 |
if (ver < 1) |
| 2169 |
{ |
| 2170 |
x.m_mask = rct::identity(); |
| 2171 |
x.m_amount = x.m_tx.vout[x.m_internal_output_index].amount; |
| 2172 |
} |
| 2173 |
if (ver < 2) |
| 2174 |
{ |
| 2175 |
x.m_spent_height = 0; |
| 2176 |
} |
| 2177 |
if (ver < 4) |
| 2178 |
{ |
| 2179 |
x.m_rct = x.m_tx.vout[x.m_internal_output_index].amount == 0; |
| 2180 |
} |
| 2181 |
if (ver < 6) |
| 2182 |
{ |
| 2183 |
x.m_key_image_known = true; |
| 2184 |
} |
| 2185 |
if (ver < 7) |
| 2186 |
{ |
| 2187 |
x.m_pk_index = 0; |
| 2188 |
} |
| 2189 |
if (ver < 8) |
| 2190 |
{ |
| 2191 |
x.m_subaddr_index = {}; |
| 2192 |
} |
| 2193 |
if (ver < 9) |
| 2194 |
{ |
| 2195 |
x.m_key_image_partial = false; |
| 2196 |
x.m_multisig_k.clear(); |
| 2197 |
x.m_multisig_info.clear(); |
| 2198 |
} |
| 2199 |
if (ver < 10) |
| 2200 |
{ |
| 2201 |
x.m_key_image_request = false; |
| 2202 |
} |
| 2203 |
if (ver < 12) |
| 2204 |
{ |
| 2205 |
x.m_frozen = false; |
| 2206 |
} |
| 2207 |
} |
| 2208 |
|
| 2209 |
template <class Archive> |
| 2210 |
inline void serialize(Archive &a, tools::wallet2::transfer_details &x, const boost::serialization::version_type ver) |
| 2211 |
{ |
| 2212 |
a & x.m_block_height; |
| 2213 |
a & x.m_global_output_index; |
| 2214 |
a & x.m_internal_output_index; |
| 2215 |
if (ver < 3) |
| 2216 |
{ |
| 2217 |
cryptonote::transaction tx; |
| 2218 |
a & tx; |
| 2219 |
x.m_tx = (const cryptonote::transaction_prefix&)tx; |
| 2220 |
x.m_txid = cryptonote::get_transaction_hash(tx); |
| 2221 |
} |
| 2222 |
else |
| 2223 |
{ |
| 2224 |
a & x.m_tx; |
| 2225 |
} |
| 2226 |
a & x.m_spent; |
| 2227 |
a & x.m_key_image; |
| 2228 |
if (ver < 1) |
| 2229 |
{ |
| 2230 |
|
| 2231 |
initialize_transfer_details(a, x, ver); |
| 2232 |
return; |
| 2233 |
} |
| 2234 |
a & x.m_mask; |
| 2235 |
a & x.m_amount; |
| 2236 |
if (ver < 2) |
| 2237 |
{ |
| 2238 |
initialize_transfer_details(a, x, ver); |
| 2239 |
return; |
| 2240 |
} |
| 2241 |
a & x.m_spent_height; |
| 2242 |
if (ver < 3) |
| 2243 |
{ |
| 2244 |
initialize_transfer_details(a, x, ver); |
| 2245 |
return; |
| 2246 |
} |
| 2247 |
a & x.m_txid; |
| 2248 |
if (ver < 4) |
| 2249 |
{ |
| 2250 |
initialize_transfer_details(a, x, ver); |
| 2251 |
return; |
| 2252 |
} |
| 2253 |
a & x.m_rct; |
| 2254 |
if (ver < 5) |
| 2255 |
{ |
| 2256 |
initialize_transfer_details(a, x, ver); |
| 2257 |
return; |
| 2258 |
} |
| 2259 |
if (ver < 6) |
| 2260 |
{ |
| 2261 |
|
| 2262 |
uint8_t u; |
| 2263 |
a & u; |
| 2264 |
x.m_key_image_known = true; |
| 2265 |
return; |
| 2266 |
} |
| 2267 |
a & x.m_key_image_known; |
| 2268 |
if (ver < 7) |
| 2269 |
{ |
| 2270 |
initialize_transfer_details(a, x, ver); |
| 2271 |
return; |
| 2272 |
} |
| 2273 |
a & x.m_pk_index; |
| 2274 |
if (ver < 8) |
| 2275 |
{ |
| 2276 |
initialize_transfer_details(a, x, ver); |
| 2277 |
return; |
| 2278 |
} |
| 2279 |
a & x.m_subaddr_index; |
| 2280 |
if (ver < 9) |
| 2281 |
{ |
| 2282 |
initialize_transfer_details(a, x, ver); |
| 2283 |
return; |
| 2284 |
} |
| 2285 |
a & x.m_multisig_info; |
| 2286 |
a & x.m_multisig_k; |
| 2287 |
a & x.m_key_image_partial; |
| 2288 |
if (ver < 10) |
| 2289 |
{ |
| 2290 |
initialize_transfer_details(a, x, ver); |
| 2291 |
return; |
| 2292 |
} |
| 2293 |
a & x.m_key_image_request; |
| 2294 |
if (ver < 11) |
| 2295 |
{ |
| 2296 |
initialize_transfer_details(a, x, ver); |
| 2297 |
return; |
| 2298 |
} |
| 2299 |
a & x.m_uses; |
| 2300 |
if (ver < 12) |
| 2301 |
{ |
| 2302 |
initialize_transfer_details(a, x, ver); |
| 2303 |
return; |
| 2304 |
} |
| 2305 |
a & x.m_frozen; |
| 2306 |
} |
| 2307 |
|
| 2308 |
template <class Archive> |
| 2309 |
inline void serialize(Archive &a, tools::wallet2::multisig_info::LR &x, const boost::serialization::version_type ver) |
| 2310 |
{ |
| 2311 |
a & x.m_L; |
| 2312 |
a & x.m_R; |
| 2313 |
} |
| 2314 |
|
| 2315 |
template <class Archive> |
| 2316 |
inline void serialize(Archive &a, tools::wallet2::multisig_info &x, const boost::serialization::version_type ver) |
| 2317 |
{ |
| 2318 |
a & x.m_signer; |
| 2319 |
a & x.m_LR; |
| 2320 |
a & x.m_partial_key_images; |
| 2321 |
} |
| 2322 |
|
| 2323 |
template <class Archive> |
| 2324 |
inline void serialize(Archive &a, tools::wallet2::multisig_tx_set &x, const boost::serialization::version_type ver) |
| 2325 |
{ |
| 2326 |
a & x.m_ptx; |
| 2327 |
a & x.m_signers; |
| 2328 |
} |
| 2329 |
|
| 2330 |
template <class Archive> |
| 2331 |
inline void serialize(Archive &a, tools::wallet2::unconfirmed_transfer_details &x, const boost::serialization::version_type ver) |
| 2332 |
{ |
| 2333 |
a & x.m_change; |
| 2334 |
a & x.m_sent_time; |
| 2335 |
if (ver < 5) |
| 2336 |
{ |
| 2337 |
cryptonote::transaction tx; |
| 2338 |
a & tx; |
| 2339 |
x.m_tx = (const cryptonote::transaction_prefix&)tx; |
| 2340 |
} |
| 2341 |
else |
| 2342 |
{ |
| 2343 |
a & x.m_tx; |
| 2344 |
} |
| 2345 |
if (ver < 1) |
| 2346 |
return; |
| 2347 |
a & x.m_dests; |
| 2348 |
a & x.m_payment_id; |
| 2349 |
if (ver < 2) |
| 2350 |
return; |
| 2351 |
a & x.m_state; |
| 2352 |
if (ver < 3) |
| 2353 |
return; |
| 2354 |
a & x.m_timestamp; |
| 2355 |
if (ver < 4) |
| 2356 |
return; |
| 2357 |
a & x.m_amount_in; |
| 2358 |
a & x.m_amount_out; |
| 2359 |
if (ver < 6) |
| 2360 |
{ |
| 2361 |
|
| 2362 |
|
| 2363 |
|
| 2364 |
if (!typename Archive::is_saving() && x.m_change != (uint64_t)-1) |
| 2365 |
x.m_amount_out += x.m_change; |
| 2366 |
} |
| 2367 |
if (ver < 7) |
| 2368 |
{ |
| 2369 |
x.m_subaddr_account = 0; |
| 2370 |
return; |
| 2371 |
} |
| 2372 |
a & x.m_subaddr_account; |
| 2373 |
a & x.m_subaddr_indices; |
| 2374 |
if (ver < 8) |
| 2375 |
return; |
| 2376 |
a & x.m_rings; |
| 2377 |
} |
| 2378 |
|
| 2379 |
template <class Archive> |
| 2380 |
inline void serialize(Archive &a, tools::wallet2::confirmed_transfer_details &x, const boost::serialization::version_type ver) |
| 2381 |
{ |
| 2382 |
a & x.m_amount_in; |
| 2383 |
a & x.m_amount_out; |
| 2384 |
a & x.m_change; |
| 2385 |
a & x.m_block_height; |
| 2386 |
if (ver < 1) |
| 2387 |
return; |
| 2388 |
a & x.m_dests; |
| 2389 |
a & x.m_payment_id; |
| 2390 |
if (ver < 2) |
| 2391 |
return; |
| 2392 |
a & x.m_timestamp; |
| 2393 |
if (ver < 3) |
| 2394 |
{ |
| 2395 |
|
| 2396 |
|
| 2397 |
|
| 2398 |
|
| 2399 |
|
| 2400 |
|
| 2401 |
if (!typename Archive::is_saving() && x.m_change != (uint64_t)-1) |
| 2402 |
{ |
| 2403 |
if (x.m_amount_in > (x.m_amount_out + x.m_change)) |
| 2404 |
x.m_amount_out += x.m_change; |
| 2405 |
} |
| 2406 |
} |
| 2407 |
if (ver < 4) |
| 2408 |
{ |
| 2409 |
if (!typename Archive::is_saving()) |
| 2410 |
x.m_unlock_time = 0; |
| 2411 |
return; |
| 2412 |
} |
| 2413 |
a & x.m_unlock_time; |
| 2414 |
if (ver < 5) |
| 2415 |
{ |
| 2416 |
x.m_subaddr_account = 0; |
| 2417 |
return; |
| 2418 |
} |
| 2419 |
a & x.m_subaddr_account; |
| 2420 |
a & x.m_subaddr_indices; |
| 2421 |
if (ver < 6) |
| 2422 |
return; |
| 2423 |
a & x.m_rings; |
| 2424 |
} |
| 2425 |
|
| 2426 |
template <class Archive> |
| 2427 |
inline void serialize(Archive& a, tools::wallet2::payment_details& x, const boost::serialization::version_type ver) |
| 2428 |
{ |
| 2429 |
a & x.m_tx_hash; |
| 2430 |
a & x.m_amount; |
| 2431 |
a & x.m_block_height; |
| 2432 |
a & x.m_unlock_time; |
| 2433 |
if (ver < 1) |
| 2434 |
return; |
| 2435 |
a & x.m_timestamp; |
| 2436 |
if (ver < 2) |
| 2437 |
{ |
| 2438 |
x.m_coinbase = false; |
| 2439 |
x.m_subaddr_index = {}; |
| 2440 |
return; |
| 2441 |
} |
| 2442 |
a & x.m_subaddr_index; |
| 2443 |
if (ver < 3) |
| 2444 |
{ |
| 2445 |
x.m_coinbase = false; |
| 2446 |
x.m_fee = 0; |
| 2447 |
return; |
| 2448 |
} |
| 2449 |
a & x.m_fee; |
| 2450 |
if (ver < 4) |
| 2451 |
{ |
| 2452 |
x.m_coinbase = false; |
| 2453 |
return; |
| 2454 |
} |
| 2455 |
a & x.m_coinbase; |
| 2456 |
if (ver < 5) |
| 2457 |
return; |
| 2458 |
a & x.m_amounts; |
| 2459 |
} |
| 2460 |
|
| 2461 |
template <class Archive> |
| 2462 |
inline void serialize(Archive& a, tools::wallet2::pool_payment_details& x, const boost::serialization::version_type ver) |
| 2463 |
{ |
| 2464 |
a & x.m_pd; |
| 2465 |
a & x.m_double_spend_seen; |
| 2466 |
} |
| 2467 |
|
| 2468 |
template <class Archive> |
| 2469 |
inline void serialize(Archive& a, tools::wallet2::address_book_row& x, const boost::serialization::version_type ver) |
| 2470 |
{ |
| 2471 |
a & x.m_address; |
| 2472 |
if (ver < 18) |
| 2473 |
{ |
| 2474 |
crypto::hash payment_id; |
| 2475 |
a & payment_id; |
| 2476 |
x.m_has_payment_id = !(payment_id == crypto::null_hash); |
| 2477 |
if (x.m_has_payment_id) |
| 2478 |
{ |
| 2479 |
bool is_long = false; |
| 2480 |
for (int i = 8; i < 32; ++i) |
| 2481 |
is_long |= payment_id.data[i]; |
| 2482 |
if (is_long) |
| 2483 |
{ |
| 2484 |
MWARNING("Long payment ID ignored on address book load"); |
| 2485 |
x.m_payment_id = crypto::null_hash8; |
| 2486 |
x.m_has_payment_id = false; |
| 2487 |
} |
| 2488 |
else |
| 2489 |
memcpy(x.m_payment_id.data, payment_id.data, 8); |
| 2490 |
} |
| 2491 |
} |
| 2492 |
a & x.m_description; |
| 2493 |
if (ver < 17) |
| 2494 |
{ |
| 2495 |
x.m_is_subaddress = false; |
| 2496 |
return; |
| 2497 |
} |
| 2498 |
a & x.m_is_subaddress; |
| 2499 |
if (ver < 18) |
| 2500 |
return; |
| 2501 |
a & x.m_has_payment_id; |
| 2502 |
if (x.m_has_payment_id) |
| 2503 |
a & x.m_payment_id; |
| 2504 |
} |
| 2505 |
|
| 2506 |
template <class Archive> |
| 2507 |
inline void serialize(Archive& a, tools::wallet2::reserve_proof_entry& x, const boost::serialization::version_type ver) |
| 2508 |
{ |
| 2509 |
a & x.txid; |
| 2510 |
a & x.index_in_tx; |
| 2511 |
a & x.shared_secret; |
| 2512 |
a & x.key_image; |
| 2513 |
a & x.shared_secret_sig; |
| 2514 |
a & x.key_image_sig; |
| 2515 |
} |
| 2516 |
|
| 2517 |
template <class Archive> |
| 2518 |
inline void serialize(Archive &a, tools::wallet2::unsigned_tx_set &x, const boost::serialization::version_type ver) |
| 2519 |
{ |
| 2520 |
a & x.txes; |
| 2521 |
if (ver == 0) |
| 2522 |
{ |
| 2523 |
|
| 2524 |
std::pair<size_t, tools::wallet2::transfer_container> old_transfers; |
| 2525 |
a & old_transfers; |
| 2526 |
std::get<0>(x.transfers) = std::get<0>(old_transfers); |
| 2527 |
std::get<1>(x.transfers) = std::get<0>(old_transfers) + std::get<1>(old_transfers).size(); |
| 2528 |
std::get<2>(x.transfers) = std::get<1>(old_transfers); |
| 2529 |
return; |
| 2530 |
} |
| 2531 |
throw std::runtime_error("Boost serialization not supported for newest unsigned_tx_set"); |
| 2532 |
} |
| 2533 |
|
| 2534 |
template <class Archive> |
| 2535 |
inline void serialize(Archive &a, tools::wallet2::signed_tx_set &x, const boost::serialization::version_type ver) |
| 2536 |
{ |
| 2537 |
a & x.ptx; |
| 2538 |
a & x.key_images; |
| 2539 |
if (ver < 1) |
| 2540 |
return; |
| 2541 |
a & x.tx_key_images.parent(); |
| 2542 |
} |
| 2543 |
|
| 2544 |
template <class Archive> |
| 2545 |
inline void serialize(Archive &a, tools::wallet2::tx_construction_data &x, const boost::serialization::version_type ver) |
| 2546 |
{ |
| 2547 |
a & x.sources; |
| 2548 |
a & x.change_dts; |
| 2549 |
a & x.splitted_dsts; |
| 2550 |
if (ver < 2) |
| 2551 |
{ |
| 2552 |
|
| 2553 |
std::list<size_t> selected_transfers; |
| 2554 |
a & selected_transfers; |
| 2555 |
x.selected_transfers.clear(); |
| 2556 |
x.selected_transfers.reserve(selected_transfers.size()); |
| 2557 |
for (size_t t: selected_transfers) |
| 2558 |
x.selected_transfers.push_back(t); |
| 2559 |
} |
| 2560 |
a & x.extra; |
| 2561 |
a & x.unlock_time; |
| 2562 |
a & x.use_rct; |
| 2563 |
a & x.dests; |
| 2564 |
if (ver < 1) |
| 2565 |
{ |
| 2566 |
x.subaddr_account = 0; |
| 2567 |
return; |
| 2568 |
} |
| 2569 |
a & x.subaddr_account; |
| 2570 |
a & x.subaddr_indices; |
| 2571 |
if (ver < 2) |
| 2572 |
{ |
| 2573 |
if (!typename Archive::is_saving()) |
| 2574 |
x.rct_config = { rct::RangeProofBorromean, 0 }; |
| 2575 |
return; |
| 2576 |
} |
| 2577 |
a & x.selected_transfers; |
| 2578 |
if (ver < 3) |
| 2579 |
{ |
| 2580 |
if (!typename Archive::is_saving()) |
| 2581 |
x.rct_config = { rct::RangeProofBorromean, 0 }; |
| 2582 |
return; |
| 2583 |
} |
| 2584 |
if (ver < 4) |
| 2585 |
{ |
| 2586 |
bool use_bulletproofs = x.rct_config.range_proof_type != rct::RangeProofBorromean; |
| 2587 |
a & use_bulletproofs; |
| 2588 |
if (!typename Archive::is_saving()) |
| 2589 |
x.rct_config = { use_bulletproofs ? rct::RangeProofPaddedBulletproof : rct::RangeProofBorromean, 0 }; |
| 2590 |
return; |
| 2591 |
} |
| 2592 |
a & x.rct_config; |
| 2593 |
} |
| 2594 |
|
| 2595 |
template <class Archive> |
| 2596 |
inline void serialize(Archive &a, tools::wallet2::multisig_sig &x, const boost::serialization::version_type ver) |
| 2597 |
{ |
| 2598 |
a & x.sigs; |
| 2599 |
a & x.ignore; |
| 2600 |
a & x.used_L; |
| 2601 |
a & x.signing_keys; |
| 2602 |
a & x.msout; |
| 2603 |
if (ver < 1) |
| 2604 |
return; |
| 2605 |
a & x.total_alpha_G; |
| 2606 |
a & x.total_alpha_H; |
| 2607 |
a & x.c_0; |
| 2608 |
a & x.s; |
| 2609 |
} |
| 2610 |
|
| 2611 |
template <class Archive> |
| 2612 |
inline void serialize(Archive &a, tools::wallet2::pending_tx &x, const boost::serialization::version_type ver) |
| 2613 |
{ |
| 2614 |
a & x.tx; |
| 2615 |
a & x.dust; |
| 2616 |
a & x.fee; |
| 2617 |
a & x.dust_added_to_fee; |
| 2618 |
a & x.change_dts; |
| 2619 |
if (ver < 2) |
| 2620 |
{ |
| 2621 |
|
| 2622 |
std::list<size_t> selected_transfers; |
| 2623 |
a & selected_transfers; |
| 2624 |
x.selected_transfers.clear(); |
| 2625 |
x.selected_transfers.reserve(selected_transfers.size()); |
| 2626 |
for (size_t t: selected_transfers) |
| 2627 |
x.selected_transfers.push_back(t); |
| 2628 |
} |
| 2629 |
a & x.key_images; |
| 2630 |
a & x.tx_key; |
| 2631 |
a & x.dests; |
| 2632 |
a & x.construction_data; |
| 2633 |
if (ver < 1) |
| 2634 |
return; |
| 2635 |
a & x.additional_tx_keys; |
| 2636 |
if (ver < 2) |
| 2637 |
return; |
| 2638 |
a & x.selected_transfers; |
| 2639 |
if (ver < 3) |
| 2640 |
return; |
| 2641 |
a & x.multisig_sigs; |
| 2642 |
} |
| 2643 |
|
| 2644 |
template <class Archive> |
| 2645 |
inline void serialize(Archive& a, tools::wallet2::background_synced_tx_t &x, const boost::serialization::version_type ver) |
| 2646 |
{ |
| 2647 |
a & x.index_in_background_sync_data; |
| 2648 |
a & x.tx; |
| 2649 |
a & x.output_indices; |
| 2650 |
a & x.height; |
| 2651 |
a & x.block_timestamp; |
| 2652 |
a & x.double_spend_seen; |
| 2653 |
} |
| 2654 |
|
| 2655 |
template <class Archive> |
| 2656 |
inline void serialize(Archive& a, tools::wallet2::background_sync_data_t &x, const boost::serialization::version_type ver) |
| 2657 |
{ |
| 2658 |
a & x.first_refresh_done; |
| 2659 |
a & x.start_height; |
| 2660 |
a & x.txs.parent(); |
| 2661 |
a & x.wallet_refresh_from_block_height; |
| 2662 |
a & x.subaddress_lookahead_major; |
| 2663 |
a & x.subaddress_lookahead_minor; |
| 2664 |
a & x.wallet_refresh_type; |
| 2665 |
} |
| 2666 |
} |
| 2667 |
} |
| 2668 |
|
| 2669 |
namespace tools |
| 2670 |
{ |
| 2671 |
|
| 2672 |
namespace detail |
| 2673 |
{ |
| 2674 |
|
| 2675 |
inline void digit_split_strategy(const std::vector<cryptonote::tx_destination_entry>& dsts, |
| 2676 |
const cryptonote::tx_destination_entry& change_dst, uint64_t dust_threshold, |
| 2677 |
std::vector<cryptonote::tx_destination_entry>& splitted_dsts, std::vector<cryptonote::tx_destination_entry> &dust_dsts) |
| 2678 |
{ |
| 2679 |
splitted_dsts.clear(); |
| 2680 |
dust_dsts.clear(); |
| 2681 |
|
| 2682 |
for(auto& de: dsts) |
| 2683 |
{ |
| 2684 |
cryptonote::decompose_amount_into_digits(de.amount, 0, |
| 2685 |
[&](uint64_t chunk) { splitted_dsts.push_back(cryptonote::tx_destination_entry(chunk, de.addr, de.is_subaddress)); }, |
| 2686 |
[&](uint64_t a_dust) { splitted_dsts.push_back(cryptonote::tx_destination_entry(a_dust, de.addr, de.is_subaddress)); } ); |
| 2687 |
} |
| 2688 |
|
| 2689 |
cryptonote::decompose_amount_into_digits(change_dst.amount, 0, |
| 2690 |
[&](uint64_t chunk) { |
| 2691 |
if (chunk <= dust_threshold) |
| 2692 |
dust_dsts.push_back(cryptonote::tx_destination_entry(chunk, change_dst.addr, false)); |
| 2693 |
else |
| 2694 |
splitted_dsts.push_back(cryptonote::tx_destination_entry(chunk, change_dst.addr, false)); |
| 2695 |
}, |
| 2696 |
[&](uint64_t a_dust) { dust_dsts.push_back(cryptonote::tx_destination_entry(a_dust, change_dst.addr, false)); } ); |
| 2697 |
} |
| 2698 |
|
| 2699 |
inline void null_split_strategy(const std::vector<cryptonote::tx_destination_entry>& dsts, |
| 2700 |
const cryptonote::tx_destination_entry& change_dst, uint64_t dust_threshold, |
| 2701 |
std::vector<cryptonote::tx_destination_entry>& splitted_dsts, std::vector<cryptonote::tx_destination_entry> &dust_dsts) |
| 2702 |
{ |
| 2703 |
splitted_dsts = dsts; |
| 2704 |
|
| 2705 |
dust_dsts.clear(); |
| 2706 |
uint64_t change = change_dst.amount; |
| 2707 |
|
| 2708 |
if (0 != change) |
| 2709 |
{ |
| 2710 |
splitted_dsts.push_back(cryptonote::tx_destination_entry(change, change_dst.addr, false)); |
| 2711 |
} |
| 2712 |
} |
| 2713 |
|
| 2714 |
inline void print_source_entry(const cryptonote::tx_source_entry& src) |
| 2715 |
{ |
| 2716 |
std::string indexes; |
| 2717 |
std::for_each(src.outputs.begin(), src.outputs.end(), [&](const cryptonote::tx_source_entry::output_entry& s_e) { indexes += boost::to_string(s_e.first) + " "; }); |
| 2718 |
LOG_PRINT_L0("amount=" << cryptonote::print_money(src.amount) << ", real_output=" <<src.real_output << ", real_output_in_tx_index=" << src.real_output_in_tx_index << ", indexes: " << indexes); |
| 2719 |
} |
| 2720 |
|
| 2721 |
} |
| 2722 |
|
| 2723 |
} |