Scorum
wallet.cpp
Go to the documentation of this file.
1 #include <graphene/utilities/git_revision.hpp>
2 #include <graphene/utilities/key_conversion.hpp>
3 
4 #include <scorum/app/api.hpp>
11 
16 
18 
19 #include <algorithm>
20 #include <cctype>
21 #include <iomanip>
22 #include <iostream>
23 #include <iterator>
24 #include <sstream>
25 #include <string>
26 #include <list>
27 #include <cstdlib>
28 
29 #include <boost/version.hpp>
30 #include <boost/lexical_cast.hpp>
31 #include <boost/algorithm/string/replace.hpp>
32 
33 #include <boost/range/adaptor/map.hpp>
34 #include <boost/range/algorithm_ext/erase.hpp>
35 #include <boost/range/algorithm/unique.hpp>
36 #include <boost/range/algorithm/sort.hpp>
37 
38 #include <boost/multi_index_container.hpp>
39 #include <boost/multi_index/ordered_index.hpp>
40 #include <boost/multi_index/mem_fun.hpp>
41 #include <boost/multi_index/member.hpp>
42 #include <boost/multi_index/random_access_index.hpp>
43 #include <boost/multi_index/tag.hpp>
44 #include <boost/multi_index/sequenced_index.hpp>
45 #include <boost/multi_index/hashed_index.hpp>
46 
47 #include <fc/container/deque.hpp>
48 #include <fc/git_revision.hpp>
49 #include <fc/io/fstream.hpp>
50 #include <fc/io/json.hpp>
51 #include <fc/io/stdio.hpp>
52 #include <fc/network/http/websocket.hpp>
53 #include <fc/rpc/websocket_api.hpp>
54 #include <fc/crypto/aes.hpp>
55 #include <fc/crypto/hex.hpp>
56 #include <fc/thread/mutex.hpp>
57 #include <fc/thread/scoped_lock.hpp>
58 #include <fc/smart_ref_impl.hpp>
59 
60 #ifndef WIN32
61 #include <sys/types.h>
62 #include <sys/stat.h>
63 #endif
64 
65 #include <scorum/cli/formatter.hpp>
66 
67 namespace scorum {
68 namespace wallet {
69 
70 using namespace graphene::utilities;
71 
72 namespace detail {
73 
74 template <class T> optional<T> maybe_id(const std::string& name_or_id)
75 {
76  if (std::isdigit(name_or_id.front()))
77  {
78  try
79  {
80  return fc::variant(name_or_id).as<T>();
81  }
82  catch (const fc::exception&)
83  {
84  }
85  }
86  return optional<T>();
87 }
88 
90 {
91  int t = 0;
92  flat_map<std::string, operation>& name2op;
93 
94  op_prototype_visitor(int _t, flat_map<std::string, operation>& _prototype_ops)
95  : t(_t)
96  , name2op(_prototype_ops)
97  {
98  }
99 
100  template <typename Type> void operator()(const Type& op) const
101  {
102  std::string name = fc::get_typename<Type>::name();
103  size_t p = name.rfind(':');
104  if (p != std::string::npos)
105  name = name.substr(p + 1);
106  name2op[name] = Type();
107  }
108 };
109 
111 {
112 public:
114 
115 private:
116  void enable_umask_protection()
117  {
118 #ifdef __unix__
119  _old_umask = umask(S_IRWXG | S_IRWXO);
120 #endif
121  }
122 
123  void disable_umask_protection()
124  {
125 #ifdef __unix__
126  umask(_old_umask);
127 #endif
128  }
129 
130  void init_prototype_ops()
131  {
132  operation op;
133  for (int t = 0; t < op.count(); t++)
134  {
135  op.set_which(t);
136  op.visit(op_prototype_visitor(t, _prototype_ops));
137  }
138  }
139 
140 public:
141  wallet_api& self;
142  wallet_api_impl(wallet_api& s, const wallet_data& initial_data, fc::api<login_api> rapi)
143  : self(s)
144  , _chain_id(initial_data.chain_id)
145  , _remote_api(rapi)
146  , _remote_db(rapi->get_api_by_name(API_DATABASE)->as<database_api>())
147  , _chain_api(rapi->get_api_by_name(API_CHAIN)->as<chain_api>())
148  , _remote_net_broadcast(rapi->get_api_by_name("network_broadcast_api")->as<network_broadcast_api>())
149  {
150  init_prototype_ops();
151 
152  chain_id_type remote_chain_id = _remote_db->get_chain_id();
153  if (remote_chain_id != _chain_id)
154  {
155  FC_THROW("Remote server gave us an unexpected chain_id",
156  ("remote_chain_id", remote_chain_id)("chain_id", _chain_id));
157  }
158 
159  _wallet.ws_server = initial_data.ws_server;
160  _wallet.ws_user = initial_data.ws_user;
161  _wallet.ws_password = initial_data.ws_password;
162  _wallet.chain_id = initial_data.chain_id;
163  }
164 
166  {
167  }
168 
170  {
171  if (!is_locked())
172  {
173  plain_keys data;
174  data.keys = _keys;
175  data.checksum = _checksum;
176  auto plain_txt = fc::raw::pack(data);
177  _wallet.cipher_keys = fc::aes_encrypt(data.checksum, plain_txt);
178  }
179  }
180 
181  bool copy_wallet_file(const std::string& destination_filename)
182  {
183  fc::path src_path = get_wallet_filename();
184  if (!fc::exists(src_path))
185  return false;
186  fc::path dest_path = destination_filename + _wallet_filename_extension;
187  int suffix = 0;
188  while (fc::exists(dest_path))
189  {
190  ++suffix;
191  dest_path = destination_filename + "-" + std::to_string(suffix) + _wallet_filename_extension;
192  }
193  wlog("backing up wallet ${src} to ${dest}", ("src", src_path)("dest", dest_path));
194 
195  fc::path dest_parent = fc::absolute(dest_path).parent_path();
196  try
197  {
198  enable_umask_protection();
199  if (!fc::exists(dest_parent))
200  fc::create_directories(dest_parent);
201  fc::copy(src_path, dest_path);
202  disable_umask_protection();
203  }
204  catch (...)
205  {
206  disable_umask_protection();
207  throw;
208  }
209  return true;
210  }
211 
212  bool is_locked() const
213  {
214  return _checksum == fc::sha512();
215  }
216 
217  variant info() const
218  {
219  auto dynamic_props = _remote_db->get_dynamic_global_properties();
220 
221  fc::mutable_variant_object result = fc::variant(dynamic_props).get_object();
222 
223  result["witness_majority_version"] = fc::string(dynamic_props.majority_version);
224  result["hardfork_version"] = fc::string(_chain_api->get_chain_properties().hf_version);
225 
226  result["chain_properties"] = fc::variant(dynamic_props.median_chain_props).get_object();
227 
228  result["chain_id"] = _chain_id;
229  result["head_block_age"]
230  = fc::get_approximate_relative_time_string(dynamic_props.time, time_point_sec(time_point::now()), " old");
231 
232  result["participation"] = (100 * dynamic_props.recent_slots_filled.popcount()) / 128.0;
233 
234  return result;
235  }
236 
237  variant_object about() const
238  {
239  std::string client_version(graphene::utilities::git_revision_description);
240  const size_t pos = client_version.find('/');
241  if (pos != std::string::npos && client_version.size() > pos)
242  client_version = client_version.substr(pos + 1);
243 
244  fc::mutable_variant_object result;
245  result["blockchain_version"] = SCORUM_BLOCKCHAIN_VERSION;
246  result["client_version"] = client_version;
247  result["scorum_revision"] = graphene::utilities::git_revision_sha;
248  result["scorum_revision_age"] = fc::get_approximate_relative_time_string(
249  fc::time_point_sec(graphene::utilities::git_revision_unix_timestamp));
250  result["fc_revision"] = fc::git_revision_sha;
251  result["fc_revision_age"]
252  = fc::get_approximate_relative_time_string(fc::time_point_sec(fc::git_revision_unix_timestamp));
253  result["compile_date"] = "compiled on " __DATE__ " at " __TIME__;
254  result["boost_version"] = boost::replace_all_copy(std::string(BOOST_LIB_VERSION), "_", ".");
255  result["openssl_version"] = OPENSSL_VERSION_TEXT;
256 
257  std::string bitness = boost::lexical_cast<std::string>(8 * sizeof(int*)) + "-bit";
258 #if defined(__APPLE__)
259  std::string os = "osx";
260 #elif defined(__linux__)
261  std::string os = "linux";
262 #elif defined(_MSC_VER)
263  std::string os = "win32";
264 #else
265  std::string os = "other";
266 #endif
267  result["build"] = os + " " + bitness;
268 
269  try
270  {
271  auto v = _remote_api->get_version();
272  result["server_blockchain_version"] = v.blockchain_version;
273  result["server_scorum_revision"] = v.scorum_revision;
274  result["server_fc_revision"] = v.fc_revision;
275  }
276  catch (fc::exception&)
277  {
278  result["server"] = "could not retrieve server version information";
279  }
280 
281  return result;
282  }
283 
284  account_api_obj get_account(const std::string& account_name) const
285  {
286  auto accounts = _remote_db->get_accounts({ account_name });
287  FC_ASSERT(!accounts.empty(), "Unknown account");
288  return accounts.front();
289  }
290 
291  std::string get_wallet_filename() const
292  {
293  return _wallet_filename;
294  }
295 
296  optional<fc::ecc::private_key> try_get_private_key(const public_key_type& id) const
297  {
298  auto it = _keys.find(id);
299  if (it != _keys.end())
300  return wif_to_key(it->second);
301  return optional<fc::ecc::private_key>();
302  }
303 
304  fc::ecc::private_key get_private_key(const public_key_type& id) const
305  {
306  auto has_key = try_get_private_key(id);
307  FC_ASSERT(has_key);
308  return *has_key;
309  }
310 
311  fc::ecc::private_key get_private_key_for_account(const account_api_obj& account) const
312  {
313  std::vector<public_key_type> active_keys = account.active.get_keys();
314  if (active_keys.size() != 1)
315  FC_THROW("Expecting a simple authority with one active key");
316  return get_private_key(active_keys.front());
317  }
318 
319  // imports the private key into the wallet, and associate it in some way (?) with the
320  // given account name.
321  // @returns true if the key matches a current active/owner/memo key for the named
322  // account, false otherwise (but it is stored either way)
323  bool import_key(const std::string& wif_key)
324  {
325  fc::optional<fc::ecc::private_key> optional_private_key = wif_to_key(wif_key);
326  if (!optional_private_key)
327  FC_THROW("Invalid private key");
328  scorum::chain::public_key_type wif_pub_key = optional_private_key->get_public_key();
329 
330  _keys[wif_pub_key] = wif_key;
331  return true;
332  }
333 
334  // TODO: Needs refactoring
335  bool load_wallet_file(std::string wallet_filename = "")
336  {
337  // TODO: Merge imported wallet with existing wallet,
338  // instead of replacing it
339  if (wallet_filename == "")
340  wallet_filename = _wallet_filename;
341 
342  if (!fc::exists(wallet_filename))
343  return false;
344 
345  _wallet = fc::json::from_file(wallet_filename).as<wallet_data>();
346 
347  return true;
348  }
349 
350  // TODO: Needs refactoring
351  void save_wallet_file(std::string wallet_filename = "")
352  {
353  //
354  // Serialize in memory, then save to disk
355  //
356  // This approach lessens the risk of a partially written wallet
357  // if exceptions are thrown in serialization
358  //
359 
360  encrypt_keys();
361 
362  if (wallet_filename == "")
363  wallet_filename = _wallet_filename;
364 
365  wlog("saving wallet to file ${fn}", ("fn", wallet_filename));
366 
367  std::string data = fc::json::to_pretty_string(_wallet);
368  try
369  {
370  enable_umask_protection();
371  //
372  // Parentheses on the following declaration fails to compile,
373  // due to the Most Vexing Parse. Thanks, C++
374  //
375  // http://en.wikipedia.org/wiki/Most_vexing_parse
376  //
377  fc::ofstream outfile{ fc::path(wallet_filename) };
378  outfile.write(data.c_str(), data.length());
379  outfile.flush();
380  outfile.close();
381  disable_umask_protection();
382  }
383  catch (...)
384  {
385  disable_umask_protection();
386  throw;
387  }
388  }
389 
390  // This function generates derived keys starting with index 0 and keeps incrementing
391  // the index until it finds a key that isn't registered in the block chain. To be
392  // safer, it continues checking for a few more keys to make sure there wasn't a short gap
393  // caused by a failed registration or the like.
394  int find_first_unused_derived_key_index(const fc::ecc::private_key& parent_key)
395  {
396  int first_unused_index = 0;
397  int number_of_consecutive_unused_keys = 0;
398  for (int key_index = 0;; ++key_index)
399  {
400  fc::ecc::private_key derived_private_key = derive_private_key(key_to_wif(parent_key), key_index);
401  scorum::chain::public_key_type derived_public_key = derived_private_key.get_public_key();
402  if (_keys.find(derived_public_key) == _keys.end())
403  {
404  if (number_of_consecutive_unused_keys)
405  {
406  ++number_of_consecutive_unused_keys;
407  if (number_of_consecutive_unused_keys > 5)
408  return first_unused_index;
409  }
410  else
411  {
412  first_unused_index = key_index;
413  number_of_consecutive_unused_keys = 1;
414  }
415  }
416  else
417  {
418  // key_index is used
419  first_unused_index = 0;
420  number_of_consecutive_unused_keys = 0;
421  }
422  }
423  }
424 
425  signed_transaction create_account_with_private_key(fc::ecc::private_key owner_privkey,
426  const std::string& account_name,
427  const std::string& creator_account_name,
428  bool broadcast = false,
429  bool save_wallet = true)
430  {
431  try
432  {
433  int active_key_index = find_first_unused_derived_key_index(owner_privkey);
434  fc::ecc::private_key active_privkey = derive_private_key(key_to_wif(owner_privkey), active_key_index);
435 
436  int memo_key_index = find_first_unused_derived_key_index(active_privkey);
437  fc::ecc::private_key memo_privkey = derive_private_key(key_to_wif(active_privkey), memo_key_index);
438 
439  scorum::chain::public_key_type owner_pubkey = owner_privkey.get_public_key();
440  scorum::chain::public_key_type active_pubkey = active_privkey.get_public_key();
441  scorum::chain::public_key_type memo_pubkey = memo_privkey.get_public_key();
442 
443  account_create_operation account_create_op;
444 
445  account_create_op.creator = creator_account_name;
446  account_create_op.new_account_name = account_name;
447  account_create_op.fee = _chain_api->get_chain_properties().median_chain_props.account_creation_fee;
448  account_create_op.owner = authority(1, owner_pubkey, 1);
449  account_create_op.active = authority(1, active_pubkey, 1);
450  account_create_op.memo_key = memo_pubkey;
451 
453 
454  tx.operations.push_back(account_create_op);
455  tx.validate();
456 
457  if (save_wallet)
458  save_wallet_file();
459  if (broadcast)
460  {
461  //_remote_net_broadcast->broadcast_transaction( tx );
462  auto result = _remote_net_broadcast->broadcast_transaction_synchronous(tx);
463  }
464  return tx;
465  }
466  FC_CAPTURE_AND_RETHROW((account_name)(creator_account_name)(broadcast)(save_wallet))
467  }
468 
470  set_voting_proxy(const std::string& account_to_modify, const std::string& proxy, bool broadcast /* = false */)
471  {
472  try
473  {
475  op.account = account_to_modify;
476  op.proxy = proxy;
477 
479  tx.operations.push_back(op);
480  tx.validate();
481 
482  return sign_transaction(tx, broadcast);
483  }
484  FC_CAPTURE_AND_RETHROW((account_to_modify)(proxy)(broadcast))
485  }
486 
487  optional<witness_api_obj> get_witness(const std::string& owner_account)
488  {
489  return _remote_db->get_witness_by_account(owner_account);
490  }
491 
492  void set_transaction_expiration(uint32_t tx_expiration_seconds)
493  {
494  FC_ASSERT(tx_expiration_seconds < SCORUM_MAX_TIME_UNTIL_EXPIRATION);
495  _tx_expiration_seconds = tx_expiration_seconds;
496  }
497 
499  {
500  flat_set<account_name_type> req_active_approvals;
501  flat_set<account_name_type> req_owner_approvals;
502  flat_set<account_name_type> req_posting_approvals;
503  std::vector<authority> other_auths;
504 
505  tx.get_required_authorities(req_active_approvals, req_owner_approvals, req_posting_approvals, other_auths);
506 
507  for (const auto& auth : other_auths)
508  for (const auto& a : auth.account_auths)
509  req_active_approvals.insert(a.first);
510 
511  // std::merge lets us de-duplicate account_id's that occur in both
512  // sets, and dump them into a vector (as required by remote_db api)
513  // at the same time
514  std::vector<std::string> v_approving_account_names;
515  std::merge(req_active_approvals.begin(), req_active_approvals.end(), req_owner_approvals.begin(),
516  req_owner_approvals.end(), std::back_inserter(v_approving_account_names));
517 
518  for (const auto& a : req_posting_approvals)
519  v_approving_account_names.push_back(a);
520 
522 
523  auto approving_account_objects = _remote_db->get_accounts(v_approving_account_names);
524 
526 
527  FC_ASSERT(approving_account_objects.size() == v_approving_account_names.size(), "",
528  ("aco.size:", approving_account_objects.size())("acn", v_approving_account_names.size()));
529 
530  flat_map<std::string, account_api_obj> approving_account_lut;
531  size_t i = 0;
532  for (const optional<account_api_obj> approving_acct : approving_account_objects)
533  {
534  if (!approving_acct.valid())
535  {
536  wlog("operation_get_required_auths said approval of non-existing account ${name} was needed",
537  ("name", v_approving_account_names[i]));
538  i++;
539  continue;
540  }
541  approving_account_lut[approving_acct->name] = *approving_acct;
542  i++;
543  }
544 
545  flat_set<public_key_type> approving_key_set;
546  for (account_name_type& acct_name : req_active_approvals)
547  {
548  const auto it = approving_account_lut.find(acct_name);
549  if (it == approving_account_lut.end())
550  continue;
551  const account_api_obj& acct = it->second;
552  std::vector<public_key_type> v_approving_keys = acct.active.get_keys();
553  wdump((v_approving_keys));
554  for (const public_key_type& approving_key : v_approving_keys)
555  {
556  wdump((approving_key));
557  approving_key_set.insert(approving_key);
558  }
559  }
560 
561  for (account_name_type& acct_name : req_posting_approvals)
562  {
563  const auto it = approving_account_lut.find(acct_name);
564  if (it == approving_account_lut.end())
565  continue;
566  const account_api_obj& acct = it->second;
567  std::vector<public_key_type> v_approving_keys = acct.posting.get_keys();
568  wdump((v_approving_keys));
569  for (const public_key_type& approving_key : v_approving_keys)
570  {
571  wdump((approving_key));
572  approving_key_set.insert(approving_key);
573  }
574  }
575 
576  for (const account_name_type& acct_name : req_owner_approvals)
577  {
578  const auto it = approving_account_lut.find(acct_name);
579  if (it == approving_account_lut.end())
580  continue;
581  const account_api_obj& acct = it->second;
582  std::vector<public_key_type> v_approving_keys = acct.owner.get_keys();
583  for (const public_key_type& approving_key : v_approving_keys)
584  {
585  wdump((approving_key));
586  approving_key_set.insert(approving_key);
587  }
588  }
589  for (const authority& a : other_auths)
590  {
591  for (const auto& k : a.key_auths)
592  {
593  wdump((k.first));
594  approving_key_set.insert(k.first);
595  }
596  }
597 
598  auto dyn_props = _remote_db->get_dynamic_global_properties();
599  tx.set_reference_block(dyn_props.head_block_id);
600  tx.set_expiration(dyn_props.time + fc::seconds(_tx_expiration_seconds));
601  tx.signatures.clear();
602 
603  // idump((_keys));
604  flat_set<public_key_type> available_keys;
605  flat_map<public_key_type, fc::ecc::private_key> available_private_keys;
606  for (const public_key_type& key : approving_key_set)
607  {
608  auto it = _keys.find(key);
609  if (it != _keys.end())
610  {
611  fc::optional<fc::ecc::private_key> privkey = wif_to_key(it->second);
612  FC_ASSERT(privkey.valid(), "Malformed private key in _keys");
613  available_keys.insert(key);
614  available_private_keys[key] = *privkey;
615  }
616  }
617 
618  auto get_account_from_lut = [&](const std::string& name) -> const account_api_obj& {
619  auto it = approving_account_lut.find(name);
620  FC_ASSERT(it != approving_account_lut.end());
621  return it->second;
622  };
623 
624  auto minimal_signing_keys = tx.minimize_required_signatures(
625  _chain_id, available_keys,
626  [&](const std::string& account_name) -> const authority& {
627  return (get_account_from_lut(account_name).active);
628  },
629  [&](const std::string& account_name) -> const authority& {
630  return (get_account_from_lut(account_name).owner);
631  },
632  [&](const std::string& account_name) -> const authority& {
633  return (get_account_from_lut(account_name).posting);
634  },
635  SCORUM_MAX_SIG_CHECK_DEPTH);
636 
637  for (const public_key_type& k : minimal_signing_keys)
638  {
639  auto it = available_private_keys.find(k);
640  FC_ASSERT(it != available_private_keys.end());
641  tx.sign(it->second, _chain_id);
642  }
643 
644  if (broadcast)
645  {
646  try
647  {
648  auto result = _remote_net_broadcast->broadcast_transaction_synchronous(tx);
650  rtrx.block_num = result.get_object()["block_num"].as_uint64();
651  rtrx.transaction_num = result.get_object()["trx_num"].as_uint64();
652  return rtrx;
653  }
654  catch (const fc::exception& e)
655  {
656  elog("Caught exception while broadcasting tx ${id}: ${e}",
657  ("id", tx.id().str())("e", e.to_detail_string()));
658  throw;
659  }
660  }
661  return tx;
662  }
663 
664  std::string print_atomicswap_secret2str(const std::string& secret) const
665  {
666  cli::formatter p;
667 
668  p.print_line();
669  p.print_field("SECRET: ", secret);
670 
671  return p.str();
672  }
673 
675  {
676  cli::formatter p;
677 
678  p.print_line();
679 
680  if (rt.contract_initiator)
681  {
682  p.print_raw("INITIATION CONTRACT");
683  }
684  else
685  {
686  p.print_raw("* PARTICIPATION CONTRACT");
687  }
688 
689  p.print_line();
690  p.print_field("From: ", rt.owner);
691  p.print_field("To: ", rt.to);
692  p.print_field("Amount: ", rt.amount);
693 
694  if (rt.deadline.sec_since_epoch())
695  {
696  p.print_field("Locktime: ", rt.deadline.to_iso_string());
697 
698  time_point_sec now = rt.deadline;
699  now -= fc::time_point::now().sec_since_epoch();
700  int h = now.sec_since_epoch() / 3600;
701  int m = now.sec_since_epoch() % 3600 / 60;
702  int s = now.sec_since_epoch() % 60;
703  p.print_field("Locktime reached in: ", p.print_sequence2str(h, 'h', m, 'm', s, 's'));
704  }
705 
706  if (!rt.secret.empty())
707  {
708  p.print_raw(print_atomicswap_secret2str(rt.secret));
709  }
710 
711  p.print_line();
712  p.print_field("Secret Hash: ", rt.secret_hash);
713 
714  if (!rt.metadata.empty())
715  {
716  p.print_line();
717  p.print_field("Metadata: ", rt.metadata);
718  }
719 
720  return p.str();
721  }
722 
723  std::map<std::string, std::function<std::string(fc::variant, const fc::variants&)>> get_result_formatters() const
724  {
725  std::map<std::string, std::function<std::string(fc::variant, const fc::variants&)>> m;
726  m["help"] = [](variant result, const fc::variants& a) { return result.get_string(); };
727 
728  m["gethelp"] = [](variant result, const fc::variants& a) { return result.get_string(); };
729 
730  m["list_my_accounts"] = [](variant result, const fc::variants& a) {
731  auto accounts = result.as<std::vector<account_api_obj>>();
732 
733  cli::formatter p;
734 
735  asset total_scorum(0, SCORUM_SYMBOL);
736  asset total_vest(0, SP_SYMBOL);
737 
738  FC_ASSERT(p.create_table(16, 20, 10, 20));
739 
740  for (const auto& a : accounts)
741  {
742  total_scorum += a.balance;
743  total_vest += a.scorumpower;
744  p.print_cell(a.name);
745  p.print_cell(a.balance);
746  p.print_cell("");
747  p.print_cell(a.scorumpower);
748  }
749  p.print_endl();
750  p.print_line('-', accounts.empty());
751  p.print_cell("TOTAL");
752  p.print_cell(total_scorum);
753  p.print_cell("");
754  p.print_cell(total_vest);
755 
756  return p.str();
757  };
758  m["get_account_balance"] = [](variant result, const fc::variants& a) -> std::string {
759  auto rt = result.as<account_balance_info_api_obj>();
760 
761  cli::formatter p;
762 
763  FC_ASSERT(p.create_table(16, 20, 10, 20));
764 
765  p.print_line();
766  p.print_cell("Scorums:");
767  p.print_cell(rt.balance);
768  p.print_cell("Vests:");
769  p.print_cell(rt.scorumpower);
770 
771  return p.str();
772  };
773 
774  auto history_formatter = [](variant result, const fc::variants& a) {
775  const auto& results = result.get_array();
776 
777  cli::formatter p;
778 
779  FC_ASSERT(p.create_table(5, 10, 15, 20, 50));
780 
781  p.print_cell("#");
782  p.print_cell("BLOCK #");
783  p.print_cell("TRX ID");
784  p.print_cell("OPERATION");
785  p.print_cell("DETAILS");
786  p.print_endl();
787  p.print_line('-', false);
788 
789  for (const auto& item : results)
790  {
791  p.print_cell(item.get_array()[0].as_string());
792  const auto& op = item.get_array()[1].get_object();
793  p.print_cell(op["block"].as_string());
794  p.print_cell(op["trx_id"].as_string());
795  const auto& opop = op["op"].get_array();
796  p.print_cell(opop[0].as_string());
797  p.print_cell(fc::json::to_string(opop[1]));
798  }
799  return p.str();
800  };
801 
802  m["get_account_history"] = history_formatter;
803  m["get_account_scr_to_scr_transfers"] = history_formatter;
804  m["get_account_scr_to_sp_transfers"] = history_formatter;
805  m["get_account_sp_to_scr_transfers"] = history_formatter;
806 
807  m["get_devcommittee_history"] = history_formatter;
808  m["get_devcommittee_scr_to_scr_transfers"] = history_formatter;
809  m["get_devcommittee_sp_to_scr_transfers"] = history_formatter;
810 
811  m["get_withdraw_routes"] = [](variant result, const fc::variants& a) {
812  auto routes = result.as<std::vector<withdraw_route>>();
813 
814  cli::formatter p;
815 
816  FC_ASSERT(p.create_table(20, 20, 8, 9));
817 
818  p.print_cell("From");
819  p.print_cell("To");
820  p.print_cell("Percent");
821  p.print_cell("Auto-Vest");
822  p.print_endl();
823  p.print_line('=', false);
824 
825  for (auto r : routes)
826  {
827  p.print_cell(r.from_account);
828  p.print_cell(r.to_account);
829  std::stringstream tmp;
830  tmp << std::setprecision(2) << std::fixed << double(r.percent) / 100;
831  p.print_cell(tmp.str());
832  p.print_cell((r.auto_vest ? "true" : "false"));
833  }
834 
835  return p.str();
836  };
837  m["atomicswap_initiate"] = [this](variant result, const fc::variants& a) -> std::string {
839  if (rt.empty())
840  {
841  return "";
842  }
843  else
844  {
845  return print_atomicswap_contract2str(rt.obj);
846  }
847  };
848  m["atomicswap_participate"] = [this](variant result, const fc::variants& a) -> std::string {
850  if (rt.empty())
851  {
852  return "";
853  }
854  else
855  {
856  return print_atomicswap_contract2str(rt.obj);
857  }
858  };
859  m["atomicswap_auditcontract"] = [this](variant result, const fc::variants& a) -> std::string {
861  if (rt.empty())
862  {
863  return "Nothing to audit.";
864  }
865  else
866  {
867  return print_atomicswap_contract2str(rt);
868  }
869  };
870  m["atomicswap_extractsecret"] = [this](variant result, const fc::variants& a) -> std::string {
871  auto secret = result.as<std::string>();
872  if (secret.empty())
873  {
874  return "";
875  }
876  else
877  {
878  return print_atomicswap_secret2str(secret);
879  }
880  };
881 
882  return m;
883  }
884 
886  {
887  if (_remote_net_node)
888  return;
889  try
890  {
891  _remote_net_node = _remote_api->get_api_by_name("network_node_api")->as<network_node_api>();
892  }
893  catch (const fc::exception& e)
894  {
895  elog("Couldn't get network_node_api");
896  throw(e);
897  }
898  }
899 
901  {
902  if (_remote_account_by_key_api.valid())
903  return;
904 
905  try
906  {
907  _remote_account_by_key_api
908  = _remote_api->get_api_by_name("account_by_key_api")->as<account_by_key::account_by_key_api>();
909  }
910  catch (const fc::exception& e)
911  {
912  elog("Couldn't get account_by_key_api");
913  throw(e);
914  }
915  }
916 
918  {
919  if (_remote_account_history_api.valid())
920  return;
921 
922  try
923  {
924  _remote_account_history_api
925  = _remote_api->get_api_by_name(API_ACCOUNT_HISTORY)->as<blockchain_history::account_history_api>();
926  }
927  catch (const fc::exception& e)
928  {
929  elog("Couldn't get account_history_api");
930  throw(e);
931  }
932  }
933 
935  {
936  if (_remote_devcommittee_history_api.valid())
937  return;
938 
939  try
940  {
941  _remote_devcommittee_history_api = _remote_api->get_api_by_name(API_DEVCOMMITTEE_HISTORY)
943  }
944  catch (const fc::exception& e)
945  {
946  elog("Couldn't get devcommittee_history_api");
947  throw(e);
948  }
949  }
950 
952  {
953  if (_remote_blockchain_history_api.valid())
954  return;
955 
956  try
957  {
958  _remote_blockchain_history_api = _remote_api->get_api_by_name(API_BLOCKCHAIN_HISTORY)
960  }
961  catch (const fc::exception& e)
962  {
963  elog("Couldn't get blockchain_history_api");
964  throw(e);
965  }
966  }
967 
968  void network_add_nodes(const std::vector<std::string>& nodes)
969  {
970  use_network_node_api();
971  for (const std::string& node_address : nodes)
972  {
973  (*_remote_net_node)->add_node(fc::ip::endpoint::from_string(node_address));
974  }
975  }
976 
977  std::vector<variant> network_get_connected_peers()
978  {
979  use_network_node_api();
980  const auto peers = (*_remote_net_node)->get_connected_peers();
981  std::vector<variant> result;
982  result.reserve(peers.size());
983  for (const auto& peer : peers)
984  {
985  variant v;
986  fc::to_variant(peer, v);
987  result.push_back(v);
988  }
989  return result;
990  }
991 
992  operation get_prototype_operation(const std::string& operation_name)
993  {
994  auto it = _prototype_ops.find(operation_name);
995  if (it == _prototype_ops.end())
996  FC_THROW("Unsupported operation: \"${operation_name}\"", ("operation_name", operation_name));
997  return it->second;
998  }
999 
1000  std::string _wallet_filename;
1002 
1003  std::map<public_key_type, std::string> _keys;
1004  fc::sha512 _checksum;
1005 
1007 
1008  fc::api<login_api> _remote_api;
1009  fc::api<database_api> _remote_db;
1010  fc::api<chain_api> _chain_api;
1011  fc::api<network_broadcast_api> _remote_net_broadcast;
1012  optional<fc::api<network_node_api>> _remote_net_node;
1013  optional<fc::api<account_by_key::account_by_key_api>> _remote_account_by_key_api;
1014  optional<fc::api<blockchain_history::account_history_api>> _remote_account_history_api;
1015  optional<fc::api<blockchain_history::blockchain_history_api>> _remote_blockchain_history_api;
1016  optional<fc::api<blockchain_history::devcommittee_history_api>> _remote_devcommittee_history_api;
1017 
1018  uint32_t _tx_expiration_seconds = 30;
1019 
1020  flat_map<std::string, operation> _prototype_ops;
1021 
1022  static_variant_map _operation_which_map = create_static_variant_map<operation>();
1023 
1024 #ifdef __unix__
1025  mode_t _old_umask;
1026 #endif
1027  const std::string _wallet_filename_extension = ".wallet";
1028 };
1029 
1030 } // namespace detail
1031 
1032 wallet_api::wallet_api(const wallet_data& initial_data, fc::api<login_api> rapi)
1033  : my(new detail::wallet_api_impl(*this, initial_data, rapi))
1034  , exit_func([]() { FC_ASSERT(false, "Operation valid only in console mode."); })
1035 {
1036 }
1037 
1039 {
1040 }
1041 
1043 {
1044  exit_func = fn;
1045 }
1046 
1047 bool wallet_api::copy_wallet_file(const std::string& destination_filename)
1048 {
1049  return my->copy_wallet_file(destination_filename);
1050 }
1051 
1052 optional<block_header> wallet_api::get_block_header(uint32_t num) const
1053 {
1054  my->use_remote_blockchain_history_api();
1055 
1056  return (*my->_remote_blockchain_history_api)->get_block_header(num);
1057 }
1058 
1059 optional<signed_block_api_obj> wallet_api::get_block(uint32_t num) const
1060 {
1061  my->use_remote_blockchain_history_api();
1062 
1063  return (*my->_remote_blockchain_history_api)->get_block(num);
1064 }
1065 
1066 std::map<uint32_t, block_header> wallet_api::get_block_headers_history(uint32_t num, uint32_t limit) const
1067 {
1068  my->use_remote_blockchain_history_api();
1069 
1070  return (*my->_remote_blockchain_history_api)->get_block_headers_history(num, limit);
1071 }
1072 
1073 std::map<uint32_t, signed_block_api_obj> wallet_api::get_blocks_history(uint32_t num, uint32_t limit) const
1074 {
1075  my->use_remote_blockchain_history_api();
1076 
1077  return (*my->_remote_blockchain_history_api)->get_blocks_history(num, limit);
1078 }
1079 
1080 std::map<uint32_t, applied_operation> wallet_api::get_ops_in_block(uint32_t block_num,
1081  applied_operation_type type_of_operation) const
1082 {
1083  my->use_remote_blockchain_history_api();
1084 
1085  return (*my->_remote_blockchain_history_api)->get_ops_in_block(block_num, type_of_operation);
1086 }
1087 
1088 std::map<uint32_t, applied_operation>
1089 wallet_api::get_ops_history(uint32_t from_op, uint32_t limit, applied_operation_type type_of_operation) const
1090 {
1091  my->use_remote_blockchain_history_api();
1092 
1093  return (*my->_remote_blockchain_history_api)->get_ops_history(from_op, limit, type_of_operation);
1094 }
1095 
1096 std::map<uint32_t, applied_operation> wallet_api::get_ops_history_by_time(const fc::time_point_sec& from,
1097  const fc::time_point_sec& to,
1098  uint32_t from_op,
1099  uint32_t limit) const
1100 {
1101  my->use_remote_blockchain_history_api();
1102 
1103  return (*my->_remote_blockchain_history_api)->get_ops_history_by_time(from, to, from_op, limit);
1104 }
1105 
1106 std::vector<block_api_object> wallet_api::get_blocks(uint32_t from, uint32_t limit) const
1107 {
1108  my->use_remote_blockchain_history_api();
1109 
1110  return (*my->_remote_blockchain_history_api)->get_blocks(from, limit);
1111 }
1112 
1113 std::vector<account_api_obj> wallet_api::list_my_accounts()
1114 {
1115  FC_ASSERT(!is_locked(), "Wallet must be unlocked to list accounts");
1116  std::vector<account_api_obj> result;
1117 
1118  my->use_remote_account_by_key_api();
1119 
1120  std::vector<public_key_type> pub_keys;
1121  pub_keys.reserve(my->_keys.size());
1122 
1123  for (const auto& item : my->_keys)
1124  pub_keys.push_back(item.first);
1125 
1126  auto refs = (*my->_remote_account_by_key_api)->get_key_references(pub_keys);
1127  std::set<std::string> names;
1128  for (const auto& item : refs)
1129  for (const auto& name : item)
1130  names.insert(name);
1131 
1132  result.reserve(names.size());
1133  for (const auto& name : names)
1134  result.emplace_back(get_account(name));
1135 
1136  return result;
1137 }
1138 
1139 std::set<std::string> wallet_api::list_accounts(const std::string& lowerbound, uint32_t limit)
1140 {
1141  return my->_remote_db->lookup_accounts(lowerbound, limit);
1142 }
1143 
1144 std::vector<account_name_type> wallet_api::get_active_witnesses() const
1145 {
1146  return my->_remote_db->get_active_witnesses();
1147 }
1148 
1150 {
1151  return fc::to_hex(fc::raw::pack(tx));
1152 }
1153 
1155 {
1156  return my->get_wallet_filename();
1157 }
1158 
1159 account_api_obj wallet_api::get_account(const std::string& account_name) const
1160 {
1161  return my->get_account(account_name);
1162 }
1163 
1165 {
1166  return my->get_account(account_name);
1167 }
1168 
1169 bool wallet_api::import_key(const std::string& wif_key)
1170 {
1171  FC_ASSERT(!is_locked());
1172  // backup wallet
1173  fc::optional<fc::ecc::private_key> optional_private_key = wif_to_key(wif_key);
1174  if (!optional_private_key)
1175  FC_THROW("Invalid private key");
1176  // string shorthash = detail::pubkey_to_shorthash( optional_private_key->get_public_key() );
1177  // copy_wallet_file( "before-import-key-" + shorthash );
1178 
1179  if (my->import_key(wif_key))
1180  {
1181  save_wallet_file();
1182  // copy_wallet_file( "after-import-key-" + shorthash );
1183  return true;
1184  }
1185  return false;
1186 }
1187 
1188 std::string wallet_api::normalize_brain_key(const std::string& s) const
1189 {
1191 }
1192 
1194 {
1195  return my->info();
1196 }
1197 
1198 variant_object wallet_api::about() const
1199 {
1200  return my->about();
1201 }
1202 
1203 std::set<account_name_type> wallet_api::list_witnesses(const std::string& lowerbound, uint32_t limit)
1204 {
1205  return my->_remote_db->lookup_witness_accounts(lowerbound, limit);
1206 }
1207 
1208 optional<witness_api_obj> wallet_api::get_witness(const std::string& owner_account)
1209 {
1210  return my->get_witness(owner_account);
1211 }
1212 
1213 annotated_signed_transaction wallet_api::set_voting_proxy(const std::string& account_to_modify,
1214  const std::string& voting_account,
1215  bool broadcast /* = false */)
1216 {
1217  return my->set_voting_proxy(account_to_modify, voting_account, broadcast);
1218 }
1219 
1220 void wallet_api::set_wallet_filename(const std::string& wallet_filename)
1221 {
1222  my->_wallet_filename = wallet_filename;
1223 }
1224 
1226 {
1228 }
1229 
1231 {
1232  try
1233  {
1234  return my->sign_transaction(tx, broadcast);
1235  }
1236  FC_CAPTURE_AND_RETHROW((tx))
1237 }
1238 
1239 operation wallet_api::get_prototype_operation(const std::string& operation_name)
1240 {
1241  return my->get_prototype_operation(operation_name);
1242 }
1243 
1244 void wallet_api::network_add_nodes(const std::vector<std::string>& nodes)
1245 {
1246  my->network_add_nodes(nodes);
1247 }
1248 
1250 {
1251  return my->network_get_connected_peers();
1252 }
1253 
1254 std::string wallet_api::help() const
1255 {
1256  std::vector<std::string> method_names = my->method_documentation.get_method_names();
1257  std::stringstream ss;
1258  for (const std::string& method_name : method_names)
1259  {
1260  try
1261  {
1262  ss << my->method_documentation.get_brief_description(method_name);
1263  }
1264  catch (const fc::key_not_found_exception&)
1265  {
1266  ss << method_name << " (no help available)\n";
1267  }
1268  }
1269  return ss.str();
1270 }
1271 
1272 std::string wallet_api::gethelp(const std::string& method) const
1273 {
1274  fc::api<wallet_api> tmp;
1275  std::stringstream ss;
1276  ss << "\n";
1277 
1278  std::string doxygenHelpString = my->method_documentation.get_detailed_description(method);
1279  if (!doxygenHelpString.empty())
1280  ss << doxygenHelpString;
1281  else
1282  ss << "No help defined for method " << method << "\n";
1283 
1284  return ss.str();
1285 }
1286 
1287 bool wallet_api::load_wallet_file(const std::string& wallet_filename)
1288 {
1289  return my->load_wallet_file(wallet_filename);
1290 }
1291 
1292 void wallet_api::save_wallet_file(const std::string& wallet_filename)
1293 {
1294  my->save_wallet_file(wallet_filename);
1295 }
1296 
1297 std::map<std::string, std::function<std::string(fc::variant, const fc::variants&)>>
1299 {
1300  return my->get_result_formatters();
1301 }
1302 
1304 {
1305  return my->is_locked();
1306 }
1308 {
1309  return my->_wallet.cipher_keys.size() == 0;
1310 }
1311 
1313 {
1314  my->encrypt_keys();
1315 }
1316 
1318 {
1319  try
1320  {
1321  FC_ASSERT(!is_locked());
1322  encrypt_keys();
1323  for (auto key : my->_keys)
1324  key.second = key_to_wif(fc::ecc::private_key());
1325  my->_keys.clear();
1326  my->_checksum = fc::sha512();
1327  my->self.lock_changed(true);
1328  }
1329  FC_CAPTURE_AND_RETHROW()
1330 }
1331 
1332 void wallet_api::unlock(const std::string& password)
1333 {
1334  try
1335  {
1336  FC_ASSERT(password.size() > 0);
1337  auto pw = fc::sha512::hash(password.c_str(), password.size());
1338  std::vector<char> decrypted = fc::aes_decrypt(pw, my->_wallet.cipher_keys);
1339  auto pk = fc::raw::unpack<plain_keys>(decrypted);
1340  FC_ASSERT(pk.checksum == pw);
1341  my->_keys = std::move(pk.keys);
1342  my->_checksum = pk.checksum;
1343  my->self.lock_changed(false);
1344  }
1345  FC_CAPTURE_AND_RETHROW()
1346 }
1347 
1348 void wallet_api::set_password(const std::string& password)
1349 {
1350  if (!is_new())
1351  FC_ASSERT(!is_locked(), "The wallet must be unlocked before the password can be set");
1352  my->_checksum = fc::sha512::hash(password.c_str(), password.size());
1353  lock();
1354 }
1355 
1356 std::map<public_key_type, std::string> wallet_api::list_keys()
1357 {
1358  FC_ASSERT(!is_locked());
1359  return my->_keys;
1360 }
1361 
1362 std::string wallet_api::get_private_key(const public_key_type& pubkey) const
1363 {
1364  return key_to_wif(my->get_private_key(pubkey));
1365 }
1366 
1367 std::pair<public_key_type, std::string> wallet_api::get_private_key_from_password(const std::string& account,
1368  const std::string& role,
1369  const std::string& password) const
1370 {
1371  auto seed = account + role + password;
1372  FC_ASSERT(seed.size());
1373  auto secret = fc::sha256::hash(seed.c_str(), seed.size());
1374  auto priv = fc::ecc::private_key::regenerate(secret);
1375  return std::make_pair(public_key_type(priv.get_public_key()), key_to_wif(priv));
1376 }
1377 
1384  const std::string& newname,
1385  const std::string& json_meta,
1386  const public_key_type& owner,
1387  const public_key_type& active,
1388  const public_key_type& posting,
1389  const public_key_type& memo,
1390  bool broadcast) const
1391 {
1392  try
1393  {
1394  FC_ASSERT(!is_locked());
1396  op.creator = creator;
1397  op.new_account_name = newname;
1398  op.owner = authority(1, owner, 1);
1399  op.active = authority(1, active, 1);
1400  op.posting = authority(1, posting, 1);
1401  op.memo_key = memo;
1402  op.json_metadata = json_meta;
1403  op.fee = my->_chain_api->get_chain_properties().median_chain_props.account_creation_fee
1405 
1406  signed_transaction tx;
1407  tx.operations.push_back(op);
1408  tx.validate();
1409 
1410  return my->sign_transaction(tx, broadcast);
1411  }
1412  FC_CAPTURE_AND_RETHROW((creator)(newname)(json_meta)(owner)(active)(posting)(memo)(broadcast))
1413 }
1414 
1421  const asset& scorum_fee,
1422  const asset& delegated_scorumpower,
1423  const std::string& newname,
1424  const std::string& json_meta,
1425  const public_key_type& owner,
1426  const public_key_type& active,
1427  const public_key_type& posting,
1428  const public_key_type& memo,
1429  bool broadcast) const
1430 {
1431  try
1432  {
1433  FC_ASSERT(!is_locked());
1435  op.creator = creator;
1436  op.new_account_name = newname;
1437  op.owner = authority(1, owner, 1);
1438  op.active = authority(1, active, 1);
1439  op.posting = authority(1, posting, 1);
1440  op.memo_key = memo;
1441  op.json_metadata = json_meta;
1442  op.fee = scorum_fee;
1443  op.delegation = delegated_scorumpower;
1444 
1445  signed_transaction tx;
1446  tx.operations.push_back(op);
1447  tx.validate();
1448 
1449  return my->sign_transaction(tx, broadcast);
1450  }
1451  FC_CAPTURE_AND_RETHROW((creator)(newname)(json_meta)(owner)(active)(posting)(memo)(broadcast))
1452 }
1453 
1455  const std::string& newname,
1456  const std::string& json_meta,
1457  const public_key_type& owner,
1458  const public_key_type& active,
1459  const public_key_type& posting,
1460  const public_key_type& memo,
1461  bool broadcast) const
1462 {
1463  try
1464  {
1465  FC_ASSERT(!is_locked());
1467  op.creator = creator;
1468  op.new_account_name = newname;
1469  op.owner = authority(1, owner, 1);
1470  op.active = authority(1, active, 1);
1471  op.posting = authority(1, posting, 1);
1472  op.memo_key = memo;
1473  op.json_metadata = json_meta;
1474 
1475  signed_transaction tx;
1476  tx.operations.push_back(op);
1477  tx.validate();
1478 
1479  return my->sign_transaction(tx, broadcast);
1480  }
1481  FC_CAPTURE_AND_RETHROW((creator)(newname)(json_meta)(owner)(active)(posting)(memo)(broadcast))
1482 }
1483 
1489  const std::string& newname,
1490  const std::string& json_meta,
1491  bool broadcast)
1492 {
1493  try
1494  {
1495  FC_ASSERT(!is_locked());
1496  auto owner = suggest_brain_key();
1497  auto active = suggest_brain_key();
1498  auto posting = suggest_brain_key();
1499  auto memo = suggest_brain_key();
1500  import_key(owner.wif_priv_key);
1501  import_key(active.wif_priv_key);
1502  import_key(posting.wif_priv_key);
1503  import_key(memo.wif_priv_key);
1504 
1505  return create_account_by_committee_with_keys(creator, newname, json_meta, owner.pub_key, active.pub_key,
1506  posting.pub_key, memo.pub_key, broadcast);
1507  }
1508  FC_CAPTURE_AND_RETHROW((creator)(newname)(json_meta))
1509 }
1510 
1512  const std::string& account_to_recover,
1513  const authority& new_authority,
1514  bool broadcast)
1515 {
1516  FC_ASSERT(!is_locked());
1518  op.recovery_account = recovery_account;
1519  op.account_to_recover = account_to_recover;
1520  op.new_owner_authority = new_authority;
1521 
1522  signed_transaction tx;
1523  tx.operations.push_back(op);
1524  tx.validate();
1525 
1526  return my->sign_transaction(tx, broadcast);
1527 }
1528 
1529 annotated_signed_transaction wallet_api::recover_account(const std::string& account_to_recover,
1530  const authority& recent_authority,
1531  const authority& new_authority,
1532  bool broadcast)
1533 {
1534  FC_ASSERT(!is_locked());
1535 
1537  op.account_to_recover = account_to_recover;
1538  op.new_owner_authority = new_authority;
1539  op.recent_owner_authority = recent_authority;
1540 
1541  signed_transaction tx;
1542  tx.operations.push_back(op);
1543  tx.validate();
1544 
1545  return my->sign_transaction(tx, broadcast);
1546 }
1547 
1549 wallet_api::change_recovery_account(const std::string& owner, const std::string& new_recovery_account, bool broadcast)
1550 {
1551  FC_ASSERT(!is_locked());
1552 
1555  op.new_recovery_account = new_recovery_account;
1556 
1557  signed_transaction tx;
1558  tx.operations.push_back(op);
1559  tx.validate();
1560 
1561  return my->sign_transaction(tx, broadcast);
1562 }
1563 
1564 std::vector<owner_authority_history_api_obj> wallet_api::get_owner_history(const std::string& account) const
1565 {
1566  return my->_remote_db->get_owner_history(account);
1567 }
1568 
1570  const std::string& json_meta,
1571  const public_key_type& owner,
1572  const public_key_type& active,
1573  const public_key_type& posting,
1574  const public_key_type& memo,
1575  bool broadcast) const
1576 {
1577  try
1578  {
1579  FC_ASSERT(!is_locked());
1580 
1582  op.account = account_name;
1583  op.owner = authority(1, owner, 1);
1584  op.active = authority(1, active, 1);
1585  op.posting = authority(1, posting, 1);
1586  op.memo_key = memo;
1587  op.json_metadata = json_meta;
1588 
1589  signed_transaction tx;
1590  tx.operations.push_back(op);
1591  tx.validate();
1592 
1593  return my->sign_transaction(tx, broadcast);
1594  }
1595  FC_CAPTURE_AND_RETHROW((account_name)(json_meta)(owner)(active)(posting)(memo)(broadcast))
1596 }
1597 
1599  const authority_type& type,
1600  const public_key_type& key,
1601  authority_weight_type weight,
1602  bool broadcast)
1603 {
1604  FC_ASSERT(!is_locked());
1605 
1606  auto accounts = my->_remote_db->get_accounts({ account_name });
1607  FC_ASSERT(accounts.size() == 1, "Account does not exist");
1608  FC_ASSERT(account_name == accounts[0].name, "Account name doesn't match?");
1609 
1611  op.account = account_name;
1612  op.memo_key = accounts[0].memo_key;
1613  op.json_metadata = accounts[0].json_metadata;
1614 
1615  authority new_auth;
1616 
1617  switch (type)
1618  {
1619  case (owner):
1620  new_auth = accounts[0].owner;
1621  break;
1622  case (active):
1623  new_auth = accounts[0].active;
1624  break;
1625  case (posting):
1626  new_auth = accounts[0].posting;
1627  break;
1628  }
1629 
1630  if (weight == 0) // Remove the key
1631  {
1632  new_auth.key_auths.erase(key);
1633  }
1634  else
1635  {
1636  new_auth.add_authority(key, weight);
1637  }
1638 
1639  if (new_auth.is_impossible())
1640  {
1641  if (type == owner)
1642  {
1643  FC_ASSERT(false, "Owner authority change would render account irrecoverable.");
1644  }
1645 
1646  wlog("Authority is now impossible.");
1647  }
1648 
1649  switch (type)
1650  {
1651  case (owner):
1652  op.owner = new_auth;
1653  break;
1654  case (active):
1655  op.active = new_auth;
1656  break;
1657  case (posting):
1658  op.posting = new_auth;
1659  break;
1660  }
1661 
1662  signed_transaction tx;
1663  tx.operations.push_back(op);
1664  tx.validate();
1665 
1666  return my->sign_transaction(tx, broadcast);
1667 }
1668 
1670  authority_type type,
1671  const std::string& auth_account,
1672  authority_weight_type weight,
1673  bool broadcast)
1674 {
1675  FC_ASSERT(!is_locked());
1676 
1677  auto accounts = my->_remote_db->get_accounts({ account_name });
1678  FC_ASSERT(accounts.size() == 1, "Account does not exist");
1679  FC_ASSERT(account_name == accounts[0].name, "Account name doesn't match?");
1680 
1682  op.account = account_name;
1683  op.memo_key = accounts[0].memo_key;
1684  op.json_metadata = accounts[0].json_metadata;
1685 
1686  authority new_auth;
1687 
1688  switch (type)
1689  {
1690  case (owner):
1691  new_auth = accounts[0].owner;
1692  break;
1693  case (active):
1694  new_auth = accounts[0].active;
1695  break;
1696  case (posting):
1697  new_auth = accounts[0].posting;
1698  break;
1699  }
1700 
1701  if (weight == 0) // Remove the key
1702  {
1703  new_auth.account_auths.erase(auth_account);
1704  }
1705  else
1706  {
1707  new_auth.add_authority(auth_account, weight);
1708  }
1709 
1710  if (new_auth.is_impossible())
1711  {
1712  if (type == owner)
1713  {
1714  FC_ASSERT(false, "Owner authority change would render account irrecoverable.");
1715  }
1716 
1717  wlog("Authority is now impossible.");
1718  }
1719 
1720  switch (type)
1721  {
1722  case (owner):
1723  op.owner = new_auth;
1724  break;
1725  case (active):
1726  op.active = new_auth;
1727  break;
1728  case (posting):
1729  op.posting = new_auth;
1730  break;
1731  }
1732 
1733  signed_transaction tx;
1734  tx.operations.push_back(op);
1735  tx.validate();
1736 
1737  return my->sign_transaction(tx, broadcast);
1738 }
1739 
1741  authority_type type,
1742  uint32_t threshold,
1743  bool broadcast)
1744 {
1745  FC_ASSERT(!is_locked());
1746 
1747  auto accounts = my->_remote_db->get_accounts({ account_name });
1748  FC_ASSERT(accounts.size() == 1, "Account does not exist");
1749  FC_ASSERT(account_name == accounts[0].name, "Account name doesn't match?");
1750  FC_ASSERT(threshold != 0, "Authority is implicitly satisfied");
1751 
1753  op.account = account_name;
1754  op.memo_key = accounts[0].memo_key;
1755  op.json_metadata = accounts[0].json_metadata;
1756 
1757  authority new_auth;
1758 
1759  switch (type)
1760  {
1761  case (owner):
1762  new_auth = accounts[0].owner;
1763  break;
1764  case (active):
1765  new_auth = accounts[0].active;
1766  break;
1767  case (posting):
1768  new_auth = accounts[0].posting;
1769  break;
1770  }
1771 
1772  new_auth.weight_threshold = threshold;
1773 
1774  if (new_auth.is_impossible())
1775  {
1776  if (type == owner)
1777  {
1778  FC_ASSERT(false, "Owner authority change would render account irrecoverable.");
1779  }
1780 
1781  wlog("Authority is now impossible.");
1782  }
1783 
1784  switch (type)
1785  {
1786  case (owner):
1787  op.owner = new_auth;
1788  break;
1789  case (active):
1790  op.active = new_auth;
1791  break;
1792  case (posting):
1793  op.posting = new_auth;
1794  break;
1795  }
1796 
1797  signed_transaction tx;
1798  tx.operations.push_back(op);
1799  tx.validate();
1800 
1801  return my->sign_transaction(tx, broadcast);
1802 }
1803 
1805 wallet_api::update_account_meta(const std::string& account_name, const std::string& json_meta, bool broadcast)
1806 {
1807  FC_ASSERT(!is_locked());
1808 
1809  auto accounts = my->_remote_db->get_accounts({ account_name });
1810  FC_ASSERT(accounts.size() == 1, "Account does not exist");
1811  FC_ASSERT(account_name == accounts[0].name, "Account name doesn't match?");
1812 
1814  op.account = account_name;
1815  op.memo_key = accounts[0].memo_key;
1816  op.json_metadata = json_meta;
1817 
1818  signed_transaction tx;
1819  tx.operations.push_back(op);
1820  tx.validate();
1821 
1822  return my->sign_transaction(tx, broadcast);
1823 }
1824 
1826 wallet_api::update_account_memo_key(const std::string& account_name, const public_key_type& key, bool broadcast)
1827 {
1828  FC_ASSERT(!is_locked());
1829 
1830  auto accounts = my->_remote_db->get_accounts({ account_name });
1831  FC_ASSERT(accounts.size() == 1, "Account does not exist");
1832  FC_ASSERT(account_name == accounts[0].name, "Account name doesn't match?");
1833 
1835  op.account = account_name;
1836  op.memo_key = key;
1837  op.json_metadata = accounts[0].json_metadata;
1838 
1839  signed_transaction tx;
1840  tx.operations.push_back(op);
1841  tx.validate();
1842 
1843  return my->sign_transaction(tx, broadcast);
1844 }
1845 
1847  const std::string& delegatee,
1848  const asset& scorumpower,
1849  bool broadcast)
1850 {
1851  FC_ASSERT(!is_locked());
1852 
1853  auto accounts = my->_remote_db->get_accounts({ delegator, delegatee });
1854  FC_ASSERT(accounts.size() == 2, "One or more of the accounts specified do not exist.");
1855  FC_ASSERT(delegator == accounts[0].name, "Delegator account is not right?");
1856  FC_ASSERT(delegatee == accounts[1].name, "Delegatee account is not right?");
1857 
1859  op.delegator = delegator;
1860  op.delegatee = delegatee;
1861  op.scorumpower = scorumpower;
1862 
1863  signed_transaction tx;
1864  tx.operations.push_back(op);
1865  tx.validate();
1866 
1867  return my->sign_transaction(tx, broadcast);
1868 }
1869 
1871  const std::string& delegatee,
1872  const asset& scorumpower,
1873  bool broadcast)
1874 {
1875  FC_ASSERT(!is_locked());
1876 
1877  auto accounts = my->_remote_db->get_accounts({ reg_committee_member, delegatee });
1878  FC_ASSERT(accounts.size() == 2, "One or more of the accounts specified do not exist.");
1879  FC_ASSERT(reg_committee_member == accounts[0].name, "Registration committee member account is not right?");
1880  FC_ASSERT(delegatee == accounts[1].name, "Delegatee account is not right?");
1881 
1883  op.reg_committee_member = reg_committee_member;
1884  op.delegatee = delegatee;
1885  op.scorumpower = scorumpower;
1886 
1887  signed_transaction tx;
1888  tx.operations.push_back(op);
1889  tx.validate();
1890 
1891  return my->sign_transaction(tx, broadcast);
1892 }
1893 
1899  const std::string& newname,
1900  const std::string& json_meta,
1901  bool broadcast)
1902 {
1903  try
1904  {
1905  FC_ASSERT(!is_locked());
1906  auto owner = suggest_brain_key();
1907  auto active = suggest_brain_key();
1908  auto posting = suggest_brain_key();
1909  auto memo = suggest_brain_key();
1910  import_key(owner.wif_priv_key);
1911  import_key(active.wif_priv_key);
1912  import_key(posting.wif_priv_key);
1913  import_key(memo.wif_priv_key);
1914  return create_account_with_keys(creator, newname, json_meta, owner.pub_key, active.pub_key, posting.pub_key,
1915  memo.pub_key, broadcast);
1916  }
1917  FC_CAPTURE_AND_RETHROW((creator)(newname)(json_meta))
1918 }
1919 
1925  const asset& scorum_fee,
1926  const asset& delegated_scorumpower,
1927  const std::string& newname,
1928  const std::string& json_meta,
1929  bool broadcast)
1930 {
1931  try
1932  {
1933  FC_ASSERT(!is_locked());
1934  auto owner = suggest_brain_key();
1935  auto active = suggest_brain_key();
1936  auto posting = suggest_brain_key();
1937  auto memo = suggest_brain_key();
1938  import_key(owner.wif_priv_key);
1939  import_key(active.wif_priv_key);
1940  import_key(posting.wif_priv_key);
1941  import_key(memo.wif_priv_key);
1942  return create_account_with_keys_delegated(creator, scorum_fee, delegated_scorumpower, newname, json_meta,
1943  owner.pub_key, active.pub_key, posting.pub_key, memo.pub_key,
1944  broadcast);
1945  }
1946  FC_CAPTURE_AND_RETHROW((creator)(newname)(json_meta))
1947 }
1948 
1949 annotated_signed_transaction wallet_api::update_witness(const std::string& witness_account_name,
1950  const std::string& url,
1951  const public_key_type& block_signing_key,
1952  const chain_properties& props,
1953  bool broadcast)
1954 {
1955  FC_ASSERT(!is_locked());
1956 
1958 
1959  fc::optional<witness_api_obj> wit = my->_remote_db->get_witness_by_account(witness_account_name);
1960  if (!wit.valid())
1961  {
1962  op.url = url;
1963  }
1964  else
1965  {
1966  FC_ASSERT(wit->owner == witness_account_name);
1967  if (url != "")
1968  op.url = url;
1969  else
1970  op.url = wit->url;
1971  }
1972  op.owner = witness_account_name;
1973  op.block_signing_key = block_signing_key;
1974  op.proposed_chain_props = props;
1975 
1976  signed_transaction tx;
1977  tx.operations.push_back(op);
1978  tx.validate();
1979 
1980  return my->sign_transaction(tx, broadcast);
1981 }
1982 
1984  const std::string& witness_to_vote_for,
1985  bool approve,
1986  bool broadcast)
1987 {
1988  try
1989  {
1990  FC_ASSERT(!is_locked());
1992  op.account = voting_account;
1993  op.witness = witness_to_vote_for;
1994  op.approve = approve;
1995 
1996  signed_transaction tx;
1997  tx.operations.push_back(op);
1998  tx.validate();
1999 
2000  return my->sign_transaction(tx, broadcast);
2001  }
2002  FC_CAPTURE_AND_RETHROW((voting_account)(witness_to_vote_for)(approve)(broadcast))
2003 }
2004 
2005 void wallet_api::check_memo(const std::string& memo, const account_api_obj& account) const
2006 {
2007  std::vector<public_key_type> keys;
2008 
2009  try
2010  {
2011  // Check if memo is a private key
2012  keys.push_back(fc::ecc::extended_private_key::from_base58(memo).get_public_key());
2013  }
2014  catch (fc::parse_error_exception&)
2015  {
2016  }
2017  catch (fc::assert_exception&)
2018  {
2019  }
2020 
2021  // Get possible keys if memo was an account password
2022  std::string owner_seed = account.name + "owner" + memo;
2023  auto owner_secret = fc::sha256::hash(owner_seed.c_str(), owner_seed.size());
2024  keys.push_back(fc::ecc::private_key::regenerate(owner_secret).get_public_key());
2025 
2026  std::string active_seed = account.name + "active" + memo;
2027  auto active_secret = fc::sha256::hash(active_seed.c_str(), active_seed.size());
2028  keys.push_back(fc::ecc::private_key::regenerate(active_secret).get_public_key());
2029 
2030  std::string posting_seed = account.name + "posting" + memo;
2031  auto posting_secret = fc::sha256::hash(posting_seed.c_str(), posting_seed.size());
2032  keys.push_back(fc::ecc::private_key::regenerate(posting_secret).get_public_key());
2033 
2034  // Check keys against public keys in authorites
2035  for (auto& key_weight_pair : account.owner.key_auths)
2036  {
2037  for (auto& key : keys)
2038  FC_ASSERT(key_weight_pair.first != key,
2039  "Detected private owner key in memo field. Cancelling transaction.");
2040  }
2041 
2042  for (auto& key_weight_pair : account.active.key_auths)
2043  {
2044  for (auto& key : keys)
2045  FC_ASSERT(key_weight_pair.first != key,
2046  "Detected private active key in memo field. Cancelling transaction.");
2047  }
2048 
2049  for (auto& key_weight_pair : account.posting.key_auths)
2050  {
2051  for (auto& key : keys)
2052  FC_ASSERT(key_weight_pair.first != key,
2053  "Detected private posting key in memo field. Cancelling transaction.");
2054  }
2055 
2056  const auto& memo_key = account.memo_key;
2057  for (auto& key : keys)
2058  FC_ASSERT(memo_key != key, "Detected private memo key in memo field. Cancelling transaction.");
2059 
2060  // Check against imported keys
2061  for (auto& key_pair : my->_keys)
2062  {
2063  for (auto& key : keys)
2064  FC_ASSERT(key != key_pair.first, "Detected imported private key in memo field. Cancelling trasanction.");
2065  }
2066 }
2067 
2068 std::string wallet_api::get_encrypted_memo(const std::string& from, const std::string& to, const std::string& memo)
2069 {
2070 
2071  if (memo.size() > 0 && memo[0] == '#')
2072  {
2073  memo_data m;
2074 
2075  auto from_account = get_account(from);
2076  auto to_account = get_account(to);
2077 
2078  m.from = from_account.memo_key;
2079  m.to = to_account.memo_key;
2080  m.nonce = fc::time_point::now().time_since_epoch().count();
2081 
2082  auto from_priv = my->get_private_key(m.from);
2083  auto shared_secret = from_priv.get_shared_secret(m.to);
2084 
2085  fc::sha512::encoder enc;
2086  fc::raw::pack(enc, m.nonce);
2087  fc::raw::pack(enc, shared_secret);
2088  auto encrypt_key = enc.result();
2089 
2090  m.encrypted = fc::aes_encrypt(encrypt_key, fc::raw::pack(memo.substr(1)));
2091  m.check = fc::sha256::hash(encrypt_key)._hash[0];
2092  return m;
2093  }
2094  else
2095  {
2096  return memo;
2097  }
2098 }
2099 
2101  const std::string& from, const std::string& to, const asset& amount, const std::string& memo, bool broadcast)
2102 {
2103  try
2104  {
2105  FC_ASSERT(!is_locked());
2106  check_memo(memo, get_account(from));
2107  transfer_operation op;
2108  op.from = from;
2109  op.to = to;
2110  op.amount = amount;
2111 
2112  op.memo = get_encrypted_memo(from, to, memo);
2113 
2114  signed_transaction tx;
2115  tx.operations.push_back(op);
2116  tx.validate();
2117 
2118  return my->sign_transaction(tx, broadcast);
2119  }
2120  FC_CAPTURE_AND_RETHROW((from)(to)(amount)(memo)(broadcast))
2121 }
2122 
2124  const std::string& to,
2125  const std::string& agent,
2126  uint32_t escrow_id,
2127  const asset& scorum_amount,
2128  const asset& fee,
2129  time_point_sec ratification_deadline,
2130  time_point_sec escrow_expiration,
2131  const std::string& json_meta,
2132  bool broadcast)
2133 {
2134  FC_ASSERT(!is_locked());
2136  op.from = from;
2137  op.to = to;
2138  op.agent = agent;
2139  op.escrow_id = escrow_id;
2140  op.scorum_amount = scorum_amount;
2141  op.fee = fee;
2142  op.ratification_deadline = ratification_deadline;
2143  op.escrow_expiration = escrow_expiration;
2144  op.json_meta = json_meta;
2145 
2146  signed_transaction tx;
2147  tx.operations.push_back(op);
2148  tx.validate();
2149 
2150  return my->sign_transaction(tx, broadcast);
2151 }
2152 
2154  const std::string& to,
2155  const std::string& agent,
2156  const std::string& who,
2157  uint32_t escrow_id,
2158  bool approve,
2159  bool broadcast)
2160 {
2161  FC_ASSERT(!is_locked());
2163  op.from = from;
2164  op.to = to;
2165  op.agent = agent;
2166  op.who = who;
2167  op.escrow_id = escrow_id;
2168 
2169  signed_transaction tx;
2170  tx.operations.push_back(op);
2171  tx.validate();
2172 
2173  return my->sign_transaction(tx, broadcast);
2174 }
2175 
2177  const std::string& to,
2178  const std::string& agent,
2179  const std::string& who,
2180  uint32_t escrow_id,
2181  bool broadcast)
2182 {
2183  FC_ASSERT(!is_locked());
2185  op.from = from;
2186  op.to = to;
2187  op.agent = agent;
2188  op.who = who;
2189  op.escrow_id = escrow_id;
2190 
2191  signed_transaction tx;
2192  tx.operations.push_back(op);
2193  tx.validate();
2194 
2195  return my->sign_transaction(tx, broadcast);
2196 }
2197 
2199  const std::string& to,
2200  const std::string& agent,
2201  const std::string& who,
2202  const std::string& receiver,
2203  uint32_t escrow_id,
2204  const asset& scorum_amount,
2205  bool broadcast)
2206 {
2207  FC_ASSERT(!is_locked());
2209  op.from = from;
2210  op.to = to;
2211  op.agent = agent;
2212  op.who = who;
2213  op.receiver = receiver;
2214  op.escrow_id = escrow_id;
2215  op.scorum_amount = scorum_amount;
2216 
2217  signed_transaction tx;
2218  tx.operations.push_back(op);
2219  tx.validate();
2220  return my->sign_transaction(tx, broadcast);
2221 }
2222 
2224 wallet_api::transfer_to_scorumpower(const std::string& from, const std::string& to, const asset& amount, bool broadcast)
2225 {
2226  FC_ASSERT(!is_locked());
2228  op.from = from;
2229  op.to = (to == from ? "" : to);
2230  op.amount = amount;
2231 
2232  signed_transaction tx;
2233  tx.operations.push_back(op);
2234  tx.validate();
2235 
2236  return my->sign_transaction(tx, broadcast);
2237 }
2238 
2240 wallet_api::withdraw_scorumpower(const std::string& from, const asset& scorumpower, bool broadcast)
2241 {
2242  FC_ASSERT(!is_locked());
2244  op.account = from;
2245  op.scorumpower = scorumpower;
2246 
2247  signed_transaction tx;
2248  tx.operations.push_back(op);
2249  tx.validate();
2250 
2251  return my->sign_transaction(tx, broadcast);
2252 }
2253 
2255  const std::string& from, const std::string& to, uint16_t percent, bool auto_vest, bool broadcast)
2256 {
2257  FC_ASSERT(!is_locked());
2259  op.from_account = from;
2260  op.to_account = to;
2261  op.percent = percent;
2262  op.auto_vest = auto_vest;
2263 
2264  signed_transaction tx;
2265  tx.operations.push_back(op);
2266  tx.validate();
2267 
2268  return my->sign_transaction(tx, broadcast);
2269 }
2270 
2271 std::string wallet_api::decrypt_memo(const std::string& encrypted_memo)
2272 {
2273  if (is_locked())
2274  return encrypted_memo;
2275 
2276  if (encrypted_memo.size() && encrypted_memo[0] == '#')
2277  {
2278  auto m = memo_data::from_string(encrypted_memo);
2279  if (m)
2280  {
2281  fc::sha512 shared_secret;
2282  auto from_key = my->try_get_private_key(m->from);
2283  if (!from_key)
2284  {
2285  auto to_key = my->try_get_private_key(m->to);
2286  if (!to_key)
2287  return encrypted_memo;
2288  shared_secret = to_key->get_shared_secret(m->from);
2289  }
2290  else
2291  {
2292  shared_secret = from_key->get_shared_secret(m->to);
2293  }
2294  fc::sha512::encoder enc;
2295  fc::raw::pack(enc, m->nonce);
2296  fc::raw::pack(enc, shared_secret);
2297  auto encryption_key = enc.result();
2298 
2299  uint32_t check = fc::sha256::hash(encryption_key)._hash[0];
2300  if (check != m->check)
2301  return encrypted_memo;
2302 
2303  try
2304  {
2305  std::vector<char> decrypted = fc::aes_decrypt(encryption_key, m->encrypted);
2306  return fc::raw::unpack<std::string>(decrypted);
2307  }
2308  catch (...)
2309  {
2310  }
2311  }
2312  }
2313  return encrypted_memo;
2314 }
2315 
2316 annotated_signed_transaction wallet_api::decline_voting_rights(const std::string& account, bool decline, bool broadcast)
2317 {
2318  FC_ASSERT(!is_locked());
2320  op.account = account;
2321  op.decline = decline;
2322 
2323  signed_transaction tx;
2324  tx.operations.push_back(op);
2325  tx.validate();
2326 
2327  return my->sign_transaction(tx, broadcast);
2328 }
2329 
2330 std::map<uint32_t, applied_operation>
2331 wallet_api::get_account_history(const std::string& account, uint64_t from, uint32_t limit)
2332 {
2333  FC_ASSERT(!is_locked(), "Wallet must be unlocked to get account history");
2334 
2335  std::map<uint32_t, applied_operation> result;
2336 
2337  my->use_remote_account_history_api();
2338 
2339  result = (*my->_remote_account_history_api)->get_account_history(account, from, limit);
2340 
2341  for (auto& item : result)
2342  {
2343  if (item.second.op.which() == operation::tag<transfer_operation>::value)
2344  {
2345  auto& top = item.second.op.get<transfer_operation>();
2346  top.memo = decrypt_memo(top.memo);
2347  }
2348  }
2349 
2350  return result;
2351 }
2352 
2353 std::map<uint32_t, applied_operation>
2354 wallet_api::get_account_scr_to_scr_transfers(const std::string& account, uint64_t from, uint32_t limit)
2355 {
2356  FC_ASSERT(!is_locked(), "Wallet must be unlocked to get account history");
2357 
2358  std::map<uint32_t, applied_operation> result;
2359 
2360  my->use_remote_account_history_api();
2361 
2362  result = (*my->_remote_account_history_api)->get_account_scr_to_scr_transfers(account, from, limit);
2363 
2364  for (auto& item : result)
2365  {
2366  item.second.op.weak_visit([&](transfer_operation& top) { top.memo = decrypt_memo(top.memo); });
2367  }
2368 
2369  return result;
2370 }
2371 
2372 std::map<uint32_t, applied_operation>
2373 wallet_api::get_account_scr_to_sp_transfers(const std::string& account, uint64_t from, uint32_t limit)
2374 {
2375  FC_ASSERT(!is_locked(), "Wallet must be unlocked to get account history");
2376 
2377  std::map<uint32_t, applied_operation> result;
2378 
2379  my->use_remote_account_history_api();
2380 
2381  result = (*my->_remote_account_history_api)->get_account_scr_to_sp_transfers(account, from, limit);
2382 
2383  for (auto& item : result)
2384  {
2385  item.second.op.weak_visit([&](transfer_operation& top) { top.memo = decrypt_memo(top.memo); });
2386  }
2387 
2388  return result;
2389 }
2390 
2391 std::map<uint32_t, applied_withdraw_operation>
2392 wallet_api::get_account_sp_to_scr_transfers(const std::string& account, uint64_t from, uint32_t limit)
2393 {
2394  FC_ASSERT(!is_locked(), "Wallet must be unlocked to get account history");
2395  my->use_remote_account_history_api();
2396 
2397  auto result = (*my->_remote_account_history_api)->get_account_sp_to_scr_transfers(account, from, limit);
2398 
2399  for (auto& item : result)
2400  {
2401  item.second.op.weak_visit([&](transfer_operation& top) { top.memo = decrypt_memo(top.memo); });
2402  }
2403 
2404  return result;
2405 }
2406 
2407 std::vector<applied_operation> wallet_api::get_devcommittee_history(uint64_t from, uint32_t limit)
2408 {
2409  FC_ASSERT(!is_locked(), "Wallet must be unlocked to get devcommittee history");
2410  my->use_remote_devcommittee_history_api();
2411 
2412  auto result = (*my->_remote_devcommittee_history_api)->get_history(from, limit);
2413 
2414  return result;
2415 }
2416 
2417 std::vector<applied_operation> wallet_api::get_devcommittee_scr_to_scr_transfers(uint64_t from, uint32_t limit)
2418 {
2419  FC_ASSERT(!is_locked(), "Wallet must be unlocked to get devcommittee history");
2420  my->use_remote_devcommittee_history_api();
2421 
2422  auto result = (*my->_remote_devcommittee_history_api)->get_scr_to_scr_transfers(from, limit);
2423 
2424  return result;
2425 }
2426 
2427 std::vector<applied_withdraw_operation> wallet_api::get_devcommittee_sp_to_scr_transfers(uint64_t from, uint32_t limit)
2428 {
2429  FC_ASSERT(!is_locked(), "Wallet must be unlocked to get devcommittee history");
2430  my->use_remote_devcommittee_history_api();
2431 
2432  auto result = (*my->_remote_devcommittee_history_api)->get_sp_to_scr_transfers(from, limit);
2433 
2434  return result;
2435 }
2436 
2437 std::vector<withdraw_route> wallet_api::get_withdraw_routes(const std::string& account, withdraw_route_type type) const
2438 {
2439  return my->_remote_db->get_withdraw_routes(account, type);
2440 }
2441 
2443  const std::string& permlink,
2444  const std::string& parent_author,
2445  const std::string& parent_permlink,
2446  const std::string& title,
2447  const std::string& body,
2448  const std::string& json,
2449  bool broadcast)
2450 {
2451  FC_ASSERT(!is_locked());
2452  comment_operation op;
2453  op.parent_author = parent_author;
2454  op.parent_permlink = parent_permlink;
2455  op.author = author;
2456  op.permlink = permlink;
2457  op.title = title;
2458  op.body = body;
2459  op.json_metadata = json;
2460 
2461  signed_transaction tx;
2462  tx.operations.push_back(op);
2463  tx.validate();
2464 
2465  return my->sign_transaction(tx, broadcast);
2466 }
2467 
2469  const std::string& voter, const std::string& author, const std::string& permlink, int16_t weight, bool broadcast)
2470 {
2471  FC_ASSERT(!is_locked());
2472  FC_ASSERT(abs(weight) <= 10000, "Weight must be between -10 000 and 10 000 and not 0");
2473 
2474  vote_operation op;
2475  op.voter = voter;
2476  op.author = author;
2477  op.permlink = permlink;
2478  op.weight = weight;
2479 
2480  signed_transaction tx;
2481  tx.operations.push_back(op);
2482  tx.validate();
2483 
2484  return my->sign_transaction(tx, broadcast);
2485 }
2486 
2488 {
2489  my->set_transaction_expiration(seconds);
2490 }
2491 
2493 wallet_api::challenge(const std::string& challenger, const std::string& challenged, bool broadcast)
2494 {
2495  // SCORUM: TODO: remove whole method
2496  FC_ASSERT(false, "Challenge is disabled");
2497  /*
2498  FC_ASSERT( !is_locked() );
2499 
2500  challenge_authority_operation op;
2501  op.challenger = challenger;
2502  op.challenged = challenged;
2503  op.require_owner = false;
2504 
2505  signed_transaction tx;
2506  tx.operations.push_back( op );
2507  tx.validate();
2508 
2509  return my->sign_transaction( tx, broadcast );
2510  */
2511 }
2512 
2513 annotated_signed_transaction wallet_api::prove(const std::string& challenged, bool broadcast)
2514 {
2515  FC_ASSERT(!is_locked());
2516 
2518  op.challenged = challenged;
2519  op.require_owner = false;
2520 
2521  signed_transaction tx;
2522  tx.operations.push_back(op);
2523  tx.validate();
2524 
2525  return my->sign_transaction(tx, broadcast);
2526 }
2527 
2529 {
2530  my->use_remote_blockchain_history_api();
2531 
2532  return (*my->_remote_blockchain_history_api)->get_transaction(id);
2533 }
2534 
2535 std::vector<budget_api_obj> wallet_api::list_my_budgets()
2536 {
2537  FC_ASSERT(!is_locked());
2538 
2539  my->use_remote_account_by_key_api();
2540 
2541  std::vector<public_key_type> pub_keys;
2542  pub_keys.reserve(my->_keys.size());
2543 
2544  for (const auto& item : my->_keys)
2545  pub_keys.push_back(item.first);
2546 
2547  auto refs = (*my->_remote_account_by_key_api)->get_key_references(pub_keys);
2548  std::set<std::string> names;
2549  for (const auto& item : refs)
2550  for (const auto& name : item)
2551  names.insert(name);
2552 
2553  std::vector<budget_api_obj> ret;
2554 
2555  {
2556  auto budgets = my->_remote_db->get_budgets(budget_type::post, names);
2557  std::copy(budgets.begin(), budgets.end(), std::back_inserter(ret));
2558  }
2559  {
2560  auto budgets = my->_remote_db->get_budgets(budget_type::banner, names);
2561  std::copy(budgets.begin(), budgets.end(), std::back_inserter(ret));
2562  }
2563 
2564  return ret;
2565 }
2566 
2567 std::set<std::string> wallet_api::list_post_budget_owners(const std::string& lowerbound, uint32_t limit)
2568 {
2569  return my->_remote_db->lookup_budget_owners(budget_type::post, lowerbound, limit);
2570 }
2571 
2572 std::set<std::string> wallet_api::list_banner_budget_owners(const std::string& lowerbound, uint32_t limit)
2573 {
2574  return my->_remote_db->lookup_budget_owners(budget_type::banner, lowerbound, limit);
2575 }
2576 
2577 std::vector<budget_api_obj> wallet_api::get_post_budgets(const std::string& account_name)
2578 {
2579  validate_account_name(account_name);
2580 
2581  return my->_remote_db->get_budgets(budget_type::post, { account_name });
2582 }
2583 
2584 std::vector<budget_api_obj> wallet_api::get_banner_budgets(const std::string& account_name)
2585 {
2586  validate_account_name(account_name);
2587 
2588  return my->_remote_db->get_budgets(budget_type::banner, { account_name });
2589 }
2590 
2592  const uuid_type& uuid,
2593  const std::string& json_metadata,
2594  const asset& balance,
2595  const time_point_sec& start,
2596  const time_point_sec& deadline,
2597  const bool broadcast)
2598 {
2599  FC_ASSERT(!is_locked());
2600 
2602 
2603  op.type = budget_type::post;
2604  op.owner = owner;
2605  op.uuid = uuid;
2606  op.json_metadata = json_metadata;
2607  op.balance = balance;
2608  op.start = start;
2609  op.deadline = deadline;
2610 
2611  signed_transaction tx;
2612  tx.operations.push_back(op);
2613  tx.validate();
2614 
2615  return my->sign_transaction(tx, broadcast);
2616 }
2617 
2619  const uuid_type& uuid,
2620  const std::string& json_metadata,
2621  const asset& balance,
2622  const time_point_sec& start,
2623  const time_point_sec& deadline,
2624  const bool broadcast)
2625 {
2626  FC_ASSERT(!is_locked());
2627 
2629 
2630  op.type = budget_type::banner;
2631  op.owner = owner;
2632  op.uuid = uuid;
2633  op.json_metadata = json_metadata;
2634  op.balance = balance;
2635  op.start = start;
2636  op.deadline = deadline;
2637 
2638  signed_transaction tx;
2639  tx.operations.push_back(op);
2640  tx.validate();
2641 
2642  return my->sign_transaction(tx, broadcast);
2643 }
2644 
2645 template <budget_type budget_type_v>
2646 signed_transaction update_budget(const std::string& owner, uuid_type uuid, const std::string& json_metadata)
2647 {
2649  op.owner = owner;
2650  op.uuid = uuid;
2651  op.json_metadata = json_metadata;
2652  op.type = budget_type_v;
2653 
2654  signed_transaction tx;
2655  tx.operations.push_back(op);
2656  tx.validate();
2657 
2658  return tx;
2659 }
2660 
2662  const uuid_type& uuid,
2663  const std::string& json_metadata,
2664  const bool broadcast)
2665 {
2666  auto tx = update_budget<budget_type::banner>(owner, uuid, json_metadata);
2667  return my->sign_transaction(tx, broadcast);
2668 }
2669 
2671  const uuid_type& uuid,
2672  const std::string& json_metadata,
2673  const bool broadcast)
2674 {
2675  auto tx = update_budget<budget_type::post>(owner, uuid, json_metadata);
2676  return my->sign_transaction(tx, broadcast);
2677 }
2678 
2680 wallet_api::close_budget_for_post(const uuid_type& uuid, const std::string& owner, const bool broadcast)
2681 {
2682  FC_ASSERT(!is_locked());
2683 
2685 
2686  op.type = budget_type::post;
2687  op.uuid = uuid;
2688  op.owner = owner;
2689 
2690  signed_transaction tx;
2691  tx.operations.push_back(op);
2692  tx.validate();
2693 
2694  return my->sign_transaction(tx, broadcast);
2695 }
2696 
2698 wallet_api::close_budget_for_banner(const uuid_type& uuid, const std::string& owner, const bool broadcast)
2699 {
2700  FC_ASSERT(!is_locked());
2701 
2703 
2704  op.type = budget_type::banner;
2705  op.uuid = uuid;
2706  op.owner = owner;
2707 
2708  signed_transaction tx;
2709  tx.operations.push_back(op);
2710  tx.validate();
2711 
2712  return my->sign_transaction(tx, broadcast);
2713 }
2714 
2716  const std::string& moderator,
2717  const bool broadcast)
2718 {
2719  FC_ASSERT(!is_locked());
2720 
2722 
2723  op.type = budget_type::post;
2724  op.uuid = uuid;
2725  op.moderator = moderator;
2726 
2727  signed_transaction tx;
2728  tx.operations.push_back(op);
2729  tx.validate();
2730 
2731  return my->sign_transaction(tx, broadcast);
2732 }
2733 
2735  const std::string& moderator,
2736  const bool broadcast)
2737 {
2738  FC_ASSERT(!is_locked());
2739 
2741 
2742  op.type = budget_type::banner;
2743  op.uuid = uuid;
2744  op.moderator = moderator;
2745 
2746  signed_transaction tx;
2747  tx.operations.push_back(op);
2748  tx.validate();
2749 
2750  return my->sign_transaction(tx, broadcast);
2751 }
2752 
2753 template <typename T, typename C>
2754 signed_transaction proposal(const std::string& initiator, uint32_t lifetime_sec, C&& constructor)
2755 {
2756  T operation;
2757  constructor(operation);
2758 
2760  op.creator = initiator;
2761  op.operation = operation;
2762  op.lifetime_sec = lifetime_sec;
2763 
2764  signed_transaction tx;
2765  tx.operations.push_back(op);
2766  tx.validate();
2767 
2768  return tx;
2769 }
2770 
2771 annotated_signed_transaction
2772 wallet_api::vote_for_committee_proposal(const std::string& voting_account, int64_t proposal_id, bool broadcast)
2773 {
2775  op.voting_account = voting_account;
2776  op.proposal_id = proposal_id;
2777 
2778  signed_transaction tx;
2779  tx.operations.push_back(op);
2780  tx.validate();
2781 
2782  return my->sign_transaction(tx, broadcast);
2783 }
2784 
2786  const std::string& invitee,
2787  uint32_t lifetime_sec,
2788  bool broadcast)
2789 {
2790  using operation_type = registration_committee_add_member_operation;
2791 
2793  = proposal<operation_type>(initiator, lifetime_sec, [&](operation_type& o) { o.account_name = invitee; });
2794 
2795  return my->sign_transaction(tx, broadcast);
2796 }
2797 
2799  const std::string& dropout,
2800  uint32_t lifetime_sec,
2801  bool broadcast)
2802 {
2803  using operation_type = registration_committee_exclude_member_operation;
2804 
2806  = proposal<operation_type>(initiator, lifetime_sec, [&](operation_type& o) { o.account_name = dropout; });
2807 
2808  return my->sign_transaction(tx, broadcast);
2809 }
2810 
2811 std::set<account_name_type> wallet_api::list_registration_committee(const std::string& lowerbound, uint32_t limit)
2812 {
2813  return my->_remote_db->lookup_registration_committee_members(lowerbound, limit);
2814 }
2815 
2817 {
2818  return my->_remote_db->get_registration_committee();
2819 }
2820 
2821 std::vector<proposal_api_obj> wallet_api::list_proposals()
2822 {
2823  return my->_remote_db->lookup_proposals();
2824 }
2825 
2827  uint64_t quorum_percent,
2828  uint32_t lifetime_sec,
2829  bool broadcast)
2830 {
2831  using operation_type = registration_committee_change_quorum_operation;
2832 
2833  signed_transaction tx = proposal<operation_type>(initiator, lifetime_sec, [&](operation_type& o) {
2834  o.quorum = quorum_percent;
2835  o.committee_quorum = add_member_quorum;
2836  });
2837 
2838  return my->sign_transaction(tx, broadcast);
2839 }
2840 
2842  const std::string& initiator, uint64_t quorum_percent, uint32_t lifetime_sec, bool broadcast)
2843 {
2844  using operation_type = registration_committee_change_quorum_operation;
2845 
2846  signed_transaction tx = proposal<operation_type>(initiator, lifetime_sec, [&](operation_type& o) {
2847  o.quorum = quorum_percent;
2848  o.committee_quorum = exclude_member_quorum;
2849  });
2850 
2851  return my->sign_transaction(tx, broadcast);
2852 }
2853 
2855  uint64_t quorum_percent,
2856  uint32_t lifetime_sec,
2857  bool broadcast)
2858 {
2859  using operation_type = registration_committee_change_quorum_operation;
2860 
2861  signed_transaction tx = proposal<operation_type>(initiator, lifetime_sec, [&](operation_type& o) {
2862  o.quorum = quorum_percent;
2863  o.committee_quorum = base_quorum;
2864  });
2865 
2866  return my->sign_transaction(tx, broadcast);
2867 }
2868 
2870  const std::string& invitee,
2871  uint32_t lifetime_sec,
2872  bool broadcast)
2873 {
2874  using operation_type = development_committee_add_member_operation;
2875 
2877  = proposal<operation_type>(initiator, lifetime_sec, [&](operation_type& o) { o.account_name = invitee; });
2878 
2879  return my->sign_transaction(tx, broadcast);
2880 }
2881 
2883  const std::string& dropout,
2884  uint32_t lifetime_sec,
2885  bool broadcast)
2886 {
2887  using operation_type = development_committee_exclude_member_operation;
2888 
2890  = proposal<operation_type>(initiator, lifetime_sec, [&](operation_type& o) { o.account_name = dropout; });
2891 
2892  return my->sign_transaction(tx, broadcast);
2893 }
2894 
2895 std::set<account_name_type> wallet_api::list_development_committee(const std::string& lowerbound, uint32_t limit)
2896 {
2897  return my->_remote_db->lookup_development_committee_members(lowerbound, limit);
2898 }
2899 
2901  uint64_t quorum_percent,
2902  uint32_t lifetime_sec,
2903  bool broadcast)
2904 {
2905  using operation_type = development_committee_change_quorum_operation;
2906 
2907  signed_transaction tx = proposal<operation_type>(initiator, lifetime_sec, [&](operation_type& o) {
2908  o.quorum = quorum_percent;
2909  o.committee_quorum = add_member_quorum;
2910  });
2911 
2912  return my->sign_transaction(tx, broadcast);
2913 }
2914 
2916  const std::string& initiator, uint64_t quorum_percent, uint32_t lifetime_sec, bool broadcast)
2917 {
2918  using operation_type = development_committee_change_quorum_operation;
2919 
2920  signed_transaction tx = proposal<operation_type>(initiator, lifetime_sec, [&](operation_type& o) {
2921  o.quorum = quorum_percent;
2922  o.committee_quorum = exclude_member_quorum;
2923  });
2924 
2925  return my->sign_transaction(tx, broadcast);
2926 }
2927 
2929  uint64_t quorum_percent,
2930  uint32_t lifetime_sec,
2931  bool broadcast)
2932 {
2933  using operation_type = development_committee_change_quorum_operation;
2934 
2935  signed_transaction tx = proposal<operation_type>(initiator, lifetime_sec, [&](operation_type& o) {
2936  o.quorum = quorum_percent;
2937  o.committee_quorum = base_quorum;
2938  });
2939 
2940  return my->sign_transaction(tx, broadcast);
2941 }
2942 
2944  uint64_t quorum_percent,
2945  uint32_t lifetime_sec,
2946  bool broadcast)
2947 {
2948  using operation_type = development_committee_change_quorum_operation;
2949 
2950  signed_transaction tx = proposal<operation_type>(initiator, lifetime_sec, [&](operation_type& o) {
2951  o.quorum = quorum_percent;
2952  o.committee_quorum = transfer_quorum;
2953  });
2954 
2955  return my->sign_transaction(tx, broadcast);
2956 }
2957 
2959  const std::string& initiator, uint64_t quorum_percent, uint32_t lifetime_sec, bool broadcast)
2960 {
2961  using operation_type = development_committee_change_quorum_operation;
2962 
2963  signed_transaction tx = proposal<operation_type>(initiator, lifetime_sec, [&](operation_type& o) {
2964  o.quorum = quorum_percent;
2965  o.committee_quorum = budgets_auction_properties_quorum;
2966  });
2967 
2968  return my->sign_transaction(tx, broadcast);
2969 }
2970 
2972  const std::string& initiator, uint64_t quorum_percent, uint32_t lifetime_sec, bool broadcast)
2973 {
2974  using operation_type = development_committee_change_quorum_operation;
2975 
2976  signed_transaction tx = proposal<operation_type>(initiator, lifetime_sec, [&](operation_type& o) {
2977  o.quorum = quorum_percent;
2978  o.committee_quorum = advertising_moderator_quorum;
2979  });
2980 
2981  return my->sign_transaction(tx, broadcast);
2982 }
2983 
2985  const std::string& initiator, uint64_t quorum_percent, uint32_t lifetime_sec, bool broadcast)
2986 {
2987  using operation_type = development_committee_change_quorum_operation;
2988 
2989  signed_transaction tx = proposal<operation_type>(initiator, lifetime_sec, [&](operation_type& o) {
2990  o.quorum = quorum_percent;
2991  o.committee_quorum = betting_moderator_quorum;
2992  });
2993 
2994  return my->sign_transaction(tx, broadcast);
2995 }
2996 
2998  const std::string& initiator, const std::string& moderator, uint32_t lifetime_sec, bool broadcast)
2999 {
3001 
3003  = proposal<operation_type>(initiator, lifetime_sec, [&](operation_type& o) { o.account = moderator; });
3004 
3005  return my->sign_transaction(tx, broadcast);
3006 }
3007 
3009  const std::string& moderator,
3010  uint32_t lifetime_sec,
3011  bool broadcast)
3012 {
3014 
3016  = proposal<operation_type>(initiator, lifetime_sec, [&](operation_type& o) { o.account = moderator; });
3017 
3018  return my->sign_transaction(tx, broadcast);
3019 }
3020 
3022  const std::string& initiator, uint32_t delay_sec, uint32_t lifetime_sec, bool broadcast)
3023 {
3025 
3027  = proposal<operation_type>(initiator, lifetime_sec, [&](operation_type& o) { o.delay_sec = delay_sec; });
3028 
3029  return my->sign_transaction(tx, broadcast);
3030 }
3031 
3033  const std::string& initiator, const std::string& to_account, asset amount, uint32_t lifetime_sec, bool broadcast)
3034 {
3035  using operation_type = development_committee_transfer_operation;
3036 
3037  signed_transaction tx = proposal<operation_type>(initiator, lifetime_sec, [&](operation_type& o) {
3038  o.to_account = to_account;
3039  o.amount = amount;
3040  });
3041 
3042  return my->sign_transaction(tx, broadcast);
3043 }
3044 
3046  asset amount,
3047  uint32_t lifetime_sec,
3048  bool broadcast)
3049 {
3050  using operation_type = development_committee_withdraw_vesting_operation;
3051 
3053  = proposal<operation_type>(initiator, lifetime_sec, [&](operation_type& o) { o.vesting_shares = amount; });
3054 
3055  return my->sign_transaction(tx, broadcast);
3056 }
3057 
3060  const std::vector<percent_type>& auction_coefficients,
3061  uint32_t lifetime_sec,
3062  bool broadcast)
3063 {
3065 
3066  signed_transaction tx = proposal<operation_type>(
3067  initiator, lifetime_sec, [&](operation_type& o) { o.auction_coefficients = auction_coefficients; });
3068 
3069  return my->sign_transaction(tx, broadcast);
3070 }
3071 
3074  const std::vector<percent_type>& auction_coefficients,
3075  uint32_t lifetime_sec,
3076  bool broadcast)
3077 {
3079 
3080  signed_transaction tx = proposal<operation_type>(
3081  initiator, lifetime_sec, [&](operation_type& o) { o.auction_coefficients = auction_coefficients; });
3082 
3083  return my->sign_transaction(tx, broadcast);
3084 }
3085 
3087 {
3088  return my->_remote_db->get_development_committee();
3089 }
3090 
3092  const std::string& participant,
3093  const asset& amount,
3094  const std::string& metadata,
3095  const uint8_t secret_length,
3096  const bool broadcast)
3097 {
3098  FC_ASSERT(!is_locked());
3099 
3100  std::string secret;
3101 
3103  secret = atomicswap::get_secret_hex(secret, secret_length);
3104 
3105  std::string secret_hash = atomicswap::get_secret_hash(secret);
3106 
3108 
3110  op.owner = initiator;
3111  op.recipient = participant;
3112  op.secret_hash = secret_hash;
3113  op.amount = amount;
3114  op.metadata = metadata;
3115 
3116  signed_transaction tx;
3117  tx.operations.push_back(op);
3118  tx.validate();
3119 
3120  auto ret = my->sign_transaction(tx, broadcast);
3121 
3122  return atomicswap_contract_result_api_obj(ret, op, secret);
3123 }
3124 
3126  const std::string& participant,
3127  const std::string& initiator,
3128  const asset& amount,
3129  const std::string& metadata,
3130  const bool broadcast)
3131 {
3132  FC_ASSERT(!is_locked());
3133 
3135 
3137  op.owner = participant;
3138  op.recipient = initiator;
3139  op.secret_hash = secret_hash;
3140  op.amount = amount;
3141  op.metadata = metadata;
3142 
3143  signed_transaction tx;
3144  tx.operations.push_back(op);
3145  tx.validate();
3146 
3147  auto ret = my->sign_transaction(tx, broadcast);
3148 
3149  return atomicswap_contract_result_api_obj(ret, op);
3150 }
3151 
3153  const std::string& to,
3154  const std::string& secret,
3155  const bool broadcast)
3156 {
3157  FC_ASSERT(!is_locked());
3158 
3160 
3161  op.from = from;
3162  op.to = to;
3163  op.secret = secret;
3164 
3165  signed_transaction tx;
3166  tx.operations.push_back(op);
3167  tx.validate();
3168 
3169  return my->sign_transaction(tx, broadcast);
3170 }
3171 
3173 wallet_api::atomicswap_auditcontract(const std::string& from, const std::string& to, const std::string& secret_hash)
3174 {
3175  return my->_remote_db->get_atomicswap_contract(from, to, secret_hash);
3176 }
3177 
3178 std::string
3179 wallet_api::atomicswap_extractsecret(const std::string& from, const std::string& to, const std::string& secret_hash)
3180 {
3181 
3182  atomicswap_contract_info_api_obj contract_info = atomicswap_auditcontract(from, to, secret_hash);
3183 
3184  FC_ASSERT(!contract_info.secret.empty(), "Contract is not redeemed.");
3185 
3186  return contract_info.secret;
3187 }
3188 
3190  const std::string& initiator,
3191  const std::string& secret_hash,
3192  const bool broadcast)
3193 {
3194  FC_ASSERT(!is_locked());
3195 
3197 
3198  op.participant = participant;
3199  op.initiator = initiator;
3200  op.secret_hash = secret_hash;
3201 
3202  signed_transaction tx;
3203  tx.operations.push_back(op);
3204  tx.validate();
3205 
3206  return my->sign_transaction(tx, broadcast);
3207 }
3208 
3209 std::vector<atomicswap_contract_api_obj> wallet_api::get_atomicswap_contracts(const std::string& owner)
3210 {
3211  std::vector<atomicswap_contract_api_obj> result;
3212 
3213  result = my->_remote_db->get_atomicswap_contracts(owner);
3214 
3215  return result;
3216 }
3217 
3219  account_name_type moderator,
3220  const std::string& json_metadata,
3221  fc::time_point_sec start_time,
3222  uint32_t auto_resolve_delay_sec,
3223  game_type game,
3224  const std::vector<market_type>& markets,
3225  const bool broadcast)
3226 {
3227  FC_ASSERT(!is_locked());
3228 
3230 
3231  op.uuid = uuid;
3232  op.moderator = moderator;
3233  op.game = game;
3234  op.json_metadata = json_metadata;
3235  op.start_time = start_time;
3236  op.auto_resolve_delay_sec = auto_resolve_delay_sec;
3237  op.markets = markets;
3238 
3239  signed_transaction tx;
3240  tx.operations.push_back(op);
3241  tx.validate();
3242 
3244  ret = my->sign_transaction(tx, broadcast);
3245 
3246  return ret;
3247 }
3248 
3250 {
3251  FC_ASSERT(!is_locked());
3252 
3254 
3255  op.uuid = uuid;
3256  op.moderator = moderator;
3257 
3258  signed_transaction tx;
3259  tx.operations.push_back(op);
3260  tx.validate();
3261 
3263  ret = my->sign_transaction(tx, broadcast);
3264 
3265  return ret;
3266 }
3267 
3269  account_name_type moderator,
3270  const std::vector<market_type>& markets,
3271  const bool broadcast)
3272 {
3273  FC_ASSERT(!is_locked());
3274 
3276 
3277  op.uuid = uuid;
3278  op.moderator = moderator;
3279  op.markets = markets;
3280 
3281  signed_transaction tx;
3282  tx.operations.push_back(op);
3283  tx.validate();
3284 
3286  ret = my->sign_transaction(tx, broadcast);
3287 
3288  return ret;
3289 }
3290 
3292  account_name_type moderator,
3293  fc::time_point_sec start_time,
3294  const bool broadcast)
3295 {
3296  FC_ASSERT(!is_locked());
3297 
3299 
3300  op.uuid = uuid;
3301  op.moderator = moderator;
3302  op.start_time = start_time;
3303 
3304  signed_transaction tx;
3305  tx.operations.push_back(op);
3306  tx.validate();
3307 
3309  ret = my->sign_transaction(tx, broadcast);
3310 
3311  return ret;
3312 }
3313 
3315  account_name_type moderator,
3316  const std::vector<wincase_type>& wincases,
3317  const bool broadcast)
3318 {
3319  FC_ASSERT(!is_locked());
3320 
3322 
3323  op.uuid = uuid;
3324  op.moderator = moderator;
3325  op.wincases = wincases;
3326 
3327  signed_transaction tx;
3328  tx.operations.push_back(op);
3329  tx.validate();
3330 
3332  ret = my->sign_transaction(tx, broadcast);
3333 
3334  return ret;
3335 }
3336 
3338  account_name_type better,
3339  uuid_type game_uuid,
3340  wincase_type wincase,
3341  odds_input odds,
3342  asset stake,
3343  bool is_live,
3344  const bool broadcast)
3345 {
3346  FC_ASSERT(!is_locked());
3347 
3348  post_bet_operation op;
3349 
3350  op.uuid = uuid;
3351  op.better = better;
3352  op.game_uuid = game_uuid;
3353  op.odds = odds;
3354  op.stake = stake;
3355  op.wincase = wincase;
3356  op.live = is_live;
3357 
3358  signed_transaction tx;
3359  tx.operations.push_back(op);
3360  tx.validate();
3361 
3362  return my->sign_transaction(tx, broadcast);
3363 }
3364 
3366 wallet_api::cancel_pending_bets(account_name_type better, const std::vector<uuid_type>& bet_uuids, const bool broadcast)
3367 {
3368  FC_ASSERT(!is_locked());
3369 
3371 
3372  op.better = better;
3373  op.bet_uuids = bet_uuids;
3374 
3375  signed_transaction tx;
3376  tx.operations.push_back(op);
3377  tx.validate();
3378 
3379  return my->sign_transaction(tx, broadcast);
3380 }
3381 
3383 {
3384  exit_func();
3385 }
3386 
3388 {
3389  return my->_chain_api->get_chain_capital();
3390 }
3391 
3392 std::vector<game_api_object> wallet_api::get_games_by_status(const fc::flat_set<game_status>& filter) const
3393 {
3394  auto api = my->_remote_api->get_api_by_name(API_BETTING)->as<betting_api>();
3395 
3396  return api->get_games_by_status(filter);
3397 }
3398 
3399 std::vector<game_api_object> wallet_api::get_games_by_uuids(const std::vector<uuid_type>& uuids) const
3400 {
3401  auto api = my->_remote_api->get_api_by_name(API_BETTING)->as<betting_api>();
3402 
3403  return api->get_games_by_uuids(uuids);
3404 }
3405 
3406 std::vector<game_api_object> wallet_api::lookup_games_by_id(game_id_type from, uint32_t limit) const
3407 {
3408  auto api = my->_remote_api->get_api_by_name(API_BETTING)->as<betting_api>();
3409 
3410  return api->lookup_games_by_id(from, limit);
3411 }
3412 
3413 std::vector<matched_bet_api_object> wallet_api::lookup_matched_bets(matched_bet_id_type from, int64_t limit) const
3414 {
3415  auto api = my->_remote_api->get_api_by_name(API_BETTING)->as<betting_api>();
3416 
3417  return api->lookup_matched_bets(from, limit);
3418 }
3419 
3420 std::vector<pending_bet_api_object> wallet_api::lookup_pending_bets(pending_bet_id_type from, int64_t limit) const
3421 {
3422  auto api = my->_remote_api->get_api_by_name(API_BETTING)->as<betting_api>();
3423 
3424  return api->lookup_pending_bets(from, limit);
3425 }
3426 
3427 std::vector<matched_bet_api_object> wallet_api::get_matched_bets(const std::vector<uuid_type>& uuids) const
3428 {
3429  auto api = my->_remote_api->get_api_by_name(API_BETTING)->as<betting_api>();
3430 
3431  return api->get_matched_bets(uuids);
3432 }
3433 
3434 std::vector<pending_bet_api_object> wallet_api::get_pending_bets(const std::vector<uuid_type>& uuids) const
3435 {
3436  auto api = my->_remote_api->get_api_by_name(API_BETTING)->as<betting_api>();
3437 
3438  return api->get_pending_bets(uuids);
3439 }
3440 
3442 {
3443  auto api = my->_remote_api->get_api_by_name(API_BETTING)->as<betting_api>();
3444 
3445  return api->get_betting_properties();
3446 }
3447 
3448 std::vector<matched_bet_api_object> wallet_api::get_game_returns(const uuid_type& game_uuid) const
3449 {
3450  auto api = my->_remote_api->get_api_by_name(API_BETTING)->as<betting_api>();
3451 
3452  return api->get_game_returns(game_uuid);
3453 }
3454 
3455 std::vector<winner_api_object> wallet_api::get_game_winners(const uuid_type& game_uuid) const
3456 {
3457  auto api = my->_remote_api->get_api_by_name(API_BETTING)->as<betting_api>();
3458 
3459  return api->get_game_winners(game_uuid);
3460 }
3461 
3462 std::vector<matched_bet_api_object> wallet_api::get_game_matched_bets(const uuid_type& uuid) const
3463 {
3464  auto api = my->_remote_api->get_api_by_name(API_BETTING)->as<betting_api>();
3465 
3466  return api->get_game_matched_bets(uuid);
3467 }
3468 
3469 std::vector<pending_bet_api_object> wallet_api::get_game_pending_bets(const uuid_type& uuid) const
3470 {
3471  auto api = my->_remote_api->get_api_by_name(API_BETTING)->as<betting_api>();
3472 
3473  return api->get_game_pending_bets(uuid);
3474 }
3475 
3477  const uuid_type& uuid,
3478  const std::string& name,
3479  int32_t initial_power,
3480  const std::string& json_meta,
3481  const bool broadcast) const
3482 {
3483  FC_ASSERT(!is_locked());
3484 
3486  op.owner = owner;
3487  op.uuid = uuid;
3488  op.name = name;
3489  op.json_metadata = json_meta;
3490  op.initial_power = initial_power;
3491 
3492  signed_transaction tx;
3493  tx.operations.emplace_back(op);
3494  tx.validate();
3495 
3496  return my->sign_transaction(tx, broadcast);
3497 }
3498 
3500  const uuid_type& uuid,
3501  const std::string& json_meta,
3502  const bool broadcast) const
3503 {
3504  FC_ASSERT(!is_locked());
3505 
3507  op.uuid = uuid;
3508  op.moderator = moderator;
3509  op.json_metadata = json_meta;
3510 
3511  signed_transaction tx;
3512  tx.operations.emplace_back(op);
3513  tx.validate();
3514 
3515  return my->sign_transaction(tx, broadcast);
3516 }
3517 
3519  const uuid_type& uuid,
3520  int32_t experience,
3521  bool broadcast) const
3522 {
3523  FC_ASSERT(!is_locked());
3524 
3526  op.uuid = uuid;
3527  op.moderator = moderator;
3528  op.experience = experience;
3529 
3530  signed_transaction tx;
3531  tx.operations.emplace_back(op);
3532  tx.validate();
3533 
3534  return my->sign_transaction(tx, broadcast);
3535 }
3536 
3538  const uuid_type& uuid,
3539  const std::string& name,
3540  const bool broadcast) const
3541 {
3542  FC_ASSERT(!is_locked());
3543 
3545  op.uuid = uuid;
3546  op.moderator = moderator;
3547  op.name = name;
3548 
3549  signed_transaction tx;
3550  tx.operations.emplace_back(op);
3551  tx.validate();
3552 
3553  return my->sign_transaction(tx, broadcast);
3554 }
3555 
3557 {
3558  auto api = my->_remote_api->get_api_by_name(API_DATABASE)->as<database_api>();
3559  return api->get_nft_by_id(id);
3560 }
3561 
3563 {
3564  auto api = my->_remote_api->get_api_by_name(API_DATABASE)->as<database_api>();
3565  return api->get_nft_by_name(name);
3566 }
3567 
3569 {
3570  auto api = my->_remote_api->get_api_by_name(API_DATABASE)->as<database_api>();
3571  return api->get_nft_by_uuid(uuid);
3572 }
3573 
3574 std::vector<nft_api_obj> wallet_api::lookup_nft(int64_t id, uint32_t limit) const
3575 {
3576  auto api = my->_remote_api->get_api_by_name(API_DATABASE)->as<database_api>();
3577  return api->lookup_nft(id, limit);
3578 }
3579 
3581  const uuid_type& uuid,
3582  const std::string& verification_key,
3583  const std::string& seed,
3584  const bool broadcast) const
3585 {
3586  FC_ASSERT(!is_locked());
3587 
3589  op.owner = owner;
3590  op.uuid = uuid;
3591  op.verification_key = verification_key;
3592  op.seed = seed;
3593 
3594  signed_transaction tx;
3595  tx.operations.emplace_back(op);
3596  tx.validate();
3597 
3598  return my->sign_transaction(tx, broadcast);
3599 }
3600 
3602  const uuid_type& uuid,
3603  const std::string& proof,
3604  const std::string& vrf,
3605  int32_t result,
3606  const bool broadcast) const
3607 {
3608  FC_ASSERT(!is_locked());
3609 
3611  op.owner = owner;
3612  op.uuid = uuid;
3613  op.proof = proof;
3614  op.vrf = vrf;
3615  op.result = result;
3616 
3617  signed_transaction tx;
3618  tx.operations.emplace_back(op);
3619  tx.validate();
3620 
3621  return my->sign_transaction(tx, broadcast);
3622 }
3623 
3625 {
3626  auto api = my->_remote_api->get_api_by_name(API_DATABASE)->as<database_api>();
3627  return api->get_game_round_by_uuid(uuid);
3628 }
3629 
3630 std::vector<game_round_api_obj> wallet_api::lookup_game_round(const int64_t id, const uint32_t limit) const
3631 {
3632  auto api = my->_remote_api->get_api_by_name(API_DATABASE)->as<database_api>();
3633  return api->lookup_game_round(id, limit);
3634 }
3635 
3636 } // namespace wallet
3637 } // namespace scorum
#define API_ACCOUNT_HISTORY
#define API_BETTING
Definition: betting_api.hpp:3
#define API_BLOCKCHAIN_HISTORY
#define API_CHAIN
Definition: chain_api.hpp:3
The chain_api class shows blockchain entrails.
Definition: chain_api.hpp:30
The network_broadcast_api class allows broadcasting of transactions.
Definition: api.hpp:56
The network_node_api class allows maintenance of p2p connections.
Definition: api.hpp:134
std::map< std::string, std::function< std::string(fc::variant, const fc::variants &)> > get_result_formatters() const
Definition: wallet.cpp:723
std::vector< variant > network_get_connected_peers()
Definition: wallet.cpp:977
optional< witness_api_obj > get_witness(const std::string &owner_account)
Definition: wallet.cpp:487
signed_transaction create_account_with_private_key(fc::ecc::private_key owner_privkey, const std::string &account_name, const std::string &creator_account_name, bool broadcast=false, bool save_wallet=true)
Definition: wallet.cpp:425
optional< fc::api< network_node_api > > _remote_net_node
Definition: wallet.cpp:1012
optional< fc::api< account_by_key::account_by_key_api > > _remote_account_by_key_api
Definition: wallet.cpp:1013
operation get_prototype_operation(const std::string &operation_name)
Definition: wallet.cpp:992
std::map< public_key_type, std::string > _keys
Definition: wallet.cpp:1003
bool import_key(const std::string &wif_key)
Definition: wallet.cpp:323
variant_object about() const
Definition: wallet.cpp:237
std::string print_atomicswap_secret2str(const std::string &secret) const
Definition: wallet.cpp:664
signed_transaction set_voting_proxy(const std::string &account_to_modify, const std::string &proxy, bool broadcast)
Definition: wallet.cpp:470
optional< fc::ecc::private_key > try_get_private_key(const public_key_type &id) const
Definition: wallet.cpp:296
bool copy_wallet_file(const std::string &destination_filename)
Definition: wallet.cpp:181
fc::ecc::private_key get_private_key_for_account(const account_api_obj &account) const
Definition: wallet.cpp:311
wallet_api_impl(wallet_api &s, const wallet_data &initial_data, fc::api< login_api > rapi)
Definition: wallet.cpp:142
int find_first_unused_derived_key_index(const fc::ecc::private_key &parent_key)
Definition: wallet.cpp:394
optional< fc::api< blockchain_history::blockchain_history_api > > _remote_blockchain_history_api
Definition: wallet.cpp:1015
std::string get_wallet_filename() const
Definition: wallet.cpp:291
optional< fc::api< blockchain_history::account_history_api > > _remote_account_history_api
Definition: wallet.cpp:1014
void save_wallet_file(std::string wallet_filename="")
Definition: wallet.cpp:351
fc::api< database_api > _remote_db
Definition: wallet.cpp:1009
annotated_signed_transaction sign_transaction(signed_transaction tx, bool broadcast=false)
Definition: wallet.cpp:498
flat_map< std::string, operation > _prototype_ops
Definition: wallet.cpp:1020
std::string print_atomicswap_contract2str(const atomicswap_contract_info_api_obj &rt) const
Definition: wallet.cpp:674
api_documentation method_documentation
Definition: wallet.cpp:113
fc::api< network_broadcast_api > _remote_net_broadcast
Definition: wallet.cpp:1011
fc::ecc::private_key get_private_key(const public_key_type &id) const
Definition: wallet.cpp:304
bool load_wallet_file(std::string wallet_filename="")
Definition: wallet.cpp:335
void network_add_nodes(const std::vector< std::string > &nodes)
Definition: wallet.cpp:968
account_api_obj get_account(const std::string &account_name) const
Definition: wallet.cpp:284
optional< fc::api< blockchain_history::devcommittee_history_api > > _remote_devcommittee_history_api
Definition: wallet.cpp:1016
void set_transaction_expiration(uint32_t tx_expiration_seconds)
Definition: wallet.cpp:492
std::function< void()> exit_func_type
Definition: wallet.hpp:112
std::map< std::string, std::function< std::string(fc::variant, const fc::variants &)> > get_result_formatters() const
Definition: wallet.cpp:1298
void set_exit_func(exit_func_type)
Definition: wallet.cpp:1042
void check_memo(const std::string &memo, const account_api_obj &account) const
Definition: wallet.cpp:2005
bool copy_wallet_file(const std::string &destination_filename)
Definition: wallet.cpp:1047
wallet_api(const wallet_data &initial_data, fc::api< login_api > rapi)
Definition: wallet.cpp:1032
#define SCORUM_CREATE_ACCOUNT_WITH_SCORUM_MODIFIER
Definition: config.hpp:120
#define SP_SYMBOL
Definition: config.hpp:104
#define SCORUM_SYMBOL
Definition: config.hpp:102
#define SCORUM_BLOCKCHAIN_VERSION
Definition: config.hpp:91
#define SCORUM_MAX_TIME_UNTIL_EXPIRATION
Definition: config.hpp:184
#define API_DATABASE
Definition: database_api.hpp:3
#define API_DEVCOMMITTEE_HISTORY
std::vector< pending_bet_api_object > lookup_pending_bets(chain::pending_bet_id_type from, uint32_t limit) const
Return pending bets.
Definition: betting_api.cpp:55
std::vector< winner_api_object > get_game_winners(const uuid_type &game_uuid) const
Returns all winners for particular game.
Definition: betting_api.cpp:30
std::vector< pending_bet_api_object > get_game_pending_bets(const uuid_type &uuid) const
Return pending bets for game.
Definition: betting_api.cpp:75
std::vector< pending_bet_api_object > get_pending_bets(const std::vector< uuid_type > &uuids) const
Return pending bets.
Definition: betting_api.cpp:65
std::vector< matched_bet_api_object > get_game_returns(const uuid_type &game_uuid) const
Returns bets with draw status.
Definition: betting_api.cpp:25
std::vector< matched_bet_api_object > lookup_matched_bets(chain::matched_bet_id_type from, uint32_t limit) const
Returns matched bets.
Definition: betting_api.cpp:50
betting_property_api_object get_betting_properties() const
Return betting properties.
Definition: betting_api.cpp:80
std::vector< game_api_object > lookup_games_by_id(chain::game_id_type from, uint32_t limit) const
Returns games.
Definition: betting_api.cpp:45
std::vector< game_api_object > get_games_by_uuids(const std::vector< uuid_type > &uuids) const
Returns games.
Definition: betting_api.cpp:40
std::vector< matched_bet_api_object > get_game_matched_bets(const uuid_type &uuid) const
Returns matched bets for game.
Definition: betting_api.cpp:70
std::vector< game_api_object > get_games_by_status(const fc::flat_set< chain::game_status > &filter) const
Returns games.
Definition: betting_api.cpp:35
std::vector< matched_bet_api_object > get_matched_bets(const std::vector< uuid_type > &uuids) const
Returns matched bets.
Definition: betting_api.cpp:60
std::vector< nft_api_obj > lookup_nft(int64_t from, uint32_t limit) const
Retrieve list of NFT objects in range [from, from+limit-1].
game_round_api_obj get_game_round_by_uuid(const uuid_type &uuid) const
Get game round by uuid object.
nft_api_obj get_nft_by_name(const account_name_type &name) const
Get NFT object by name.
nft_api_obj get_nft_by_id(int64_t id) const
Get NFT object by id.
nft_api_obj get_nft_by_uuid(const uuid_type &uuid) const
Get NFT object by uuid.
std::vector< game_round_api_obj > lookup_game_round(int64_t id, uint32_t limit) const
Retrieve list of game rounds in range [from, from+limit-1].
annotated_signed_transaction close_budget_for_post_by_moderator(const uuid_type &uuid, const std::string &moderator, bool broadcast)
Definition: wallet.cpp:2715
annotated_signed_transaction create_budget_for_banner(const std::string &owner, const uuid_type &uuid, const std::string &json_metadata, const asset &balance, const time_point_sec &start, const time_point_sec &deadline, bool broadcast)
Definition: wallet.cpp:2618
annotated_signed_transaction close_budget_for_banner_by_moderator(const uuid_type &uuid, const std::string &moderator, bool broadcast)
Definition: wallet.cpp:2734
annotated_signed_transaction update_budget_for_post(const std::string &owner, const uuid_type &uuid, const std::string &json_metadata, bool broadcast)
Definition: wallet.cpp:2670
std::vector< budget_api_obj > list_my_budgets()
Definition: wallet.cpp:2535
annotated_signed_transaction close_budget_for_post(const uuid_type &uuid, const std::string &owner, bool broadcast)
Definition: wallet.cpp:2680
annotated_signed_transaction close_budget_for_banner(const uuid_type &uuid, const std::string &owner, bool broadcast)
Definition: wallet.cpp:2698
std::vector< budget_api_obj > get_banner_budgets(const std::string &account_name)
Definition: wallet.cpp:2584
std::vector< budget_api_obj > get_post_budgets(const std::string &account_name)
Definition: wallet.cpp:2577
annotated_signed_transaction create_budget_for_post(const std::string &owner, const uuid_type &uuid, const std::string &json_metadata, const asset &balance, const time_point_sec &start, const time_point_sec &deadline, bool broadcast)
Definition: wallet.cpp:2591
std::set< std::string > list_post_budget_owners(const std::string &lowerbound, uint32_t limit)
Definition: wallet.cpp:2567
annotated_signed_transaction update_budget_for_banner(const std::string &owner, const uuid_type &uuid, const std::string &json_metadata, bool broadcast)
Definition: wallet.cpp:2661
std::set< std::string > list_banner_budget_owners(const std::string &lowerbound, uint32_t limit)
Definition: wallet.cpp:2572
atomicswap_contract_result_api_obj atomicswap_initiate(const std::string &initiator, const std::string &participant, const asset &amount, const std::string &metadata, const uint8_t secret_length, bool broadcast)
Definition: wallet.cpp:3091
atomicswap_contract_info_api_obj atomicswap_auditcontract(const std::string &from, const std::string &to, const std::string &secret_hash)
Definition: wallet.cpp:3173
annotated_signed_transaction atomicswap_redeem(const std::string &from, const std::string &to, const std::string &secret, bool broadcast)
Definition: wallet.cpp:3152
std::vector< atomicswap_contract_api_obj > get_atomicswap_contracts(const std::string &owner)
Definition: wallet.cpp:3209
atomicswap_contract_result_api_obj atomicswap_participate(const std::string &secret_hash, const std::string &participant, const std::string &initiator, const asset &amount, const std::string &metadata, bool broadcast)
Definition: wallet.cpp:3125
annotated_signed_transaction atomicswap_refund(const std::string &participant, const std::string &initiator, const std::string &secret_hash, bool broadcast)
Definition: wallet.cpp:3189
std::string atomicswap_extractsecret(const std::string &from, const std::string &to, const std::string &secret_hash)
Definition: wallet.cpp:3179
std::vector< winner_api_object > get_game_winners(const uuid_type &game_uuid) const
Definition: wallet.cpp:3455
std::vector< pending_bet_api_object > get_game_pending_bets(const uuid_type &uuid) const
Definition: wallet.cpp:3469
annotated_signed_transaction cancel_pending_bets(account_name_type better, const std::vector< uuid_type > &bet_uuids, bool broadcast)
Definition: wallet.cpp:3366
annotated_signed_transaction cancel_game(uuid_type uuid, account_name_type moderator, bool broadcast)
Definition: wallet.cpp:3249
std::vector< pending_bet_api_object > get_pending_bets(const std::vector< uuid_type > &uuids) const
Definition: wallet.cpp:3434
std::vector< matched_bet_api_object > get_game_returns(const uuid_type &game_uuid) const
Definition: wallet.cpp:3448
annotated_signed_transaction update_game_markets(uuid_type uuid, account_name_type moderator, const std::vector< market_type > &markets, bool broadcast)
Definition: wallet.cpp:3268
annotated_signed_transaction post_bet(uuid_type uuid, account_name_type better, uuid_type game_uuid, wincase_type wincase, odds_input odds, asset stake, bool is_live, bool broadcast)
Definition: wallet.cpp:3337
std::vector< pending_bet_api_object > lookup_pending_bets(pending_bet_id_type from, int64_t limit) const
Definition: wallet.cpp:3420
annotated_signed_transaction update_game_start_time(uuid_type uuid, account_name_type moderator, fc::time_point_sec start_time, bool broadcast)
Definition: wallet.cpp:3291
std::vector< matched_bet_api_object > get_matched_bets(const std::vector< uuid_type > &uuids) const
Definition: wallet.cpp:3427
betting_property_api_object get_betting_properties() const
Definition: wallet.cpp:3441
std::vector< matched_bet_api_object > lookup_matched_bets(matched_bet_id_type from, int64_t limit) const
Definition: wallet.cpp:3413
std::vector< game_api_object > get_games_by_uuids(const std::vector< uuid_type > &uuids) const
Definition: wallet.cpp:3399
annotated_signed_transaction create_game(uuid_type uuid, account_name_type moderator, const std::string &json_metadata, fc::time_point_sec start_time, uint32_t auto_resolve_delay_sec, game_type game, const std::vector< market_type > &markets, bool broadcast)
Definition: wallet.cpp:3218
std::vector< matched_bet_api_object > get_game_matched_bets(const uuid_type &uuid) const
Definition: wallet.cpp:3462
std::vector< game_api_object > get_games_by_status(const fc::flat_set< game_status > &filter) const
Definition: wallet.cpp:3392
std::vector< game_api_object > lookup_games_by_id(game_id_type from, uint32_t limit) const
Definition: wallet.cpp:3406
annotated_signed_transaction post_game_results(uuid_type uuid, account_name_type moderator, const std::vector< wincase_type > &wincases, bool broadcast)
Definition: wallet.cpp:3314
std::vector< applied_operation > get_devcommittee_history(uint64_t from, uint32_t limit)
Definition: wallet.cpp:2407
annotated_signed_transaction development_committee_change_base_quorum(const std::string &creator, uint64_t quorum_percent, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:2928
registration_committee_api_obj get_registration_committee()
Definition: wallet.cpp:2816
annotated_signed_transaction registration_committee_change_exclude_member_quorum(const std::string &creator, uint64_t quorum_percent, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:2841
annotated_signed_transaction development_committee_empower_betting_moderator(const std::string &initiator, const std::string &moderator, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:3008
annotated_signed_transaction development_committee_add_member(const std::string &initiator, const std::string &invitee, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:2869
development_committee_api_obj get_development_committee()
Definition: wallet.cpp:3086
annotated_signed_transaction development_committee_change_add_member_quorum(const std::string &creator, uint64_t quorum_percent, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:2900
annotated_signed_transaction development_committee_change_betting_moderator_quorum(const std::string &creator, uint64_t quorum_percent, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:2984
annotated_signed_transaction vote_for_committee_proposal(const std::string &account_to_vote_with, int64_t proposal_id, bool broadcast)
Definition: wallet.cpp:2772
annotated_signed_transaction registration_committee_change_add_member_quorum(const std::string &creator, uint64_t quorum_percent, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:2826
std::set< account_name_type > list_registration_committee(const std::string &lowerbound, uint32_t limit)
Definition: wallet.cpp:2811
annotated_signed_transaction development_committee_change_transfer_quorum(const std::string &creator, uint64_t quorum_percent, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:2943
std::vector< applied_withdraw_operation > get_devcommittee_sp_to_scr_transfers(uint64_t from, uint32_t limit)
Definition: wallet.cpp:2427
annotated_signed_transaction development_committee_change_betting_resolve_delay(const std::string &initiator, uint32_t delay_sec, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:3021
annotated_signed_transaction development_committee_change_advertising_moderator_quorum(const std::string &creator, uint64_t quorum_percent, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:2971
std::vector< applied_operation > get_devcommittee_scr_to_scr_transfers(uint64_t from, uint32_t limit)
Definition: wallet.cpp:2417
annotated_signed_transaction development_committee_change_budget_auction_properties_quorum(const std::string &creator, uint64_t quorum_percent, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:2958
annotated_signed_transaction registration_committee_exclude_member(const std::string &initiator, const std::string &dropout, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:2798
annotated_signed_transaction registration_committee_change_base_quorum(const std::string &creator, uint64_t quorum_percent, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:2854
annotated_signed_transaction development_committee_change_exclude_member_quorum(const std::string &creator, uint64_t quorum_percent, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:2915
std::set< account_name_type > list_development_committee(const std::string &lowerbound, uint32_t limit)
Definition: wallet.cpp:2895
annotated_signed_transaction development_committee_empower_advertising_moderator(const std::string &initiator, const std::string &moderator, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:2997
std::vector< proposal_api_obj > list_proposals()
Definition: wallet.cpp:2821
annotated_signed_transaction development_pool_transfer(const std::string &initiator, const std::string &to_account, asset amount, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:3032
annotated_signed_transaction registration_committee_add_member(const std::string &inviter, const std::string &invitee, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:2785
annotated_signed_transaction development_committee_exclude_member(const std::string &initiator, const std::string &dropout, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:2882
annotated_signed_transaction development_pool_withdraw_vesting(const std::string &initiator, asset amount, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:3045
annotated_signed_transaction development_pool_post_budgets_auction_properties(const std::string &initiator, const std::vector< percent_type > &, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:3059
annotated_signed_transaction development_pool_banner_budgets_auction_properties(const std::string &initiator, const std::vector< percent_type > &, uint32_t lifetime_sec, bool broadcast)
Definition: wallet.cpp:3073
void set_transaction_expiration(uint32_t seconds)
Definition: wallet.cpp:2487
annotated_signed_transaction sign_transaction(const signed_transaction &tx, bool broadcast=false)
Definition: wallet.cpp:1230
operation get_prototype_operation(const std::string &operation_type)
Definition: wallet.cpp:1239
std::string serialize_transaction(const signed_transaction &tx) const
Definition: wallet.cpp:1149
void network_add_nodes(const std::vector< std::string > &nodes)
Definition: wallet.cpp:1244
std::vector< variant > network_get_connected_peers()
Definition: wallet.cpp:1249
std::map< uint32_t, applied_operation > get_ops_in_block(uint32_t block_num, applied_operation_type type_of_operation) const
Definition: wallet.cpp:1080
std::map< uint32_t, block_header > get_block_headers_history(uint32_t num, uint32_t limit) const
Definition: wallet.cpp:1066
std::vector< block_api_object > get_blocks(uint32_t from, uint32_t limit) const
Definition: wallet.cpp:1106
std::map< uint32_t, applied_operation > get_ops_history_by_time(const fc::time_point_sec &from, const fc::time_point_sec &to, uint32_t from_op, uint32_t limit) const
Definition: wallet.cpp:1096
std::map< uint32_t, signed_block_api_obj > get_blocks_history(uint32_t num, uint32_t limit) const
Definition: wallet.cpp:1073
std::map< uint32_t, applied_operation > get_ops_history(uint32_t from_op, uint32_t limit, applied_operation_type type_of_operation) const
Definition: wallet.cpp:1089
optional< block_header > get_block_header(uint32_t num) const
Definition: wallet.cpp:1052
optional< signed_block_api_obj > get_block(uint32_t num) const
Definition: wallet.cpp:1059
bool import_key(const std::string &wif_key)
Definition: wallet.cpp:1169
brain_key_info suggest_brain_key() const
Definition: wallet.cpp:1225
std::map< public_key_type, std::string > list_keys()
Definition: wallet.cpp:1356
std::pair< public_key_type, std::string > get_private_key_from_password(const std::string &account, const std::string &role, const std::string &password) const
Definition: wallet.cpp:1367
std::string get_private_key(const public_key_type &pubkey) const
Definition: wallet.cpp:1362
std::string normalize_brain_key(const std::string &s) const
Definition: wallet.cpp:1188
std::map< uint32_t, applied_operation > get_account_scr_to_sp_transfers(const std::string &account, uint64_t from, uint32_t limit)
Definition: wallet.cpp:2373
annotated_signed_transaction withdraw_scorumpower(const std::string &from, const asset &scorumpower, bool broadcast=false)
Definition: wallet.cpp:2240
optional< witness_api_obj > get_witness(const std::string &owner_account)
Definition: wallet.cpp:1208
annotated_signed_transaction challenge(const std::string &challenger, const std::string &challenged, bool broadcast)
Definition: wallet.cpp:2493
annotated_signed_transaction decline_voting_rights(const std::string &account, bool decline, bool broadcast)
Definition: wallet.cpp:2316
annotated_signed_transaction update_account_memo_key(const std::string &account_name, const public_key_type &key, bool broadcast)
Definition: wallet.cpp:1826
annotated_signed_transaction change_recovery_account(const std::string &owner, const std::string &new_recovery_account, bool broadcast)
Definition: wallet.cpp:1549
annotated_signed_transaction escrow_release(const std::string &from, const std::string &to, const std::string &agent, const std::string &who, const std::string &receiver, uint32_t escrow_id, const asset &scorum_amount, bool broadcast=false)
Definition: wallet.cpp:2198
account_api_obj get_account(const std::string &account_name) const
Definition: wallet.cpp:1159
annotated_signed_transaction vote(const std::string &voter, const std::string &author, const std::string &permlink, int16_t weight, bool broadcast)
Definition: wallet.cpp:2468
annotated_signed_transaction create_account_with_keys(const std::string &creator, const std::string &newname, const std::string &json_meta, const public_key_type &owner, const public_key_type &active, const public_key_type &posting, const public_key_type &memo, bool broadcast) const
Definition: wallet.cpp:1383
annotated_signed_transaction get_transaction(transaction_id_type trx_id) const
Definition: wallet.cpp:2528
std::map< uint32_t, applied_withdraw_operation > get_account_sp_to_scr_transfers(const std::string &account, uint64_t from, uint32_t limit)
Definition: wallet.cpp:2392
annotated_signed_transaction create_account_with_keys_delegated(const std::string &creator, const asset &scorum_fee, const asset &delegated_scorumpower, const std::string &newname, const std::string &json_meta, const public_key_type &owner, const public_key_type &active, const public_key_type &posting, const public_key_type &memo, bool broadcast) const
Definition: wallet.cpp:1420
std::map< uint32_t, applied_operation > get_account_history(const std::string &account, uint64_t from, uint32_t limit)
Definition: wallet.cpp:2331
annotated_signed_transaction create_account(const std::string &creator, const std::string &newname, const std::string &json_meta, bool broadcast)
Definition: wallet.cpp:1898
std::vector< withdraw_route > get_withdraw_routes(const std::string &account, withdraw_route_type type=all) const
Definition: wallet.cpp:2437
annotated_signed_transaction update_account(const std::string &accountname, const std::string &json_meta, const public_key_type &owner, const public_key_type &active, const public_key_type &posting, const public_key_type &memo, bool broadcast) const
Definition: wallet.cpp:1569
annotated_signed_transaction create_account_delegated(const std::string &creator, const asset &scorum_fee, const asset &delegated_scorumpower, const std::string &new_account_name, const std::string &json_meta, bool broadcast)
Definition: wallet.cpp:1924
annotated_signed_transaction escrow_dispute(const std::string &from, const std::string &to, const std::string &agent, const std::string &who, uint32_t escrow_id, bool broadcast=false)
Definition: wallet.cpp:2176
annotated_signed_transaction transfer_to_scorumpower(const std::string &from, const std::string &to, const asset &amount, bool broadcast=false)
Definition: wallet.cpp:2224
annotated_signed_transaction update_account_auth_key(const std::string &account_name, const authority_type &type, const public_key_type &key, authority_weight_type weight, bool broadcast)
Definition: wallet.cpp:1598
annotated_signed_transaction update_witness(const std::string &witness_name, const std::string &url, const public_key_type &block_signing_key, const chain_properties &props, bool broadcast=false)
Definition: wallet.cpp:1949
std::set< std::string > list_accounts(const std::string &lowerbound, uint32_t limit)
Definition: wallet.cpp:1139
annotated_signed_transaction update_account_meta(const std::string &account_name, const std::string &json_meta, bool broadcast)
Definition: wallet.cpp:1805
annotated_signed_transaction post_comment(const std::string &author, const std::string &permlink, const std::string &parent_author, const std::string &parent_permlink, const std::string &title, const std::string &body, const std::string &json, bool broadcast)
Definition: wallet.cpp:2442
std::vector< owner_authority_history_api_obj > get_owner_history(const std::string &account) const
Get the owner history object.
Definition: wallet.cpp:1564
annotated_signed_transaction update_account_auth_threshold(const std::string &account_name, authority_type type, uint32_t threshold, bool broadcast)
Definition: wallet.cpp:1740
annotated_signed_transaction request_account_recovery(const std::string &recovery_account, const std::string &account_to_recover, const authority &new_authority, bool broadcast)
Definition: wallet.cpp:1511
annotated_signed_transaction set_voting_proxy(const std::string &account_to_modify, const std::string &proxy, bool broadcast=false)
Definition: wallet.cpp:1213
annotated_signed_transaction create_account_by_committee_with_keys(const std::string &creator, const std::string &newname, const std::string &json_meta, const public_key_type &owner, const public_key_type &active, const public_key_type &posting, const public_key_type &memo, bool broadcast) const
Definition: wallet.cpp:1454
std::vector< account_api_obj > list_my_accounts()
Definition: wallet.cpp:1113
chain_capital_api_obj get_chain_capital() const
Definition: wallet.cpp:3387
annotated_signed_transaction delegate_scorumpower_from_reg_pool(const std::string &reg_committee_member, const std::string &delegatee, const asset &scorumpower, bool broadcast)
Definition: wallet.cpp:1870
annotated_signed_transaction prove(const std::string &challenged, bool broadcast)
Definition: wallet.cpp:2513
annotated_signed_transaction set_withdraw_scorumpower_route(const std::string &from, const std::string &to, uint16_t percent, bool auto_vest, bool broadcast=false)
Definition: wallet.cpp:2254
annotated_signed_transaction create_account_by_committee(const std::string &creator, const std::string &newname, const std::string &json_meta, bool broadcast)
Definition: wallet.cpp:1488
std::string decrypt_memo(const std::string &memo)
Definition: wallet.cpp:2271
annotated_signed_transaction recover_account(const std::string &account_to_recover, const authority &recent_authority, const authority &new_authority, bool broadcast)
Definition: wallet.cpp:1529
std::map< uint32_t, applied_operation > get_account_scr_to_scr_transfers(const std::string &account, uint64_t from, uint32_t limit)
Definition: wallet.cpp:2354
account_balance_info_api_obj get_account_balance(const std::string &account_name) const
Definition: wallet.cpp:1164
annotated_signed_transaction vote_for_witness(const std::string &account_to_vote_with, const std::string &witness_to_vote_for, bool approve=true, bool broadcast=false)
Definition: wallet.cpp:1983
annotated_signed_transaction escrow_approve(const std::string &from, const std::string &to, const std::string &agent, const std::string &who, uint32_t escrow_id, bool approve, bool broadcast=false)
Definition: wallet.cpp:2153
annotated_signed_transaction delegate_scorumpower(const std::string &delegator, const std::string &delegatee, const asset &scorumpower, bool broadcast)
Definition: wallet.cpp:1846
annotated_signed_transaction transfer(const std::string &from, const std::string &to, const asset &amount, const std::string &memo, bool broadcast=false)
Definition: wallet.cpp:2100
annotated_signed_transaction update_account_auth_account(const std::string &account_name, authority_type type, const std::string &auth_account, authority_weight_type weight, bool broadcast)
Definition: wallet.cpp:1669
std::vector< account_name_type > get_active_witnesses() const
Definition: wallet.cpp:1144
std::string get_encrypted_memo(const std::string &from, const std::string &to, const std::string &memo)
Definition: wallet.cpp:2068
std::set< account_name_type > list_witnesses(const std::string &lowerbound, uint32_t limit)
Definition: wallet.cpp:1203
annotated_signed_transaction escrow_transfer(const std::string &from, const std::string &to, const std::string &agent, uint32_t escrow_id, const asset &scorum_amount, const asset &fee, time_point_sec ratification_deadline, time_point_sec escrow_expiration, const std::string &json_meta, bool broadcast=false)
Definition: wallet.cpp:2123
void unlock(const std::string &password)
Definition: wallet.cpp:1332
std::string gethelp(const std::string &method) const
Definition: wallet.cpp:1272
void set_password(const std::string &password)
Definition: wallet.cpp:1348
void save_wallet_file(const std::string &wallet_filename="")
Definition: wallet.cpp:1292
std::string get_wallet_filename() const
Definition: wallet.cpp:1154
std::string help() const
Definition: wallet.cpp:1254
bool load_wallet_file(const std::string &wallet_filename="")
Definition: wallet.cpp:1287
void set_wallet_filename(const std::string &wallet_filename)
Definition: wallet.cpp:1220
variant_object about() const
Definition: wallet.cpp:1198
nft_api_obj get_nft_by_id(int64_t id) const
Definition: wallet.cpp:3556
annotated_signed_transaction update_nft_name(const std::string &moderator, const uuid_type &uuid, const std::string &name, bool broadcast) const
Definition: wallet.cpp:3537
std::vector< game_round_api_obj > lookup_game_round(int64_t from, uint32_t limit) const
Definition: wallet.cpp:3630
annotated_signed_transaction adjust_nft_experience(const std::string &moderator, const uuid_type &uuid, int32_t experience, bool broadcast) const
Definition: wallet.cpp:3518
annotated_signed_transaction update_game_round_result(const std::string &owner, const uuid_type &uuid, const std::string &proof, const std::string &vrf, int32_t result, bool broadcast) const
Definition: wallet.cpp:3601
nft_api_obj get_nft_by_uuid(const uuid_type &uuid) const
Definition: wallet.cpp:3568
game_round_api_obj get_game_round_by_uuid(const uuid_type &uuid) const
Definition: wallet.cpp:3624
annotated_signed_transaction create_game_round(const std::string &owner, const uuid_type &uuid, const std::string &verification_key, const std::string &seed, bool broadcast) const
Definition: wallet.cpp:3580
std::vector< nft_api_obj > lookup_nft(int64_t from, uint32_t limit) const
Definition: wallet.cpp:3574
annotated_signed_transaction update_nft_meta(const std::string &moderator, const uuid_type &uuid, const std::string &json_meta, bool broadcast) const
Definition: wallet.cpp:3499
annotated_signed_transaction create_nft(const std::string &owner, const uuid_type &uuid, const std::string &name, int32_t initial_power, const std::string &json_meta, bool broadcast) const
Definition: wallet.cpp:3476
nft_api_obj get_nft_by_name(const account_name_type &name) const
Definition: wallet.cpp:3562
void to_variant(const game_type &game, fc::variant &var)
Definition: game.cpp:8
std::string get_secret_hash(const std::string &secret_hex)
std::string get_secret_hex(const std::string &secret, const uint8_t secret_length)
development_committee_change_budgets_auction_properties_operation< budget_type::banner > development_committee_change_banner_budgets_auction_properties_operation
fc::ripemd160 transaction_id_type
Definition: types.hpp:65
fc::static_variant< vote_operation, comment_operation, transfer_operation, transfer_to_scorumpower_operation, withdraw_scorumpower_operation, account_create_by_committee_operation, account_create_operation, account_create_with_delegation_operation, account_update_operation, witness_update_operation, account_witness_vote_operation, account_witness_proxy_operation, delete_comment_operation, comment_options_operation, set_withdraw_scorumpower_route_to_account_operation, set_withdraw_scorumpower_route_to_dev_pool_operation, prove_authority_operation, request_account_recovery_operation, recover_account_operation, change_recovery_account_operation, escrow_approve_operation, escrow_dispute_operation, escrow_release_operation, escrow_transfer_operation, decline_voting_rights_operation, delegate_scorumpower_operation, create_budget_operation, close_budget_operation, proposal_vote_operation, proposal_create_operation, atomicswap_initiate_operation, atomicswap_redeem_operation, atomicswap_refund_operation, close_budget_by_advertising_moderator_operation, update_budget_operation, create_game_operation, cancel_game_operation, update_game_markets_operation, update_game_start_time_operation, post_game_results_operation, post_bet_operation, cancel_pending_bets_operation, delegate_sp_from_reg_pool_operation, create_nft_operation, update_nft_meta_operation, create_game_round_operation, update_game_round_result_operation, adjust_nft_experience_operation, update_nft_name_operation, author_reward_operation, comment_benefficiary_reward_operation, comment_payout_update_operation, comment_reward_operation, curation_reward_operation, hardfork_operation, producer_reward_operation, active_sp_holders_reward_operation, return_scorumpower_delegation_operation, shutdown_witness_operation, witness_miss_block_operation, expired_contract_refund_operation, acc_finished_vesting_withdraw_operation, devpool_finished_vesting_withdraw_operation, acc_to_acc_vesting_withdraw_operation, devpool_to_acc_vesting_withdraw_operation, acc_to_devpool_vesting_withdraw_operation, devpool_to_devpool_vesting_withdraw_operation, proposal_virtual_operation, budget_outgo_operation, budget_owner_income_operation, active_sp_holders_reward_legacy_operation, budget_closing_operation, bets_matched_operation, game_status_changed_operation, bet_resolved_operation, bet_cancelled_operation, bet_restored_operation, bet_updated_operation > operation
Definition: operations.hpp:112
fc::fixed_string_16 account_name_type
Definition: types.hpp:62
fc::sha256 chain_id_type
Definition: types.hpp:61
uint16_t authority_weight_type
Definition: types.hpp:68
fc::static_variant< result_home::yes, result_home::no, result_draw::yes, result_draw::no, result_away::yes, result_away::no, round_home::yes, round_home::no, handicap::over, handicap::under, correct_score_home::yes, correct_score_home::no, correct_score_draw::yes, correct_score_draw::no, correct_score_away::yes, correct_score_away::no, correct_score::yes, correct_score::no, goal_home::yes, goal_home::no, goal_both::yes, goal_both::no, goal_away::yes, goal_away::no, total::over, total::under, total_goals_home::over, total_goals_home::under, total_goals_away::over, total_goals_away::under > wincase_type
Definition: market.hpp:128
void validate_account_name(const std::string &name)
Definition: base.hpp:15
development_committee_change_budgets_auction_properties_operation< budget_type::post > development_committee_change_post_budgets_auction_properties_operation
fc::static_variant< soccer_game, hockey_game > game_type
Definition: game.hpp:14
optional< T > maybe_id(const std::string &name_or_id)
Definition: wallet.cpp:74
signed_transaction update_budget(const std::string &owner, uuid_type uuid, const std::string &json_metadata)
Definition: wallet.cpp:2646
fc::ecc::private_key derive_private_key(const std::string &prefix_string, int sequence_number)
Definition: utils.cpp:143
brain_key_info suggest_brain_key()
Definition: utils.cpp:151
signed_transaction proposal(const std::string &initiator, uint32_t lifetime_sec, C &&constructor)
Definition: wallet.cpp:2754
std::string normalize_brain_key(const std::string &s)
Definition: utils.cpp:29
Definition: asset.cpp:15
boost::uuids::uuid uuid_type
Definition: types.hpp:53
Creates new account by registration committee.
Updates account keys or/and metadata.
account_authority_map account_auths
Definition: authority.hpp:55
key_authority_map key_auths
Definition: authority.hpp:56
void add_authority(const public_key_type &k, authority_weight_type w)
Definition: authority.cpp:10
std::vector< public_key_type > get_keys() const
Definition: authority.cpp:20
uuid_type uuid
Universal Unique Identifier which is specified during game creation.
account_name_type moderator
moderator account name
This operation cancel unmatched bets by id.
std::vector< uuid_type > bet_uuids
bets list that is being canceling
Changes recovery account. Will be changed in 30 days.
account_name_type new_recovery_account
The account that creates the recover request.
account_name_type account_to_recover
The account that would be recovered in case of compromise.
Closes advertising budget by moderator, remaining funds will be returned to creator.
Closes advertising budget, remaining funds will be returned to creator.
This operation creates game object.
game_type game
game type (soccer, hockey, etc ...)
std::vector< market_type > markets
list of markets
uuid_type uuid
Universal Unique Identifier which is unique for each game.
account_name_type moderator
moderator account name
time_point_sec start_time
game start time
uint32_t auto_resolve_delay_sec
delay starting from start after which all bets are automatically resolved if game results weren't pro...
This operation create new game round.
Delegates scorumpower from one account to the other.
asset scorumpower
The amount of scorumpower delegated.
account_name_type delegatee
The account receiving scorumpower.
account_name_type delegator
The account delegating scorumpower.
asset scorum_amount
the amount of scorum to release
account_name_type to
the original 'to'
account_name_type who
the account that is attempting to release the funds, determines valid 'receiver'
account_name_type receiver
the account that should receive funds (might be from, might be to)
bool live
is this bet is active in live
uuid_type game_uuid
Universal Unique Identifier which is specified during game creation.
account_name_type better
owner for new bet
uuid_type uuid
Universal Unique Identifier which is unique for each bet.
odds_input odds
odds - rational coefficient that define potential result (p). p = odds * stake
With this operation moderator provides game results(wincases)
account_name_type moderator
moderator account name
uuid_type uuid
Universal Unique Identifier which is specified during game creation.
std::vector< wincase_type > wincases
list of wincases
Proves authority to remove challenge.
Recovers an account to a new authority using a previous authority.
account_name_type account_to_recover
The account to be recovered.
authority new_owner_authority
The new owner authority as specified in the request account recovery operation.
account_name_type account_to_recover
The account to recover. This is likely due to a compromised owner authority.
account_name_type recovery_account
The recovery account is listed as the recovery account on the account to recover.
authority new_owner_authority
known by the account to recover and will be confirmed in a recover_account_operation
const signature_type & sign(const private_key_type &key, const chain_id_type &chain_id)
Definition: transaction.cpp:51
std::set< public_key_type > minimize_required_signatures(const chain_id_type &chain_id, const flat_set< public_key_type > &available_keys, const authority_getter &get_active, const authority_getter &get_owner, const authority_getter &get_posting, uint32_t max_recursion=SCORUM_MAX_SIG_CHECK_DEPTH) const
std::vector< signature_type > signatures
Definition: transaction.hpp:83
transaction_id_type id() const
Definition: transaction.cpp:43
std::vector< operation > operations
Definition: transaction.hpp:18
void get_required_authorities(flat_set< account_name_type > &active, flat_set< account_name_type > &owner, flat_set< account_name_type > &posting, std::vector< authority > &other) const
Definition: transaction.cpp:79
void set_reference_block(const block_id_type &reference_block)
Definition: transaction.cpp:73
void set_expiration(fc::time_point_sec expiration_time)
Definition: transaction.cpp:68
Transfers SCR from one account to another.
account_name_type to
Account to transfer asset to.
asset amount
The amount of asset to transfer from from to to.
account_name_type to
if null, then same as from
Updates advertising budget metadata.
This operation updates game markets list.
uuid_type uuid
Universal Unique Identifier which is specified during game creation.
account_name_type moderator
moderator account name
std::vector< market_type > markets
list of markets
This operation update game round results.
This operation updates game start time.
account_name_type moderator
moderator account name
uuid_type uuid
Universal Unique Identifier which is specified during game creation.
This operation update NFT metadata.
flat_map< std::string, operation > & name2op
Definition: wallet.cpp:92
op_prototype_visitor(int _t, flat_map< std::string, operation > &_prototype_ops)
Definition: wallet.cpp:94
void operator()(const Type &op) const
Definition: wallet.cpp:100
static optional< memo_data > from_string(const std::string &str)
Definition: wallet.hpp:31
public_key_type from
Definition: wallet.hpp:49
std::vector< char > encrypted
Definition: wallet.hpp:53
public_key_type to
Definition: wallet.hpp:50
std::map< public_key_type, std::string > keys
Definition: wallet.hpp:2317
chain_id_type chain_id
Definition: wallet.hpp:71