Monero
wallet_errors.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2022, The Monero Project
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification, are
6 // permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice, this list of
9 // conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 // of conditions and the following disclaimer in the documentation and/or other
13 // materials provided with the distribution.
14 //
15 // 3. Neither the name of the copyright holder nor the names of its contributors may be
16 // used to endorse or promote products derived from this software without specific
17 // prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 //
29 // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
30 
31 #pragma once
32 
33 #include <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  // invalid_spend_key
67  // refresh_error *
68  // acc_outs_lookup_error
69  // block_parse_error
70  // get_blocks_error
71  // get_hashes_error
72  // get_out_indexes_error
73  // tx_parse_error
74  // get_tx_pool_error
75  // out_of_hashchain_bounds_error
76  // signature_check_failed
77  // transfer_error *
78  // get_outs_general_error
79  // not_enough_unlocked_money
80  // not_enough_money
81  // tx_not_possible
82  // not_enough_outs_to_mix
83  // tx_not_constructed
84  // tx_rejected
85  // tx_sum_overflow
86  // tx_too_big
87  // zero_amount
88  // zero_destination
89  // subtract_fee_from_bad_index
90  // nonzero_unlock_time
91  // wallet_rpc_error *
92  // daemon_busy
93  // no_connection_to_daemon
94  // is_key_image_spent_error
95  // get_histogram_error
96  // get_output_distribution
97  // payment_required
98  // wallet_files_doesnt_correspond
99  // scan_tx_error *
100  // wont_reprocess_recent_txs_via_untrusted_daemon
101  // background_sync_error *
102  // background_wallet_already_open
103  // background_custom_password_same_as_wallet_password
104  //
105  // * - class with protected ctor
106 
107  //----------------------------------------------------------------------------------------------------
108  template<typename Base>
109  struct wallet_error_base : public Base
110  {
111  const std::string& location() const { return m_loc; }
112 
114  {
115  std::ostringstream ss;
116  ss << m_loc << ':' << typeid(*this).name() << ": " << Base::what();
117  return ss.str();
118  }
119 
120  protected:
122  : Base(message)
123  , m_loc(loc)
124  {
125  }
126 
127  private:
129  };
130  //----------------------------------------------------------------------------------------------------
131  const char* const failed_rpc_request_messages[] = {
132  "failed to get blocks",
133  "failed to get hashes",
134  "failed to get out indices",
135  "failed to get random outs"
136  };
138  {
143  };
144 
145  template<typename Base, int msg_index>
146  struct failed_rpc_request : public Base
147  {
149  : Base(std::move(loc), failed_rpc_request_messages[msg_index])
150  , m_status(status)
151  {
152  }
153 
154  const std::string& status() const { return m_status; }
155 
157  {
158  std::ostringstream ss;
159  ss << Base::to_string() << ", status = " << status();
160  return ss.str();
161  }
162 
163  private:
165  };
166  //----------------------------------------------------------------------------------------------------
169  //----------------------------------------------------------------------------------------------------
171  {
174  {
175  }
176  };
177  //----------------------------------------------------------------------------------------------------
179  {
181  : wallet_internal_error(std::move(loc), "one of tx inputs has unexpected type")
182  , m_tx(tx)
183  {
184  }
185 
186  const cryptonote::transaction& tx() const { return m_tx; }
187 
189  {
190  std::ostringstream ss;
193  return ss.str();
194  }
195 
196  private:
198  };
199  //----------------------------------------------------------------------------------------------------
201  {
203  : wallet_internal_error(std::move(loc), "wallet is not initialized")
204  {
205  }
206  };
207  //----------------------------------------------------------------------------------------------------
209  {
211  : wallet_runtime_error(std::move(loc), "This signature was made with stale data: export fresh multisig data, which other participants must then use")
212  {
213  }
214  };
215  //----------------------------------------------------------------------------------------------------
217  {
219  : wallet_runtime_error(std::move(loc), "Not enough multisig data was found to sign: import multisig data from more other participants")
220  {
221  }
222  };
223  //----------------------------------------------------------------------------------------------------
225  {
226  explicit password_needed(std::string&& loc, const std::string &msg = "Password needed")
227  : wallet_runtime_error(std::move(loc), msg)
228  {
229  }
230  };
231  //----------------------------------------------------------------------------------------------------
233  {
234  explicit password_entry_failed(std::string&& loc, const std::string &msg = "Password entry failed")
235  : wallet_runtime_error(std::move(loc), msg)
236  {
237  }
238  };
239  //----------------------------------------------------------------------------------------------------
240  const char* const file_error_messages[] = {
241  "file already exists",
242  "file not found",
243  "failed to read file",
244  "failed to save file"
245  };
247  {
252  };
253 
254  template<int msg_index>
256  {
257  explicit file_error_base(std::string&& loc, const std::string& file)
258  : wallet_logic_error(std::move(loc), std::string(file_error_messages[msg_index]) + " \"" + file + '\"')
259  , m_file(file)
260  {
261  }
262 
263  explicit file_error_base(std::string&& loc, const std::string& file, const std::error_code &e)
264  : wallet_logic_error(std::move(loc), std::string(file_error_messages[msg_index]) + " \"" + file + "\": " + e.message())
265  , m_file(file)
266  {
267  }
268 
269  const std::string& file() const { return m_file; }
270 
272 
273  private:
275  };
276  //----------------------------------------------------------------------------------------------------
281  //----------------------------------------------------------------------------------------------------
283  {
285  : wallet_logic_error(std::move(loc), "invalid password")
286  {
287  }
288 
290  };
292  {
294  : wallet_logic_error(std::move(loc), "invalid priority")
295  {
296  }
297 
299  };
300 
302  {
304  : wallet_logic_error(std::move(loc), "invalid multisig seed")
305  {
306  }
307 
309  };
310 
312  {
314  : wallet_logic_error(std::move(loc), "invalid spend key")
315  {
316  }
317 
319  };
320 
321  //----------------------------------------------------------------------------------------------------
323  {
325  : wallet_logic_error(std::move(loc), "invalid pregenerated random for wallet creation/recovery")
326  {
327  }
328 
330  };
331  //----------------------------------------------------------------------------------------------------
333  {
334  protected:
337  {
338  }
339  };
340  //----------------------------------------------------------------------------------------------------
342  {
345  {
346  }
347  };
349  {
351  : index_outofbound(std::move(loc), "account index is out of bound")
352  {
353  }
354  };
356  {
358  : index_outofbound(std::move(loc), "address index is out of bound")
359  {
360  }
361  };
362  //----------------------------------------------------------------------------------------------------
364  {
367  : refresh_error(std::move(loc), "account outs lookup error")
368  , m_tx(tx)
371  {
372  }
373 
374  const cryptonote::transaction& tx() const { return m_tx; }
375  const crypto::public_key& tx_pub_key() const { return m_tx_pub_key; }
376  const cryptonote::account_keys& acc_keys() const { return m_acc_keys; }
377 
379  {
380  std::ostringstream ss;
383  return ss.str();
384  }
385 
386  private:
390  };
391  //----------------------------------------------------------------------------------------------------
393  {
394  explicit block_parse_error(std::string&& loc, const cryptonote::blobdata& block_data)
395  : refresh_error(std::move(loc), "block parse error")
396  , m_block_blob(block_data)
397  {
398  }
399 
400  const cryptonote::blobdata& block_blob() const { return m_block_blob; }
401 
403 
404  private:
406  };
407  //----------------------------------------------------------------------------------------------------
409  //----------------------------------------------------------------------------------------------------
411  //----------------------------------------------------------------------------------------------------
413  //----------------------------------------------------------------------------------------------------
415  {
417  : refresh_error(std::move(loc), "transaction parse error")
418  , m_tx_blob(tx_blob)
419  {
420  }
421 
422  const cryptonote::blobdata& tx_blob() const { return m_tx_blob; }
423 
425 
426  private:
428  };
429  //----------------------------------------------------------------------------------------------------
431  {
433  : refresh_error(std::move(loc), "error getting transaction pool")
434  {
435  }
436 
438  };
439  //----------------------------------------------------------------------------------------------------
441  {
443  : refresh_error(std::move(loc), "Index out of bounds of of hashchain")
444  {
445  }
446 
448  };
449  //----------------------------------------------------------------------------------------------------
451  {
453  : refresh_error(std::move(loc), message)
454  {
455  }
456 
458  };
459  //----------------------------------------------------------------------------------------------------
461  {
463  : refresh_error(std::move(loc), message)
464  {
465  }
466 
468  };
469  //----------------------------------------------------------------------------------------------------
471  {
473  : wallet_logic_error(std::move(loc), "Signature check failed " + message)
474  {
475  }
476  };
477  //----------------------------------------------------------------------------------------------------
479  {
480  protected:
483  {
484  }
485  };
486  //----------------------------------------------------------------------------------------------------
488  //----------------------------------------------------------------------------------------------------
490  {
492  : transfer_error(std::move(loc), "not enough unlocked money")
495  {
496  }
497 
498  uint64_t available() const { return m_available; }
499  uint64_t tx_amount() const { return m_tx_amount; }
500 
502  {
503  std::ostringstream ss;
504  ss << transfer_error::to_string() <<
505  ", available = " << cryptonote::print_money(m_available) <<
506  ", tx_amount = " << cryptonote::print_money(m_tx_amount);
507  return ss.str();
508  }
509 
510  private:
513  };
514  //----------------------------------------------------------------------------------------------------
516  {
518  : transfer_error(std::move(loc), "not enough money")
521  {
522  }
523 
524  uint64_t available() const { return m_available; }
525  uint64_t tx_amount() const { return m_tx_amount; }
526 
528  {
529  std::ostringstream ss;
530  ss << transfer_error::to_string() <<
531  ", available = " << cryptonote::print_money(m_available) <<
532  ", tx_amount = " << cryptonote::print_money(m_tx_amount);
533  return ss.str();
534  }
535 
536  private:
539  };
540  //----------------------------------------------------------------------------------------------------
542  {
544  : transfer_error(std::move(loc), "tx not possible")
547  , m_fee(fee)
548  {
549  }
550 
551  uint64_t available() const { return m_available; }
552  uint64_t tx_amount() const { return m_tx_amount; }
553  uint64_t fee() const { return m_fee; }
554 
556  {
557  std::ostringstream ss;
558  ss << transfer_error::to_string() <<
559  ", available = " << cryptonote::print_money(m_available) <<
560  ", tx_amount = " << cryptonote::print_money(m_tx_amount) <<
561  ", fee = " << cryptonote::print_money(m_fee);
562  return ss.str();
563  }
564 
565  private:
569  };
570  //----------------------------------------------------------------------------------------------------
572  {
573  typedef std::unordered_map<uint64_t, uint64_t> scanty_outs_t;
574 
576  : transfer_error(std::move(loc), "not enough outputs to use")
579  {
580  }
581 
582  const scanty_outs_t& scanty_outs() const { return m_scanty_outs; }
583  size_t mixin_count() const { return m_mixin_count; }
584 
586  {
587  std::ostringstream ss;
588  ss << transfer_error::to_string() << ", ring size = " << (m_mixin_count + 1) << ", scanty_outs:";
589  for (const auto& out: m_scanty_outs)
590  {
591  ss << '\n' << cryptonote::print_money(out.first) << " - " << out.second;
592  }
593  return ss.str();
594  }
595 
596  private:
599  };
600  //----------------------------------------------------------------------------------------------------
602  {
603  typedef std::vector<cryptonote::tx_source_entry> sources_t;
604  typedef std::vector<cryptonote::tx_destination_entry> destinations_t;
605 
607  std::string && loc
608  , sources_t const & sources
609  , destinations_t const & destinations
610  , cryptonote::network_type nettype
611  )
612  : transfer_error(std::move(loc), "transaction was not constructed")
613  , m_sources(sources)
615  , m_nettype(nettype)
616  {
617  }
618 
619  const sources_t& sources() const { return m_sources; }
620  const destinations_t& destinations() const { return m_destinations; }
621 
623  {
624  std::ostringstream ss;
626  ss << "\nSources:";
627  for (size_t i = 0; i < m_sources.size(); ++i)
628  {
630  ss << "\n source " << i << ":";
631  ss << "\n amount: " << cryptonote::print_money(src.amount);
632  // It's not good, if logs will contain such much data
633  //ss << "\n real_output: " << src.real_output;
634  //ss << "\n real_output_in_tx_index: " << src.real_output_in_tx_index;
635  //ss << "\n real_out_tx_key: " << epee::string_tools::pod_to_hex(src.real_out_tx_key);
636  //ss << "\n outputs:";
637  //for (size_t j = 0; j < src.outputs.size(); ++j)
638  //{
639  // const cryptonote::tx_source_entry::output_entry& out = src.outputs[j];
640  // ss << "\n " << j << ": " << out.first << ", " << epee::string_tools::pod_to_hex(out.second);
641  //}
642  }
643 
644  ss << "\nDestinations:";
645  for (size_t i = 0; i < m_destinations.size(); ++i)
646  {
648  ss << "\n " << i << ": " << cryptonote::get_account_address_as_str(m_nettype, dst.is_subaddress, dst.addr) << " " <<
650  }
651 
652  return ss.str();
653  }
654 
655  private:
659  };
660  //----------------------------------------------------------------------------------------------------
661  struct tx_rejected : public transfer_error
662  {
664  : transfer_error(std::move(loc), "transaction was rejected by daemon")
665  , m_tx(tx)
666  , m_status(status)
667  , m_reason(reason)
668  {
669  }
670 
671  const cryptonote::transaction& tx() const { return m_tx; }
672  const std::string& status() const { return m_status; }
673  const std::string& reason() const { return m_reason; }
674 
676  {
677  std::ostringstream ss;
678  ss << transfer_error::to_string() << ", status = " << m_status << ", tx:\n";
681  if (!m_reason.empty())
682  {
683  ss << " (" << m_reason << ")";
684  }
685  return ss.str();
686  }
687 
688  private:
692  };
693  //----------------------------------------------------------------------------------------------------
695  {
696  explicit tx_sum_overflow(
697  std::string && loc
698  , const std::vector<cryptonote::tx_destination_entry>& destinations
699  , uint64_t fee
700  , cryptonote::network_type nettype
701  )
702  : transfer_error(std::move(loc), "transaction sum + fee exceeds " + cryptonote::print_money(std::numeric_limits<uint64_t>::max()))
704  , m_fee(fee)
705  , m_nettype(nettype)
706  {
707  }
708 
709  const std::vector<cryptonote::tx_destination_entry>& destinations() const { return m_destinations; }
710  uint64_t fee() const { return m_fee; }
711 
713  {
714  std::ostringstream ss;
715  ss << transfer_error::to_string() <<
716  ", fee = " << cryptonote::print_money(m_fee) <<
717  ", destinations:";
718  for (const auto& dst : m_destinations)
719  {
720  ss << '\n' << cryptonote::print_money(dst.amount) << " -> " << cryptonote::get_account_address_as_str(m_nettype, dst.is_subaddress, dst.addr);
721  }
722  return ss.str();
723  }
724 
725  private:
726  std::vector<cryptonote::tx_destination_entry> m_destinations;
729  };
730  //----------------------------------------------------------------------------------------------------
731  struct tx_too_big : public transfer_error
732  {
734  : transfer_error(std::move(loc), "transaction is too big")
735  , m_tx(tx)
736  , m_tx_valid(true)
739  {
740  }
741 
743  : transfer_error(std::move(loc), "transaction would be too big")
744  , m_tx_valid(false)
747  {
748  }
749 
750  bool tx_valid() const { return m_tx_valid; }
751  const cryptonote::transaction& tx() const { return m_tx; }
752  uint64_t tx_weight() const { return m_tx_weight; }
754 
756  {
757  std::ostringstream ss;
758  ss << transfer_error::to_string() <<
759  ", tx_weight_limit = " << m_tx_weight_limit <<
760  ", tx weight = " << m_tx_weight;
761  if (m_tx_valid)
762  {
764  ss << ", tx:\n" << cryptonote::obj_to_json_str(tx);
765  }
766  return ss.str();
767  }
768 
769  private:
774  };
775  //----------------------------------------------------------------------------------------------------
777  {
778  explicit zero_amount(std::string&& loc)
779  : transfer_error(std::move(loc), "destination amount is zero")
780  {
781  }
782  };
783  //----------------------------------------------------------------------------------------------------
785  {
787  : transfer_error(std::move(loc), "transaction has no destination")
788  {
789  }
790  };
791  //----------------------------------------------------------------------------------------------------
793  {
794  explicit subtract_fee_from_bad_index(std::string&& loc, long bad_index)
795  : transfer_error(std::move(loc),
796  "subtractfeefrom: bad index: " + std::to_string(bad_index) + " (indexes are 0-based)")
797  {
798  }
799  };
800  //----------------------------------------------------------------------------------------------------
802  {
804  : transfer_error(std::move(loc), "transaction cannot have non-zero unlock time")
805  {
806  }
807  };
808  //----------------------------------------------------------------------------------------------------
810  {
811  const std::string& request() const { return m_request; }
812 
814  {
815  std::ostringstream ss;
816  ss << wallet_logic_error::to_string() << ", request = " << m_request;
817  return ss.str();
818  }
819 
820  protected:
823  , m_request(request)
824  {
825  }
826 
827  private:
829  };
830  //----------------------------------------------------------------------------------------------------
832  {
834  : wallet_rpc_error(std::move(loc), std::string("error in ") + request + " RPC: " + status, request),
836  {
837  }
838  const std::string& status() const { return m_status; }
839  private:
841  };
842  //----------------------------------------------------------------------------------------------------
844  {
846  : wallet_rpc_error(std::move(loc), std::string("error ") + std::to_string(code) + (" in ") + request + " RPC: " + status, request),
848  {
849  }
850  int code() const { return m_code; }
851  const std::string& status() const { return m_status; }
852  private:
853  int m_code;
855  };
856  //----------------------------------------------------------------------------------------------------
858  {
859  explicit daemon_busy(std::string&& loc, const std::string& request)
860  : wallet_rpc_error(std::move(loc), "daemon is busy", request)
861  {
862  }
863  };
864  //----------------------------------------------------------------------------------------------------
866  {
868  : wallet_rpc_error(std::move(loc), "no connection to daemon", request)
869  {
870  }
871  };
872  //----------------------------------------------------------------------------------------------------
874  {
876  : wallet_rpc_error(std::move(loc), "error from is_key_image_spent call", request)
877  {
878  }
879  };
880  //----------------------------------------------------------------------------------------------------
882  {
884  : wallet_rpc_error(std::move(loc), "failed to get output histogram", request)
885  {
886  }
887  };
888  //----------------------------------------------------------------------------------------------------
890  {
892  : wallet_rpc_error(std::move(loc), "failed to get output distribution", request)
893  {
894  }
895  };
896  //----------------------------------------------------------------------------------------------------
898  {
900  : wallet_rpc_error(std::move(loc), "payment required", request)
901  {
902  }
903  };
904  //----------------------------------------------------------------------------------------------------
906  {
908  : wallet_logic_error(std::move(loc), "file " + wallet_file + " does not correspond to " + keys_file)
909  {
910  }
911 
912  const std::string& keys_file() const { return m_keys_file; }
913  const std::string& wallet_file() const { return m_wallet_file; }
914 
916 
917  private:
920  };
921  //----------------------------------------------------------------------------------------------------
923  {
924  protected:
925  explicit mms_error(std::string&& loc, const std::string& message)
927  {
928  }
929  };
930  //----------------------------------------------------------------------------------------------------
932  {
934  : mms_error(std::move(loc), "no connection to PyBitmessage at address " + address)
935  {
936  }
937  };
938  //----------------------------------------------------------------------------------------------------
940  {
941  explicit bitmessage_api_error(std::string&& loc, const std::string& error_string)
942  : mms_error(std::move(loc), "PyBitmessage returned " + error_string)
943  {
944  }
945  };
946  //----------------------------------------------------------------------------------------------------
948  {
949  protected:
952  {
953  }
954  };
955  //----------------------------------------------------------------------------------------------------
957  {
959  : scan_tx_error(std::move(loc), "The wallet has already seen 1 or more recent transactions than the scanned tx")
960  {
961  }
962  };
963  //----------------------------------------------------------------------------------------------------
965  {
966  protected:
969  {
970  }
971  };
972  //----------------------------------------------------------------------------------------------------
974  {
975  explicit background_wallet_already_open(std::string&& loc, const std::string& background_wallet_file)
976  : background_sync_error(std::move(loc), "background wallet " + background_wallet_file + " is already opened by another wallet program")
977  {
978  }
979  };
980  //----------------------------------------------------------------------------------------------------
982  {
984  : background_sync_error(std::move(loc), "custom background password must be different than wallet password")
985  {
986  }
987  };
988  //----------------------------------------------------------------------------------------------------
989 
990 #if !defined(_MSC_VER)
991 
992  template<typename TException, typename... TArgs>
993  void throw_wallet_ex(std::string&& loc, const TArgs&... args)
994  {
995  TException e(std::move(loc), args...);
996  LOG_PRINT_L0(e.to_string());
997  throw e;
998  }
999 
1000 #else
1001  #include <boost/preprocessor/repetition/enum_binary_params.hpp>
1002  #include <boost/preprocessor/repetition/enum_params.hpp>
1003  #include <boost/preprocessor/repetition/repeat_from_to.hpp>
1004 
1005  template<typename TException>
1006  void throw_wallet_ex(std::string&& loc)
1007  {
1008  TException e(std::move(loc));
1009  LOG_PRINT_L0(e.to_string());
1010  throw e;
1011  }
1012 
1013 #define GEN_throw_wallet_ex(z, n, data) \
1014  template<typename TException, BOOST_PP_ENUM_PARAMS(n, typename TArg)> \
1015  void throw_wallet_ex(std::string&& loc, BOOST_PP_ENUM_BINARY_PARAMS(n, const TArg, &arg)) \
1016  { \
1017  TException e(std::move(loc), BOOST_PP_ENUM_PARAMS(n, arg)); \
1018  LOG_PRINT_L0(e.to_string()); \
1019  throw e; \
1020  }
1021 
1022  BOOST_PP_REPEAT_FROM_TO(1, 6, GEN_throw_wallet_ex, ~)
1023 #endif
1024  }
1025 }
1026 
1027 #define STRINGIZE_DETAIL(x) #x
1028 #define STRINGIZE(x) STRINGIZE_DETAIL(x)
1029 
1030 #define THROW_WALLET_EXCEPTION(err_type, ...) \
1031  do { \
1032  LOG_ERROR("THROW EXCEPTION: " << #err_type); \
1033  tools::error::throw_wallet_ex<err_type>(std::string(__FILE__ ":" STRINGIZE(__LINE__)), ## __VA_ARGS__); \
1034  } while(0)
1035 
1036 #define THROW_WALLET_EXCEPTION_IF(cond, err_type, ...) \
1037  if (cond) \
1038  { \
1039  LOG_ERROR(#cond << ". THROW EXCEPTION: " << #err_type); \
1040  tools::error::throw_wallet_ex<err_type>(std::string(__FILE__ ":" STRINGIZE(__LINE__)), ## __VA_ARGS__); \
1041  }
Definition: wallet_errors.h:809
Definition: wallet_errors.h:250
Definition: wallet_errors.h:601
is_key_image_spent_error(std::string &&loc, const std::string &request)
Definition: wallet_errors.h:875
subtract_fee_from_bad_index(std::string &&loc, long bad_index)
Definition: wallet_errors.h:794
no_connection_to_daemon(std::string &&loc, const std::string &request)
Definition: wallet_errors.h:867
std::string to_string() const
Definition: wallet_errors.h:457
Definition: wallet_errors.h:865
uint64_t tx_weight() const
Definition: wallet_errors.h:752
Definition: wallet_errors.h:311
wallet_rpc_error(std::string &&loc, const std::string &message, const std::string &request)
Definition: wallet_errors.h:821
password_needed(std::string &&loc, const std::string &msg="Password needed")
Definition: wallet_errors.h:226
std::string m_loc
Definition: wallet_errors.h:128
Definition: wallet_errors.h:332
Definition: wallet_errors.h:571
uint64_t m_fee
Definition: wallet_errors.h:568
Definition: wallet_errors.h:939
std::string get_account_address_as_str(network_type nettype, bool subaddress, account_public_address const &adr)
Definition: cryptonote_basic_impl.cpp:150
std::string m_status
Definition: wallet_errors.h:690
const std::string & request() const
Definition: wallet_errors.h:811
cryptonote::network_type m_nettype
Definition: wallet_errors.h:728
Definition: wallet_errors.h:139
wallet_error_base< std::runtime_error > wallet_runtime_error
Definition: wallet_errors.h:168
const std::string & file() const
Definition: wallet_errors.h:269
uint64_t tx_weight_limit() const
Definition: wallet_errors.h:753
Definition: wallet_errors.h:414
uint64_t m_available
Definition: wallet_errors.h:511
int i
Definition: pymoduletest.py:23
bool m_tx_valid
Definition: wallet_errors.h:771
Definition: wallet_errors.h:440
const cryptonote::account_keys & acc_keys() const
Definition: wallet_errors.h:376
uint64_t m_tx_amount
Definition: wallet_errors.h:567
Definition: wallet_errors.h:248
void throw_wallet_ex(std::string &&loc, const TArgs &... args)
Definition: wallet_errors.h:993
int m_code
Definition: wallet_errors.h:853
std::string to_string() const
Definition: wallet_errors.h:675
const cryptonote::transaction & tx() const
Definition: wallet_errors.h:374
::std::string string
Definition: gtest-port.h:1097
Definition: wallet_errors.h:348
uint64_t m_tx_weight
Definition: wallet_errors.h:772
Definition: wallet_errors.h:355
wallet_generic_rpc_error(std::string &&loc, const std::string &request, const std::string &status)
Definition: wallet_errors.h:833
tx_parse_error(std::string &&loc, const cryptonote::blobdata &tx_blob)
Definition: wallet_errors.h:416
std::string m_keys_file
Definition: wallet_errors.h:918
not_enough_money(std::string &&loc, uint64_t available, uint64_t tx_amount, uint64_t fee)
Definition: wallet_errors.h:517
Definition: wallet_errors.h:255
uint64_t tx_amount() const
Definition: wallet_errors.h:552
Definition: wallet_errors.h:897
Definition: wallet_errors.h:146
block_parse_error(std::string &&loc, const cryptonote::blobdata &block_data)
Definition: wallet_errors.h:394
Definition: wallet_errors.h:341
std::vector< cryptonote::tx_destination_entry > destinations_t
Definition: wallet_errors.h:604
std::vector< cryptonote::tx_destination_entry > m_destinations
Definition: wallet_errors.h:726
transfer_error(std::string &&loc, const std::string &message)
Definition: wallet_errors.h:481
zero_amount(std::string &&loc)
Definition: wallet_errors.h:778
index_outofbound(std::string &&loc, const std::string &message)
Definition: wallet_errors.h:343
uint64_t fee() const
Definition: wallet_errors.h:710
std::string to_string() const
Definition: wallet_errors.h:527
std::string to_string() const
Definition: wallet_errors.h:622
failed_rpc_request< transfer_error, get_outs_error_message_index > get_outs_error
Definition: wallet_errors.h:487
no_connection_to_bitmessage(std::string &&loc, const std::string &address)
Definition: wallet_errors.h:933
Definition: enums.h:67
std::string to_string() const
Definition: wallet_errors.h:755
Definition: wallet_errors.h:792
bitmessage_api_error(std::string &&loc, const std::string &error_string)
Definition: wallet_errors.h:941
Definition: wallet_errors.h:178
Definition: wallet_errors.h:470
Definition: wallet_errors.h:931
Definition: wallet_errors.h:731
cryptonote::transaction m_tx
Definition: wallet_errors.h:689
std::unordered_map< uint64_t, uint64_t > scanty_outs_t
Definition: wallet_errors.h:573
uint64_t get_transaction_weight(const transaction &tx, size_t blob_size)
Definition: cryptonote_format_utils.cpp:445
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:365
uint64_t amount
Definition: cryptonote_tx_utils.h:51
address_index_outofbound(std::string &&loc)
Definition: wallet_errors.h:357
Definition: wallet_errors.h:831
args
Definition: build_protob.py:10
uint64_t m_available
Definition: wallet_errors.h:537
uint64_t m_tx_weight_limit
Definition: wallet_errors.h:773
std::string m_file
Definition: wallet_errors.h:274
uint64_t fee() const
Definition: wallet_errors.h:553
tx_not_possible(std::string &&loc, uint64_t available, uint64_t tx_amount, uint64_t fee)
Definition: wallet_errors.h:543
const destinations_t & destinations() const
Definition: wallet_errors.h:620
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:696
const cryptonote::blobdata & block_blob() const
Definition: wallet_errors.h:400
Definition: wallet_errors.h:489
const char *const failed_rpc_request_messages[]
Definition: wallet_errors.h:131
tx_not_constructed(std::string &&loc, sources_t const &sources, destinations_t const &destinations, cryptonote::network_type nettype)
Definition: wallet_errors.h:606
multisig_export_needed(std::string &&loc)
Definition: wallet_errors.h:210
Holds cryptonote related classes and helpers.
Definition: blockchain_db.cpp:44
cryptonote::transaction m_tx
Definition: wallet_errors.h:197
e
Definition: pymoduletest.py:79
Definition: wallet_errors.h:843
std::string to_string() const
Definition: wallet_errors.h:289
out_of_hashchain_bounds_error(std::string &&loc)
Definition: wallet_errors.h:442
uint64_t m_available
Definition: wallet_errors.h:566
Definition: wallet_errors.h:881
size_t m_mixin_count
Definition: wallet_errors.h:598
Definition: wallet_errors.h:208
invalid_pregenerated_random(std::string &&loc)
Definition: wallet_errors.h:324
Definition: wallet_errors.h:541
Definition: wallet_errors.h:964
const std::string & keys_file() const
Definition: wallet_errors.h:912
std::string to_string() const
Definition: wallet_errors.h:318
std::string to_string() const
Definition: wallet_errors.h:113
file_error_base< file_save_error_message_index > file_save_error
Definition: wallet_errors.h:280
Definition: wallet_errors.h:973
std::string to_string() const
Definition: wallet_errors.h:501
file_error_base< file_not_found_message_index > file_not_found
Definition: wallet_errors.h:278
Definition: wallet_errors.h:905
Definition: wallet_errors.h:801
Definition: wallet_errors.h:170
Various Tools.
Definition: apply_permutation.h:39
invalid_priority(std::string &&loc)
Definition: wallet_errors.h:293
Definition: wallet_errors.h:282
failed_rpc_request< refresh_error, get_hashes_error_message_index > get_hashes_error
Definition: wallet_errors.h:410
cryptonote::blobdata m_tx_blob
Definition: wallet_errors.h:427
Definition: wallet_errors.h:873
get_output_distribution(std::string &&loc, const std::string &request)
Definition: wallet_errors.h:891
const crypto::public_key & tx_pub_key() const
Definition: wallet_errors.h:375
std::string to_string() const
Definition: wallet_errors.h:308
Definition: cryptonote_tx_utils.h:42
const cryptonote::transaction & tx() const
Definition: wallet_errors.h:751
const cryptonote::transaction & tx() const
Definition: wallet_errors.h:186
account_index_outofbound(std::string &&loc)
Definition: wallet_errors.h:350
invalid_multisig_seed(std::string &&loc)
Definition: wallet_errors.h:303
refresh_error(std::string &&loc, const std::string &message)
Definition: wallet_errors.h:335
Definition: wallet_errors.h:322
std::string obj_to_json_str(T &obj)
Definition: cryptonote_format_utils.h:206
unsigned __int64 uint64_t
Definition: stdint.h:136
file_error_base< file_read_error_message_index > file_read_error
Definition: wallet_errors.h:279
std::string to_string() const
Definition: wallet_errors.h:156
wont_reprocess_recent_txs_via_untrusted_daemon(std::string &&loc)
Definition: wallet_errors.h:958
daemon_busy(std::string &&loc, const std::string &request)
Definition: wallet_errors.h:859
std::string to_string() const
Definition: wallet_errors.h:402
Definition: wallet_errors.h:232
std::string m_wallet_file
Definition: wallet_errors.h:919
uint64_t amount
Definition: cryptonote_tx_utils.h:77
const scanty_outs_t & scanty_outs() const
Definition: wallet_errors.h:582
not_enough_outs_to_mix(std::string &&loc, const scanty_outs_t &scanty_outs, size_t mixin_count)
Definition: wallet_errors.h:575
sources_t m_sources
Definition: wallet_errors.h:656
const std::string & status() const
Definition: wallet_errors.h:154
#define false
Definition: stdbool.h:37
get_tx_pool_error(std::string &&loc)
Definition: wallet_errors.h:432
Definition: wallet_errors.h:478
const cryptonote::account_keys m_acc_keys
Definition: wallet_errors.h:389
uint64_t available() const
Definition: wallet_errors.h:551
bool is_subaddress
Definition: cryptonote_tx_utils.h:79
Definition: account.h:40
get_histogram_error(std::string &&loc, const std::string &request)
Definition: wallet_errors.h:883
std::string to_string() const
Definition: wallet_errors.h:378
invalid_spend_key(std::string &&loc)
Definition: wallet_errors.h:313
zero_destination(std::string &&loc)
Definition: wallet_errors.h:786
std::string to_string() const
Definition: wallet_errors.h:437
Definition: wallet_errors.h:450
std::string to_string() const
Definition: wallet_errors.h:447
scan_tx_error(std::string &&loc, const std::string &message)
Definition: wallet_errors.h:950
POD_CLASS public_key
Definition: crypto.h:61
std::string m_reason
Definition: wallet_errors.h:691
const std::string & status() const
Definition: wallet_errors.h:851
wallet_error_base< std::logic_error > wallet_logic_error
Definition: wallet_errors.h:167
size_t mixin_count() const
Definition: wallet_errors.h:583
tx_rejected(std::string &&loc, const cryptonote::transaction &tx, const std::string &status, const std::string &reason)
Definition: wallet_errors.h:663
uint64_t m_tx_amount
Definition: wallet_errors.h:512
std::string m_request
Definition: wallet_errors.h:828
wallet_error_base(std::string &&loc, const std::string &message)
Definition: wallet_errors.h:121
wallet_coded_rpc_error(std::string &&loc, const std::string &request, int code, const std::string &status)
Definition: wallet_errors.h:845
Definition: wallet_errors.h:249
std::string to_string() const
Definition: wallet_errors.h:329
Definition: wallet_errors.h:109
const std::string & reason() const
Definition: wallet_errors.h:673
mms_error(std::string &&loc, const std::string &message)
Definition: wallet_errors.h:925
not_enough_unlocked_money(std::string &&loc, uint64_t available, uint64_t tx_amount, uint64_t fee)
Definition: wallet_errors.h:491
account_public_address addr
Definition: cryptonote_tx_utils.h:78
std::string blobdata
Definition: blobdatatype.h:39
std::string to_string() const
Definition: wallet_errors.h:585
Definition: get_output_distribution.py:1
uint64_t tx_amount() const
Definition: wallet_errors.h:525
const std::string & location() const
Definition: wallet_errors.h:111
std::string to_string() const
Definition: wallet_errors.h:467
network_type
Definition: cryptonote_config.h:301
uint32_t address
Definition: getifaddr.c:269
Definition: wallet_errors.h:200
const crypto::public_key m_tx_pub_key
Definition: wallet_errors.h:388
Definition: wallet_errors.h:784
Definition: wallet_errors.h:857
std::string to_string() const
Definition: wallet_errors.h:424
tx_too_big(std::string &&loc, uint64_t tx_weight, uint64_t tx_weight_limit)
Definition: wallet_errors.h:742
Definition: wallet_errors.h:515
const T & move(const T &t)
Definition: gtest-port.h:1317
const cryptonote::blobdata & tx_blob() const
Definition: wallet_errors.h:422
Definition: wallet_errors.h:224
failed_rpc_request(std::string &&loc, const std::string &status)
Definition: wallet_errors.h:148
password_entry_failed(std::string &&loc, const std::string &msg="Password entry failed")
Definition: wallet_errors.h:234
background_sync_error(std::string &&loc, const std::string &message)
Definition: wallet_errors.h:967
const std::string & status() const
Definition: wallet_errors.h:672
const std::string & wallet_file() const
Definition: wallet_errors.h:913
wallet_internal_error(std::string &&loc, const std::string &message)
Definition: wallet_errors.h:172
cryptonote::network_type m_nettype
Definition: wallet_errors.h:658
wallet_files_doesnt_correspond(std::string &&loc, const std::string &keys_file, const std::string &wallet_file)
Definition: wallet_errors.h:907
nonzero_unlock_time(std::string &&loc)
Definition: wallet_errors.h:803
incorrect_fork_version(std::string &&loc, const std::string &message)
Definition: wallet_errors.h:462
Definition: wallet_errors.h:216
Definition: wallet_errors.h:142
std::string to_string() const
Definition: wallet_errors.h:915
Definition: wallet_errors.h:291
cryptonote::blobdata m_block_blob
Definition: wallet_errors.h:405
std::string to_string() const
Definition: wallet_errors.h:555
const std::vector< cryptonote::tx_destination_entry > & destinations() const
Definition: wallet_errors.h:709
std::string to_string() const
Definition: wallet_errors.h:712
Definition: wallet_errors.h:301
std::string m_status
Definition: wallet_errors.h:164
Definition: cryptonote_tx_utils.h:74
int code() const
Definition: wallet_errors.h:850
uint64_t m_tx_amount
Definition: wallet_errors.h:538
uint64_t m_fee
Definition: wallet_errors.h:727
std::string to_string() const
Definition: wallet_errors.h:813
bool tx_valid() const
Definition: wallet_errors.h:750
failed_rpc_request< refresh_error, get_blocks_error_message_index > get_blocks_error
Definition: wallet_errors.h:408
std::string to_string() const
Definition: wallet_errors.h:188
const cryptonote::transaction & tx() const
Definition: wallet_errors.h:671
std::vector< cryptonote::tx_source_entry > sources_t
Definition: wallet_errors.h:603
multisig_import_needed(std::string &&loc)
Definition: wallet_errors.h:218
Definition: wallet_errors.h:661
payment_required(std::string &&loc, const std::string &request)
Definition: wallet_errors.h:899
scanty_outs_t m_scanty_outs
Definition: wallet_errors.h:597
signature_check_failed(std::string &&loc, const std::string &message)
Definition: wallet_errors.h:472
Definition: wallet_errors.h:140
failed_rpc_request< refresh_error, get_out_indices_error_message_index > get_out_indices_error
Definition: wallet_errors.h:412
uint64_t available() const
Definition: wallet_errors.h:498
failed_rpc_request_message_indices
Definition: wallet_errors.h:137
cryptonote::transaction m_tx
Definition: wallet_errors.h:770
std::string to_string(t_connection_type type)
Definition: connection_basic.cpp:70
Definition: wallet_errors.h:947
std::string print_money(uint64_t amount, unsigned int decimal_point)
Definition: cryptonote_format_utils.cpp:1180
const std::string m_status
Definition: wallet_errors.h:854
const cryptonote::transaction m_tx
Definition: wallet_errors.h:387
const std::string & status() const
Definition: wallet_errors.h:838
file_error_base(std::string &&loc, const std::string &file)
Definition: wallet_errors.h:257
file_error_message_indices
Definition: wallet_errors.h:246
unexpected_txin_type(std::string &&loc, const cryptonote::transaction &tx)
Definition: wallet_errors.h:180
Definition: wallet_errors.h:363
wallet_not_initialized(std::string &&loc)
Definition: wallet_errors.h:202
uint64_t available() const
Definition: wallet_errors.h:524
destinations_t m_destinations
Definition: wallet_errors.h:657
std::string to_string() const
Definition: wallet_errors.h:298
invalid_password(std::string &&loc)
Definition: wallet_errors.h:284
error
Tracks LMDB error codes.
Definition: error.h:44
tuple message
Definition: gtest_output_test.py:331
Definition: wallet_errors.h:776
file_error_base< file_exists_message_index > file_exists
Definition: wallet_errors.h:277
background_custom_password_same_as_wallet_password(std::string &&loc)
Definition: wallet_errors.h:983
Definition: cryptonote_basic.h:204
#define true
Definition: stdbool.h:36
std::string to_string() const
Definition: wallet_errors.h:271
Definition: wallet_errors.h:694
Definition: wallet_errors.h:251
Definition: wallet_errors.h:430
reorg_depth_error(std::string &&loc, const std::string &message)
Definition: wallet_errors.h:452
Definition: wallet_errors.h:392
const std::string m_status
Definition: wallet_errors.h:840
Definition: wallet_errors.h:922
const char *const file_error_messages[]
Definition: wallet_errors.h:240
uint64_t tx_amount() const
Definition: wallet_errors.h:499
background_wallet_already_open(std::string &&loc, const std::string &background_wallet_file)
Definition: wallet_errors.h:975
Definition: wallet_errors.h:460
tx_too_big(std::string &&loc, const cryptonote::transaction &tx, uint64_t tx_weight_limit)
Definition: wallet_errors.h:733
const sources_t & sources() const
Definition: wallet_errors.h:619