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