24 #include <boost/range/algorithm_ext/erase.hpp>
25 #include <boost/range/algorithm/unique.hpp>
26 #include <boost/range/algorithm/sort.hpp>
36 namespace graphene {
namespace wallet {
namespace detail {
39 public_key_type active,
string registrar_account,
string referrer_account,
40 uint32_t referrer_percent,
bool broadcast )
56 account_id_type registrar_account_id = registrar_account_object.
get_id();
60 account_create_op.
referrer = referrer_account_object.
id;
63 account_create_op.
registrar = registrar_account_id;
64 account_create_op.
name = name;
76 (referrer_account)(referrer_percent)(broadcast) ) }
97 string registrar_account,
98 string referrer_account,
107 referrer_account, broadcast, save_wallet);
128 op.
payer = account_id;
143 bool import_keys =
false;
146 for (
const std::string& wif_key : it->second) {
151 elog(
"account ${name} registered by someone else first!",
152 (
"name", account.
name) );
172 void wallet_api_impl::claim_registered_witness(
const std::string& witness_name)
176 std::string wif_key = iter->second;
183 _keys[pub_key] = wif_key;
189 auto account_id = std::string(
id);
191 auto rec =
_remote_db->get_accounts({account_id}, {}).front();
198 FC_ASSERT( account_name_or_id.size() > 0 );
200 if(
auto id = maybe_id<account_id_type>(account_name_or_id) )
205 auto rec =
_remote_db->lookup_account_names({account_name_or_id}).front();
206 FC_ASSERT( rec && rec->name == account_name_or_id );
217 string account_name,
string registrar_account,
string referrer_account,
bool broadcast,
220 int active_key_index = find_first_unused_derived_key_index(owner_privkey);
223 int memo_key_index = find_first_unused_derived_key_index(active_privkey);
236 account_id_type registrar_account_id = registrar_account_object.
get_id();
239 account_create_op.
referrer = referrer_account_object.
id;
242 account_create_op.
registrar = registrar_account_id;
243 account_create_op.
name = account_name;
286 std::vector<vesting_balance_object_with_info> result;
291 result.emplace_back(
get_object(*vbid), now );
295 vector< vesting_balance_object > vbos =
_remote_db->get_vesting_balances( account_name );
296 if( vbos.size() == 0 )
300 result.emplace_back( vbo, now );
307 const vector<string>& wif_keys,
bool broadcast )
312 uint32_t max_ops_per_tx = 30;
314 map< address, private_key_type > keys;
315 vector< address > addrs;
316 bool has_wildcard =
false;
317 addrs.reserve( wif_keys.size() );
318 for(
const string& wif_key : wif_keys )
326 addrs.push_back(
address(pub) );
327 auto it =
_keys.find( pub );
328 if( it !=
_keys.end() )
332 keys[ addrs.back() ] = *privkey;
336 wlog(
"Somehow _keys has no private key for extra_keys public key ${k}", (
"k", pub) );
343 optional< private_key_type > key =
wif_to_key( wif_key );
344 FC_ASSERT( key.valid(),
"Invalid private key" );
346 addrs.push_back(
address(pk) );
347 keys[addrs.back()] = *key;
350 keys[addrs.back()] = *key;
352 keys[addrs.back()] = *key;
354 keys[addrs.back()] = *key;
356 keys[addrs.back()] = *key;
360 vector< balance_object > balances =
_remote_db->get_balance_objects( addrs );
363 set<asset_id_type> bal_types;
364 for(
auto b : balances ) bal_types.insert( b.balance.asset_id );
368 vector< balance_claim_operation > ops;
369 set< address > addrs;
371 vector< claim_tx > claim_txs;
373 for(
const asset_id_type& a : bal_types )
379 if( b.balance.asset_id == a )
386 if( (claim_txs.empty()) || (claim_txs.back().ops.size() >= max_ops_per_tx) )
387 claim_txs.emplace_back();
388 claim_txs.back().ops.push_back(op);
389 claim_txs.back().addrs.insert(b.owner);
394 vector< signed_transaction > result;
396 for(
const claim_tx& ctx : claim_txs )
405 for(
const address& addr : ctx.addrs )
409 boost::erase(signed_tx.
signatures, boost::unique<boost::return_found_end>(boost::sort(signed_tx.
signatures)));
410 result.push_back( signed_tx );