Monero
wallet_errors.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2018, The Monero Project
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification, are
6 // permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice, this list of
9 // conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 // of conditions and the following disclaimer in the documentation and/or other
13 // materials provided with the distribution.
14 //
15 // 3. Neither the name of the copyright holder nor the names of its contributors may be
16 // used to endorse or promote products derived from this software without specific
17 // prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 //
29 // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
30 
31 #pragma once
32 
33 #include <stdexcept>
34 #include <system_error>
35 #include <string>
36 #include <vector>
37 
41 #include "include_base_utils.h"
42 
43 
44 namespace tools
45 {
46  namespace error
47  {
48  // std::exception
49  // std::runtime_error
50  // wallet_runtime_error *
51  // wallet_internal_error
52  // unexpected_txin_type
53  // wallet_not_initialized
54  // multisig_export_needed
55  // multisig_import_needed
56  // password_needed
57  // std::logic_error
58  // wallet_logic_error *
59  // file_exists
60  // file_not_found
61  // file_read_error
62  // file_save_error
63  // invalid_password
64  // invalid_priority
65  // invalid_multisig_seed
66  // refresh_error *
67  // acc_outs_lookup_error
68  // block_parse_error
69  // get_blocks_error
70  // get_hashes_error
71  // get_out_indexes_error
72  // tx_parse_error
73  // get_tx_pool_error
74  // out_of_hashchain_bounds_error
75  // transfer_error *
76  // get_outs_general_error
77  // not_enough_unlocked_money
78  // not_enough_money
79  // tx_not_possible
80  // not_enough_outs_to_mix
81  // tx_not_constructed
82  // tx_rejected
83  // tx_sum_overflow
84  // tx_too_big
85  // zero_destination
86  // wallet_rpc_error *
87  // daemon_busy
88  // no_connection_to_daemon
89  // is_key_image_spent_error
90  // get_histogram_error
91  // get_output_distribution
92  // wallet_files_doesnt_correspond
93  //
94  // * - class with protected ctor
95 
96  //----------------------------------------------------------------------------------------------------
97  template<typename Base>
98  struct wallet_error_base : public Base
99  {
100  const std::string& location() const { return m_loc; }
101 
102  std::string to_string() const
103  {
104  std::ostringstream ss;
105  ss << m_loc << ':' << typeid(*this).name() << ": " << Base::what();
106  return ss.str();
107  }
108 
109  protected:
110  wallet_error_base(std::string&& loc, const std::string& message)
111  : Base(message)
112  , m_loc(loc)
113  {
114  }
115 
116  private:
117  std::string m_loc;
118  };
119  //----------------------------------------------------------------------------------------------------
120  const char* const failed_rpc_request_messages[] = {
121  "failed to get blocks",
122  "failed to get hashes",
123  "failed to get out indices",
124  "failed to get random outs"
125  };
127  {
132  };
133 
134  template<typename Base, int msg_index>
135  struct failed_rpc_request : public Base
136  {
137  explicit failed_rpc_request(std::string&& loc, const std::string& status)
138  : Base(std::move(loc), failed_rpc_request_messages[msg_index])
139  , m_status(status)
140  {
141  }
142 
143  const std::string& status() const { return m_status; }
144 
145  std::string to_string() const
146  {
147  std::ostringstream ss;
148  ss << Base::to_string() << ", status = " << status();
149  return ss.str();
150  }
151 
152  private:
153  std::string m_status;
154  };
155  //----------------------------------------------------------------------------------------------------
158  //----------------------------------------------------------------------------------------------------
160  {
161  explicit wallet_internal_error(std::string&& loc, const std::string& message)
162  : wallet_runtime_error(std::move(loc), message)
163  {
164  }
165  };
166  //----------------------------------------------------------------------------------------------------
168  {
169  explicit unexpected_txin_type(std::string&& loc, const cryptonote::transaction& tx)
170  : wallet_internal_error(std::move(loc), "one of tx inputs has unexpected type")
171  , m_tx(tx)
172  {
173  }
174 
175  const cryptonote::transaction& tx() const { return m_tx; }
176 
177  std::string to_string() const
178  {
179  std::ostringstream ss;
182  return ss.str();
183  }
184 
185  private:
187  };
188  //----------------------------------------------------------------------------------------------------
190  {
191  explicit wallet_not_initialized(std::string&& loc)
192  : wallet_internal_error(std::move(loc), "wallet is not initialized")
193  {
194  }
195  };
196  //----------------------------------------------------------------------------------------------------
198  {
199  explicit multisig_export_needed(std::string&& loc)
200  : wallet_runtime_error(std::move(loc), "This signature was made with stale data: export fresh multisig data, which other participants must then use")
201  {
202  }
203  };
204  //----------------------------------------------------------------------------------------------------
206  {
207  explicit multisig_import_needed(std::string&& loc)
208  : wallet_runtime_error(std::move(loc), "Not enough multisig data was found to sign: import multisig data from more other participants")
209  {
210  }
211  };
212  //----------------------------------------------------------------------------------------------------
214  {
215  explicit password_needed(std::string&& loc, const std::string &msg = "Password needed")
216  : wallet_runtime_error(std::move(loc), msg)
217  {
218  }
219  };
220  //----------------------------------------------------------------------------------------------------
221  const char* const file_error_messages[] = {
222  "file already exists",
223  "file not found",
224  "failed to read file",
225  "failed to save file"
226  };
228  {
233  };
234 
235  template<int msg_index>
237  {
238  explicit file_error_base(std::string&& loc, const std::string& file)
239  : wallet_logic_error(std::move(loc), std::string(file_error_messages[msg_index]) + " \"" + file + '\"')
240  , m_file(file)
241  {
242  }
243 
244  explicit file_error_base(std::string&& loc, const std::string& file, const std::error_code &e)
245  : wallet_logic_error(std::move(loc), std::string(file_error_messages[msg_index]) + " \"" + file + "\": " + e.message())
246  , m_file(file)
247  {
248  }
249 
250  const std::string& file() const { return m_file; }
251 
252  std::string to_string() const { return wallet_logic_error::to_string(); }
253 
254  private:
255  std::string m_file;
256  };
257  //----------------------------------------------------------------------------------------------------
262  //----------------------------------------------------------------------------------------------------
264  {
265  explicit invalid_password(std::string&& loc)
266  : wallet_logic_error(std::move(loc), "invalid password")
267  {
268  }
269 
270  std::string to_string() const { return wallet_logic_error::to_string(); }
271  };
273  {
274  explicit invalid_priority(std::string&& loc)
275  : wallet_logic_error(std::move(loc), "invalid priority")
276  {
277  }
278 
279  std::string to_string() const { return wallet_logic_error::to_string(); }
280  };
281 
283  {
284  explicit invalid_multisig_seed(std::string&& loc)
285  : wallet_logic_error(std::move(loc), "invalid multisig seed")
286  {
287  }
288 
289  std::string to_string() const { return wallet_logic_error::to_string(); }
290  };
291 
292  //----------------------------------------------------------------------------------------------------
294  {
295  explicit invalid_pregenerated_random (std::string&& loc)
296  : wallet_logic_error(std::move(loc), "invalid pregenerated random for wallet creation/recovery")
297  {
298  }
299 
300  std::string to_string() const { return wallet_logic_error::to_string(); }
301  };
302  //----------------------------------------------------------------------------------------------------
304  {
305  protected:
306  explicit refresh_error(std::string&& loc, const std::string& message)
307  : wallet_logic_error(std::move(loc), message)
308  {
309  }
310  };
311  //----------------------------------------------------------------------------------------------------
313  {
314  explicit index_outofbound(std::string&& loc, const std::string& message)
315  : wallet_logic_error(std::move(loc), message)
316  {
317  }
318  };
320  {
321  explicit account_index_outofbound(std::string&& loc)
322  : index_outofbound(std::move(loc), "account index is out of bound")
323  {
324  }
325  };
327  {
328  explicit address_index_outofbound(std::string&& loc)
329  : index_outofbound(std::move(loc), "address index is out of bound")
330  {
331  }
332  };
333  //----------------------------------------------------------------------------------------------------
335  {
336  explicit acc_outs_lookup_error(std::string&& loc, const cryptonote::transaction& tx,
338  : refresh_error(std::move(loc), "account outs lookup error")
339  , m_tx(tx)
342  {
343  }
344 
345  const cryptonote::transaction& tx() const { return m_tx; }
346  const crypto::public_key& tx_pub_key() const { return m_tx_pub_key; }
347  const cryptonote::account_keys& acc_keys() const { return m_acc_keys; }
348 
349  std::string to_string() const
350  {
351  std::ostringstream ss;
354  return ss.str();
355  }
356 
357  private:
361  };
362  //----------------------------------------------------------------------------------------------------
364  {
365  explicit block_parse_error(std::string&& loc, const cryptonote::blobdata& block_data)
366  : refresh_error(std::move(loc), "block parse error")
367  , m_block_blob(block_data)
368  {
369  }
370 
371  const cryptonote::blobdata& block_blob() const { return m_block_blob; }
372 
373  std::string to_string() const { return refresh_error::to_string(); }
374 
375  private:
377  };
378  //----------------------------------------------------------------------------------------------------
380  //----------------------------------------------------------------------------------------------------
382  //----------------------------------------------------------------------------------------------------
384  //----------------------------------------------------------------------------------------------------
386  {
387  explicit tx_parse_error(std::string&& loc, const cryptonote::blobdata& tx_blob)
388  : refresh_error(std::move(loc), "transaction parse error")
389  , m_tx_blob(tx_blob)
390  {
391  }
392 
393  const cryptonote::blobdata& tx_blob() const { return m_tx_blob; }
394 
395  std::string to_string() const { return refresh_error::to_string(); }
396 
397  private:
399  };
400  //----------------------------------------------------------------------------------------------------
402  {
403  explicit get_tx_pool_error(std::string&& loc)
404  : refresh_error(std::move(loc), "error getting transaction pool")
405  {
406  }
407 
408  std::string to_string() const { return refresh_error::to_string(); }
409  };
410  //----------------------------------------------------------------------------------------------------
412  {
413  explicit out_of_hashchain_bounds_error(std::string&& loc)
414  : refresh_error(std::move(loc), "Index out of bounds of of hashchain")
415  {
416  }
417 
418  std::string to_string() const { return refresh_error::to_string(); }
419  };
420  //----------------------------------------------------------------------------------------------------
422  {
423  protected:
424  explicit transfer_error(std::string&& loc, const std::string& message)
425  : wallet_logic_error(std::move(loc), message)
426  {
427  }
428  };
429  //----------------------------------------------------------------------------------------------------
431  //----------------------------------------------------------------------------------------------------
433  {
434  explicit not_enough_unlocked_money(std::string&& loc, uint64_t available, uint64_t tx_amount, uint64_t fee)
435  : transfer_error(std::move(loc), "not enough unlocked money")
438  {
439  }
440 
441  uint64_t available() const { return m_available; }
442  uint64_t tx_amount() const { return m_tx_amount; }
443 
444  std::string to_string() const
445  {
446  std::ostringstream ss;
447  ss << transfer_error::to_string() <<
448  ", available = " << cryptonote::print_money(m_available) <<
449  ", tx_amount = " << cryptonote::print_money(m_tx_amount);
450  return ss.str();
451  }
452 
453  private:
454  uint64_t m_available;
455  uint64_t m_tx_amount;
456  };
457  //----------------------------------------------------------------------------------------------------
459  {
460  explicit not_enough_money(std::string&& loc, uint64_t available, uint64_t tx_amount, uint64_t fee)
461  : transfer_error(std::move(loc), "not enough money")
464  {
465  }
466 
467  uint64_t available() const { return m_available; }
468  uint64_t tx_amount() const { return m_tx_amount; }
469 
470  std::string to_string() const
471  {
472  std::ostringstream ss;
473  ss << transfer_error::to_string() <<
474  ", available = " << cryptonote::print_money(m_available) <<
475  ", tx_amount = " << cryptonote::print_money(m_tx_amount);
476  return ss.str();
477  }
478 
479  private:
480  uint64_t m_available;
481  uint64_t m_tx_amount;
482  };
483  //----------------------------------------------------------------------------------------------------
485  {
486  explicit tx_not_possible(std::string&& loc, uint64_t available, uint64_t tx_amount, uint64_t fee)
487  : transfer_error(std::move(loc), "tx not possible")
490  , m_fee(fee)
491  {
492  }
493 
494  uint64_t available() const { return m_available; }
495  uint64_t tx_amount() const { return m_tx_amount; }
496  uint64_t fee() const { return m_fee; }
497 
498  std::string to_string() const
499  {
500  std::ostringstream ss;
501  ss << transfer_error::to_string() <<
502  ", available = " << cryptonote::print_money(m_available) <<
503  ", tx_amount = " << cryptonote::print_money(m_tx_amount) <<
504  ", fee = " << cryptonote::print_money(m_fee);
505  return ss.str();
506  }
507 
508  private:
509  uint64_t m_available;
510  uint64_t m_tx_amount;
511  uint64_t m_fee;
512  };
513  //----------------------------------------------------------------------------------------------------
515  {
516  typedef std::unordered_map<uint64_t, uint64_t> scanty_outs_t;
517 
518  explicit not_enough_outs_to_mix(std::string&& loc, const scanty_outs_t& scanty_outs, size_t mixin_count)
519  : transfer_error(std::move(loc), "not enough outputs to use")
522  {
523  }
524 
525  const scanty_outs_t& scanty_outs() const { return m_scanty_outs; }
526  size_t mixin_count() const { return m_mixin_count; }
527 
528  std::string to_string() const
529  {
530  std::ostringstream ss;
531  ss << transfer_error::to_string() << ", ring size = " << (m_mixin_count + 1) << ", scanty_outs:";
532  for (const auto& out: m_scanty_outs)
533  {
534  ss << '\n' << cryptonote::print_money(out.first) << " - " << out.second;
535  }
536  return ss.str();
537  }
538 
539  private:
542  };
543  //----------------------------------------------------------------------------------------------------
545  {
546  typedef std::vector<cryptonote::tx_source_entry> sources_t;
547  typedef std::vector<cryptonote::tx_destination_entry> destinations_t;
548 
550  std::string && loc
551  , sources_t const & sources
552  , destinations_t const & destinations
553  , uint64_t unlock_time
554  , cryptonote::network_type nettype
555  )
556  : transfer_error(std::move(loc), "transaction was not constructed")
557  , m_sources(sources)
560  , m_nettype(nettype)
561  {
562  }
563 
564  const sources_t& sources() const { return m_sources; }
565  const destinations_t& destinations() const { return m_destinations; }
566  uint64_t unlock_time() const { return m_unlock_time; }
567 
568  std::string to_string() const
569  {
570  std::ostringstream ss;
572  ss << "\nSources:";
573  for (size_t i = 0; i < m_sources.size(); ++i)
574  {
575  const cryptonote::tx_source_entry& src = m_sources[i];
576  ss << "\n source " << i << ":";
577  ss << "\n amount: " << cryptonote::print_money(src.amount);
578  // It's not good, if logs will contain such much data
579  //ss << "\n real_output: " << src.real_output;
580  //ss << "\n real_output_in_tx_index: " << src.real_output_in_tx_index;
581  //ss << "\n real_out_tx_key: " << epee::string_tools::pod_to_hex(src.real_out_tx_key);
582  //ss << "\n outputs:";
583  //for (size_t j = 0; j < src.outputs.size(); ++j)
584  //{
585  // const cryptonote::tx_source_entry::output_entry& out = src.outputs[j];
586  // ss << "\n " << j << ": " << out.first << ", " << epee::string_tools::pod_to_hex(out.second);
587  //}
588  }
589 
590  ss << "\nDestinations:";
591  for (size_t i = 0; i < m_destinations.size(); ++i)
592  {
594  ss << "\n " << i << ": " << cryptonote::get_account_address_as_str(m_nettype, dst.is_subaddress, dst.addr) << " " <<
596  }
597 
598  ss << "\nunlock_time: " << m_unlock_time;
599 
600  return ss.str();
601  }
602 
603  private:
606  uint64_t m_unlock_time;
608  };
609  //----------------------------------------------------------------------------------------------------
610  struct tx_rejected : public transfer_error
611  {
612  explicit tx_rejected(std::string&& loc, const cryptonote::transaction& tx, const std::string& status, const std::string& reason)
613  : transfer_error(std::move(loc), "transaction was rejected by daemon")
614  , m_tx(tx)
615  , m_status(status)
616  , m_reason(reason)
617  {
618  }
619 
620  const cryptonote::transaction& tx() const { return m_tx; }
621  const std::string& status() const { return m_status; }
622  const std::string& reason() const { return m_reason; }
623 
624  std::string to_string() const
625  {
626  std::ostringstream ss;
627  ss << transfer_error::to_string() << ", status = " << m_status << ", tx:\n";
630  if (!m_reason.empty())
631  {
632  ss << " (" << m_reason << ")";
633  }
634  return ss.str();
635  }
636 
637  private:
639  std::string m_status;
640  std::string m_reason;
641  };
642  //----------------------------------------------------------------------------------------------------
644  {
645  explicit tx_sum_overflow(
646  std::string && loc
647  , const std::vector<cryptonote::tx_destination_entry>& destinations
648  , uint64_t fee
649  , cryptonote::network_type nettype
650  )
651  : transfer_error(std::move(loc), "transaction sum + fee exceeds " + cryptonote::print_money(std::numeric_limits<uint64_t>::max()))
653  , m_fee(fee)
654  , m_nettype(nettype)
655  {
656  }
657 
658  const std::vector<cryptonote::tx_destination_entry>& destinations() const { return m_destinations; }
659  uint64_t fee() const { return m_fee; }
660 
661  std::string to_string() const
662  {
663  std::ostringstream ss;
664  ss << transfer_error::to_string() <<
665  ", fee = " << cryptonote::print_money(m_fee) <<
666  ", destinations:";
667  for (const auto& dst : m_destinations)
668  {
669  ss << '\n' << cryptonote::print_money(dst.amount) << " -> " << cryptonote::get_account_address_as_str(m_nettype, dst.is_subaddress, dst.addr);
670  }
671  return ss.str();
672  }
673 
674  private:
675  std::vector<cryptonote::tx_destination_entry> m_destinations;
676  uint64_t m_fee;
678  };
679  //----------------------------------------------------------------------------------------------------
680  struct tx_too_big : public transfer_error
681  {
682  explicit tx_too_big(std::string&& loc, const cryptonote::transaction& tx, uint64_t tx_weight_limit)
683  : transfer_error(std::move(loc), "transaction is too big")
684  , m_tx(tx)
686  {
687  }
688 
689  const cryptonote::transaction& tx() const { return m_tx; }
690  uint64_t tx_weight_limit() const { return m_tx_weight_limit; }
691 
692  std::string to_string() const
693  {
694  std::ostringstream ss;
696  ss << transfer_error::to_string() <<
697  ", tx_weight_limit = " << m_tx_weight_limit <<
698  ", tx weight = " << get_transaction_weight(m_tx) <<
699  ", tx:\n" << cryptonote::obj_to_json_str(tx);
700  return ss.str();
701  }
702 
703  private:
706  };
707  //----------------------------------------------------------------------------------------------------
709  {
710  explicit zero_destination(std::string&& loc)
711  : transfer_error(std::move(loc), "destination amount is zero")
712  {
713  }
714  };
715  //----------------------------------------------------------------------------------------------------
717  {
718  const std::string& request() const { return m_request; }
719 
720  std::string to_string() const
721  {
722  std::ostringstream ss;
723  ss << wallet_logic_error::to_string() << ", request = " << m_request;
724  return ss.str();
725  }
726 
727  protected:
728  explicit wallet_rpc_error(std::string&& loc, const std::string& message, const std::string& request)
729  : wallet_logic_error(std::move(loc), message)
730  , m_request(request)
731  {
732  }
733 
734  private:
735  std::string m_request;
736  };
737  //----------------------------------------------------------------------------------------------------
739  {
740  explicit wallet_generic_rpc_error(std::string&& loc, const std::string& request, const std::string& status)
741  : wallet_rpc_error(std::move(loc), std::string("error in ") + request + " RPC: " + status, request),
743  {
744  }
745  const std::string& status() const { return m_status; }
746  private:
747  const std::string m_status;
748  };
749  //----------------------------------------------------------------------------------------------------
751  {
752  explicit daemon_busy(std::string&& loc, const std::string& request)
753  : wallet_rpc_error(std::move(loc), "daemon is busy", request)
754  {
755  }
756  };
757  //----------------------------------------------------------------------------------------------------
759  {
760  explicit no_connection_to_daemon(std::string&& loc, const std::string& request)
761  : wallet_rpc_error(std::move(loc), "no connection to daemon", request)
762  {
763  }
764  };
765  //----------------------------------------------------------------------------------------------------
767  {
768  explicit is_key_image_spent_error(std::string&& loc, const std::string& request)
769  : wallet_rpc_error(std::move(loc), "error from is_key_image_spent call", request)
770  {
771  }
772  };
773  //----------------------------------------------------------------------------------------------------
775  {
776  explicit get_histogram_error(std::string&& loc, const std::string& request)
777  : wallet_rpc_error(std::move(loc), "failed to get output histogram", request)
778  {
779  }
780  };
781  //----------------------------------------------------------------------------------------------------
783  {
784  explicit get_output_distribution(std::string&& loc, const std::string& request)
785  : wallet_rpc_error(std::move(loc), "failed to get output distribution", request)
786  {
787  }
788  };
789  //----------------------------------------------------------------------------------------------------
791  {
792  explicit wallet_files_doesnt_correspond(std::string&& loc, const std::string& keys_file, const std::string& wallet_file)
793  : wallet_logic_error(std::move(loc), "file " + wallet_file + " does not correspond to " + keys_file)
794  {
795  }
796 
797  const std::string& keys_file() const { return m_keys_file; }
798  const std::string& wallet_file() const { return m_wallet_file; }
799 
800  std::string to_string() const { return wallet_logic_error::to_string(); }
801 
802  private:
803  std::string m_keys_file;
804  std::string m_wallet_file;
805  };
806  //----------------------------------------------------------------------------------------------------
807 
808 #if !defined(_MSC_VER)
809 
810  template<typename TException, typename... TArgs>
811  void throw_wallet_ex(std::string&& loc, const TArgs&... args)
812  {
813  TException e(std::move(loc), args...);
814  LOG_PRINT_L0(e.to_string());
815  throw e;
816  }
817 
818 #else
819  #include <boost/preprocessor/repetition/enum_binary_params.hpp>
820  #include <boost/preprocessor/repetition/enum_params.hpp>
821  #include <boost/preprocessor/repetition/repeat_from_to.hpp>
822 
823  template<typename TException>
824  void throw_wallet_ex(std::string&& loc)
825  {
826  TException e(std::move(loc));
827  LOG_PRINT_L0(e.to_string());
828  throw e;
829  }
830 
831 #define GEN_throw_wallet_ex(z, n, data) \
832  template<typename TException, BOOST_PP_ENUM_PARAMS(n, typename TArg)> \
833  void throw_wallet_ex(std::string&& loc, BOOST_PP_ENUM_BINARY_PARAMS(n, const TArg, &arg)) \
834  { \
835  TException e(std::move(loc), BOOST_PP_ENUM_PARAMS(n, arg)); \
836  LOG_PRINT_L0(e.to_string()); \
837  throw e; \
838  }
839 
840  BOOST_PP_REPEAT_FROM_TO(1, 6, GEN_throw_wallet_ex, ~)
841 #endif
842  }
843 }
844 
845 #define STRINGIZE_DETAIL(x) #x
846 #define STRINGIZE(x) STRINGIZE_DETAIL(x)
847 
848 #define THROW_WALLET_EXCEPTION(err_type, ...) \
849  do { \
850  LOG_ERROR("THROW EXCEPTION: " << #err_type); \
851  tools::error::throw_wallet_ex<err_type>(std::string(__FILE__ ":" STRINGIZE(__LINE__)), ## __VA_ARGS__); \
852  } while(0)
853 
854 #define THROW_WALLET_EXCEPTION_IF(cond, err_type, ...) \
855  if (cond) \
856  { \
857  LOG_ERROR(#cond << ". THROW EXCEPTION: " << #err_type); \
858  tools::error::throw_wallet_ex<err_type>(std::string(__FILE__ ":" STRINGIZE(__LINE__)), ## __VA_ARGS__); \
859  }
Definition: wallet_errors.h:716
Definition: wallet_errors.h:231
Definition: wallet_errors.h:544
is_key_image_spent_error(std::string &&loc, const std::string &request)
Definition: wallet_errors.h:768
no_connection_to_daemon(std::string &&loc, const std::string &request)
Definition: wallet_errors.h:760
Definition: wallet_errors.h:758
wallet_rpc_error(std::string &&loc, const std::string &message, const std::string &request)
Definition: wallet_errors.h:728
password_needed(std::string &&loc, const std::string &msg="Password needed")
Definition: wallet_errors.h:215
std::string m_loc
Definition: wallet_errors.h:117
Definition: wallet_errors.h:303
Definition: wallet_errors.h:514
uint64_t m_fee
Definition: wallet_errors.h:511
std::string get_account_address_as_str(network_type nettype, bool subaddress, account_public_address const &adr)
Definition: cryptonote_basic_impl.cpp:159
std::string m_status
Definition: wallet_errors.h:639
const std::string & request() const
Definition: wallet_errors.h:718
cryptonote::network_type m_nettype
Definition: wallet_errors.h:677
Definition: wallet_errors.h:128
wallet_error_base< std::runtime_error > wallet_runtime_error
Definition: wallet_errors.h:157
const std::string & file() const
Definition: wallet_errors.h:250
uint64_t tx_weight_limit() const
Definition: wallet_errors.h:690
Definition: wallet_errors.h:385
uint64_t m_available
Definition: wallet_errors.h:454
Definition: wallet_errors.h:411
const cryptonote::account_keys & acc_keys() const
Definition: wallet_errors.h:347
uint64_t m_tx_amount
Definition: wallet_errors.h:510
Definition: wallet_errors.h:229
void throw_wallet_ex(std::string &&loc, const TArgs &... args)
Definition: wallet_errors.h:811
std::string to_string() const
Definition: wallet_errors.h:624
const cryptonote::transaction & tx() const
Definition: wallet_errors.h:345
Definition: wallet_errors.h:319
Definition: wallet_errors.h:326
wallet_generic_rpc_error(std::string &&loc, const std::string &request, const std::string &status)
Definition: wallet_errors.h:740
tx_parse_error(std::string &&loc, const cryptonote::blobdata &tx_blob)
Definition: wallet_errors.h:387
std::string m_keys_file
Definition: wallet_errors.h:803
not_enough_money(std::string &&loc, uint64_t available, uint64_t tx_amount, uint64_t fee)
Definition: wallet_errors.h:460
Definition: wallet_errors.h:236
uint64_t tx_amount() const
Definition: wallet_errors.h:495
Definition: wallet_errors.h:135
block_parse_error(std::string &&loc, const cryptonote::blobdata &block_data)
Definition: wallet_errors.h:365
Definition: wallet_errors.h:312
std::vector< cryptonote::tx_destination_entry > destinations_t
Definition: wallet_errors.h:547
std::vector< cryptonote::tx_destination_entry > m_destinations
Definition: wallet_errors.h:675
transfer_error(std::string &&loc, const std::string &message)
Definition: wallet_errors.h:424
index_outofbound(std::string &&loc, const std::string &message)
Definition: wallet_errors.h:314
uint64_t fee() const
Definition: wallet_errors.h:659
std::string to_string() const
Definition: wallet_errors.h:470
std::string to_string() const
Definition: wallet_errors.h:568
failed_rpc_request< transfer_error, get_outs_error_message_index > get_outs_error
Definition: wallet_errors.h:430
Definition: blockchain_ancestry.cpp:70
std::string to_string() const
Definition: wallet_errors.h:692
Definition: wallet_errors.h:167
Definition: wallet_errors.h:680
cryptonote::transaction m_tx
Definition: wallet_errors.h:638
std::unordered_map< uint64_t, uint64_t > scanty_outs_t
Definition: wallet_errors.h:516
uint64_t get_transaction_weight(const transaction &tx, size_t blob_size)
Definition: cryptonote_format_utils.cpp:349
acc_outs_lookup_error(std::string &&loc, const cryptonote::transaction &tx, const crypto::public_key &tx_pub_key, const cryptonote::account_keys &acc_keys)
Definition: wallet_errors.h:336
uint64_t amount
Definition: cryptonote_tx_utils.h:51
address_index_outofbound(std::string &&loc)
Definition: wallet_errors.h:328
Definition: wallet_errors.h:738
uint64_t m_available
Definition: wallet_errors.h:480
uint64_t m_tx_weight_limit
Definition: wallet_errors.h:705
std::string m_file
Definition: wallet_errors.h:255
uint64_t fee() const
Definition: wallet_errors.h:496
tx_not_possible(std::string &&loc, uint64_t available, uint64_t tx_amount, uint64_t fee)
Definition: wallet_errors.h:486
const destinations_t & destinations() const
Definition: wallet_errors.h:565
tx_sum_overflow(std::string &&loc, const std::vector< cryptonote::tx_destination_entry > &destinations, uint64_t fee, cryptonote::network_type nettype)
Definition: wallet_errors.h:645
const cryptonote::blobdata & block_blob() const
Definition: wallet_errors.h:371
Definition: wallet_errors.h:432
const char *const failed_rpc_request_messages[]
Definition: wallet_errors.h:120
multisig_export_needed(std::string &&loc)
Definition: wallet_errors.h:199
Holds cryptonote related classes and helpers.
Definition: db_bdb.cpp:224
cryptonote::transaction m_tx
Definition: wallet_errors.h:186
std::string to_string() const
Definition: wallet_errors.h:270
out_of_hashchain_bounds_error(std::string &&loc)
Definition: wallet_errors.h:413
uint64_t m_available
Definition: wallet_errors.h:509
Definition: wallet_errors.h:774
size_t m_mixin_count
Definition: wallet_errors.h:541
Definition: wallet_errors.h:197
invalid_pregenerated_random(std::string &&loc)
Definition: wallet_errors.h:295
Definition: wallet_errors.h:484
const std::string & keys_file() const
Definition: wallet_errors.h:797
std::string to_string() const
Definition: wallet_errors.h:102
file_error_base< file_save_error_message_index > file_save_error
Definition: wallet_errors.h:261
std::string to_string() const
Definition: wallet_errors.h:444
file_error_base< file_not_found_message_index > file_not_found
Definition: wallet_errors.h:259
Definition: wallet_errors.h:790
Definition: wallet_errors.h:159
Various Tools.
Definition: apply_permutation.h:39
invalid_priority(std::string &&loc)
Definition: wallet_errors.h:274
Definition: wallet_errors.h:263
failed_rpc_request< refresh_error, get_hashes_error_message_index > get_hashes_error
Definition: wallet_errors.h:381
cryptonote::blobdata m_tx_blob
Definition: wallet_errors.h:398
Definition: wallet_errors.h:766
get_output_distribution(std::string &&loc, const std::string &request)
Definition: wallet_errors.h:784
const crypto::public_key & tx_pub_key() const
Definition: wallet_errors.h:346
std::string to_string() const
Definition: wallet_errors.h:289
Definition: cryptonote_tx_utils.h:42
const cryptonote::transaction & tx() const
Definition: wallet_errors.h:689
const cryptonote::transaction & tx() const
Definition: wallet_errors.h:175
account_index_outofbound(std::string &&loc)
Definition: wallet_errors.h:321
invalid_multisig_seed(std::string &&loc)
Definition: wallet_errors.h:284
refresh_error(std::string &&loc, const std::string &message)
Definition: wallet_errors.h:306
Definition: wallet_errors.h:293
std::string obj_to_json_str(T &obj)
Definition: cryptonote_format_utils.h:176
file_error_base< file_read_error_message_index > file_read_error
Definition: wallet_errors.h:260
std::string to_string() const
Definition: wallet_errors.h:145
daemon_busy(std::string &&loc, const std::string &request)
Definition: wallet_errors.h:752
std::string to_string() const
Definition: wallet_errors.h:373
std::string m_wallet_file
Definition: wallet_errors.h:804
uint64_t amount
Definition: cryptonote_tx_utils.h:76
const scanty_outs_t & scanty_outs() const
Definition: wallet_errors.h:525
not_enough_outs_to_mix(std::string &&loc, const scanty_outs_t &scanty_outs, size_t mixin_count)
Definition: wallet_errors.h:518
sources_t m_sources
Definition: wallet_errors.h:604
const std::string & status() const
Definition: wallet_errors.h:143
get_tx_pool_error(std::string &&loc)
Definition: wallet_errors.h:403
Definition: wallet_errors.h:421
const cryptonote::account_keys m_acc_keys
Definition: wallet_errors.h:360
uint64_t available() const
Definition: wallet_errors.h:494
bool is_subaddress
Definition: cryptonote_tx_utils.h:78
Definition: account.h:40
get_histogram_error(std::string &&loc, const std::string &request)
Definition: wallet_errors.h:776
std::string to_string() const
Definition: wallet_errors.h:349
zero_destination(std::string &&loc)
Definition: wallet_errors.h:710
Definition: wallet_errors.h:782
std::string to_string() const
Definition: wallet_errors.h:408
std::string to_string() const
Definition: wallet_errors.h:418
POD_CLASS public_key
Definition: crypto.h:63
std::string m_reason
Definition: wallet_errors.h:640
wallet_error_base< std::logic_error > wallet_logic_error
Definition: wallet_errors.h:156
size_t mixin_count() const
Definition: wallet_errors.h:526
tx_rejected(std::string &&loc, const cryptonote::transaction &tx, const std::string &status, const std::string &reason)
Definition: wallet_errors.h:612
uint64_t m_tx_amount
Definition: wallet_errors.h:455
std::string m_request
Definition: wallet_errors.h:735
wallet_error_base(std::string &&loc, const std::string &message)
Definition: wallet_errors.h:110
Definition: wallet_errors.h:230
std::string to_string() const
Definition: wallet_errors.h:300
Definition: wallet_errors.h:98
const std::string & reason() const
Definition: wallet_errors.h:622
not_enough_unlocked_money(std::string &&loc, uint64_t available, uint64_t tx_amount, uint64_t fee)
Definition: wallet_errors.h:434
account_public_address addr
Definition: cryptonote_tx_utils.h:77
std::string blobdata
Definition: blobdatatype.h:35
std::string to_string() const
Definition: wallet_errors.h:528
uint64_t tx_amount() const
Definition: wallet_errors.h:468
const std::string & location() const
Definition: wallet_errors.h:100
network_type
Definition: cryptonote_config.h:204
Definition: wallet_errors.h:189
const crypto::public_key m_tx_pub_key
Definition: wallet_errors.h:359
Definition: wallet_errors.h:708
Definition: wallet_errors.h:750
std::string to_string() const
Definition: wallet_errors.h:395
Definition: wallet_errors.h:458
const cryptonote::blobdata & tx_blob() const
Definition: wallet_errors.h:393
Definition: wallet_errors.h:213
failed_rpc_request(std::string &&loc, const std::string &status)
Definition: wallet_errors.h:137
const std::string & status() const
Definition: wallet_errors.h:621
const std::string & wallet_file() const
Definition: wallet_errors.h:798
wallet_internal_error(std::string &&loc, const std::string &message)
Definition: wallet_errors.h:161
cryptonote::network_type m_nettype
Definition: wallet_errors.h:607
wallet_files_doesnt_correspond(std::string &&loc, const std::string &keys_file, const std::string &wallet_file)
Definition: wallet_errors.h:792
tx_not_constructed(std::string &&loc, sources_t const &sources, destinations_t const &destinations, uint64_t unlock_time, cryptonote::network_type nettype)
Definition: wallet_errors.h:549
Definition: wallet_errors.h:205
Definition: wallet_errors.h:131
std::string to_string() const
Definition: wallet_errors.h:800
Definition: wallet_errors.h:272
cryptonote::blobdata m_block_blob
Definition: wallet_errors.h:376
std::string to_string() const
Definition: wallet_errors.h:498
const std::vector< cryptonote::tx_destination_entry > & destinations() const
Definition: wallet_errors.h:658
std::string to_string() const
Definition: wallet_errors.h:661
Definition: wallet_errors.h:282
std::string m_status
Definition: wallet_errors.h:153
Definition: cryptonote_tx_utils.h:74
uint64_t m_tx_amount
Definition: wallet_errors.h:481
uint64_t m_fee
Definition: wallet_errors.h:676
std::string to_string() const
Definition: wallet_errors.h:720
failed_rpc_request< refresh_error, get_blocks_error_message_index > get_blocks_error
Definition: wallet_errors.h:379
std::string to_string() const
Definition: wallet_errors.h:177
const cryptonote::transaction & tx() const
Definition: wallet_errors.h:620
std::vector< cryptonote::tx_source_entry > sources_t
Definition: wallet_errors.h:546
multisig_import_needed(std::string &&loc)
Definition: wallet_errors.h:207
Definition: wallet_errors.h:610
scanty_outs_t m_scanty_outs
Definition: wallet_errors.h:540
Definition: wallet_errors.h:129
failed_rpc_request< refresh_error, get_out_indices_error_message_index > get_out_indices_error
Definition: wallet_errors.h:383
uint64_t available() const
Definition: wallet_errors.h:441
failed_rpc_request_message_indices
Definition: wallet_errors.h:126
cryptonote::transaction m_tx
Definition: wallet_errors.h:704
std::string print_money(uint64_t amount, unsigned int decimal_point)
Definition: cryptonote_format_utils.cpp:808
uint64_t m_unlock_time
Definition: wallet_errors.h:606
const cryptonote::transaction m_tx
Definition: wallet_errors.h:358
const std::string & status() const
Definition: wallet_errors.h:745
file_error_base(std::string &&loc, const std::string &file)
Definition: wallet_errors.h:238
file_error_message_indices
Definition: wallet_errors.h:227
unexpected_txin_type(std::string &&loc, const cryptonote::transaction &tx)
Definition: wallet_errors.h:169
Definition: wallet_errors.h:334
wallet_not_initialized(std::string &&loc)
Definition: wallet_errors.h:191
uint64_t available() const
Definition: wallet_errors.h:467
destinations_t m_destinations
Definition: wallet_errors.h:605
uint64_t unlock_time() const
Definition: wallet_errors.h:566
std::string to_string() const
Definition: wallet_errors.h:279
invalid_password(std::string &&loc)
Definition: wallet_errors.h:265
file_error_base< file_exists_message_index > file_exists
Definition: wallet_errors.h:258
Definition: cryptonote_basic.h:182
std::string to_string() const
Definition: wallet_errors.h:252
Definition: wallet_errors.h:643
Definition: wallet_errors.h:232
Definition: wallet_errors.h:401
Definition: wallet_errors.h:363
const std::string m_status
Definition: wallet_errors.h:747
const char *const file_error_messages[]
Definition: wallet_errors.h:221
uint64_t tx_amount() const
Definition: wallet_errors.h:442
tx_too_big(std::string &&loc, const cryptonote::transaction &tx, uint64_t tx_weight_limit)
Definition: wallet_errors.h:682
const sources_t & sources() const
Definition: wallet_errors.h:564