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);
111 flat_map<
string, optional<string>> key_values,
bool broadcast)
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 );
map< string, vector< string > > pending_account_registrations
bool import_key(string account_name_or_id, string wif_key)
account_id_type registrar
This account pays the fee. Must be a lifetime member.
bool upgrade_to_lifetime_member
If true, the account will be upgraded to a lifetime member; otherwise, it will add a year to the subs...
signed_transaction upgrade_account(string name, bool broadcast)
signed_transaction create_account_with_brain_key(string brain_key, string account_name, string registrar_account, string referrer_account, bool broadcast=false, bool save_wallet=true)
Identifies a weighted set of keys and accounts that must approve operations.
void set_operation_fees(signed_transaction &tx, const fee_schedule &s) const
Manage an account's membership statusThis operation is used to upgrade an account to a member...
public_key_type balance_owner_key
void pack(Stream &s, const flat_set< T, A... > &value, uint32_t _max_depth)
signed_transaction create_account_with_private_key(fc::ecc::private_key owner_privkey, string account_name, string registrar_account, string referrer_account, bool broadcast=false, bool save_wallet=true)
uint16_t referrer_percent
vector< operation > operations
public_key get_public_key() const
This class represents an account on the object graphAccounts are the primary unit of authority on the...
Maintains global state information (committee_member list, current fees)This is an implementation det...
signed_transaction whitelist_account(string authorizing_account, string account_to_list, account_whitelist_operation::account_listing new_listing_status, bool broadcast)
fc::optional< fc::ecc::private_key > wif_to_key(const std::string &wif_key)
vector< vesting_balance_object_with_info > get_vesting_balances(string account_name)
account_id_type account_to_upgrade
The account to upgrade; must not already be a lifetime member.
signed_transaction account_store_map(string account, string catalog, bool remove, flat_map< string, optional< string >> key_values, bool broadcast)
map< string, string > pending_witness_registrations
provides a generic way to add higher level protocols on top of witness consensusThere is no validatio...
fc::api< network_broadcast_api > _remote_net_broadcast
provides stack-based nullable value similar to boost::optional
signed_transaction register_account(string name, public_key_type owner, public_key_type active, string registrar_account, string referrer_account, uint32_t referrer_percent, bool broadcast=false)
std::string key_to_wif(const fc::sha256 &private_secret)
Claim a balance in a graphene::chain::balance_object.
account_id_type authorizing_account
The account which is specifying an opinion of another account.
bool is_lifetime_member() const
fc::ecc::private_key derive_private_key(const std::string &prefix_string, int sequence_number)
object_id< SpaceID, TypeID > get_id() const
fc::api< database_api > _remote_db
account_id_type get_account_id(string account_name_or_id) const
contains only the public point of an elliptic curve key.
vector< signed_transaction > import_balance(string name_or_id, const vector< string > &wif_keys, bool broadcast)
account_id_type referrer
This account receives a portion of the fee split between registrar and referrer. Must be a member...
signed_transaction sign_transaction(signed_transaction tx, bool broadcast=false)
#define FC_CAPTURE_AND_RETHROW(...)
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
string name
The account's name. This name must be unique among all account names on the graph. May not be empty.
adds a signature to a transaction
void save_wallet_file(string wallet_filename="")
string normalize_brain_key(string s)
bool is_valid_name(const string &name)
This operation is used to whitelist and blacklist accounts, primarily for transacting in whitelisted ...
vector< flat_set< account_id_type > > get_key_references(const vector< public_key_type > &keys) const
flat_map< string, optional< string > > key_values
graphene::db::object_downcast_t< const ID & > get_object(const ID &id) const
balance_id_type balance_to_claim
virtual void validate() const
map< public_key_type, string > _keys
uint16_t referrer_rewards_percentage
a 160 bit hash of a public key
an elliptic curve private key.
map< account_id_type, set< public_key_type > > extra_keys
account_object get_account(account_id_type id) const
const signature_type & sign(const private_key_type &key, const chain_id_type &chain_id)
#define GRAPHENE_1_PERCENT
account_id_type deposit_to_account
vector< signature_type > signatures
account_id_type account_to_list
The account being opined about.