31 namespace graphene {
namespace wallet {
namespace detail {
33 template<
typename WorkerInit>
34 static WorkerInit _create_worker_initializer(
const variant& worker_settings )
50 flat_set< worker_id_type > merged;
52 for(
const worker_id_type& wid : delta.
vote_for )
54 bool inserted = merged.insert( wid ).second;
55 FC_ASSERT( inserted,
"worker ${wid} specified multiple times", (
"wid", wid) );
59 bool inserted = merged.insert( wid ).second;
60 FC_ASSERT( inserted,
"worker ${wid} specified multiple times", (
"wid", wid) );
64 bool inserted = merged.insert( wid ).second;
65 FC_ASSERT( inserted,
"worker ${wid} specified multiple times", (
"wid", wid) );
71 vector< object_id_type > query_ids;
72 for(
const worker_id_type& wid : merged )
78 for(
const variant& obj : objects )
81 worker_id_type wo_id { wo.
id };
95 update_op.new_options = acct.
options;
96 update_op.new_options->
votes = new_votes;
112 committee_member_create_op.
url = url;
113 if (
_remote_db->get_committee_member_by_account(owner_account))
114 FC_THROW(
"Account ${owner_account} is already a committee_member", (
"owner_account", owner_account));
117 tx.
operations.push_back( committee_member_create_op );
131 std::vector<witness_id_type> ids_to_get;
132 ids_to_get.push_back(*witness_id);
133 std::vector<fc::optional<witness_object>> witness_objects =
_remote_db->get_witnesses(ids_to_get);
134 if (witness_objects.front())
135 return *witness_objects.front();
136 FC_THROW(
"No witness is registered for id ${id}", (
"id", owner_account));
143 auto owner_account_id = std::string(
get_account_id(owner_account));
148 FC_THROW(
"No witness is registered for account ${account}", (
"account", owner_account));
152 FC_THROW(
"No account or witness named ${account}", (
"account", owner_account));
164 maybe_id<committee_member_id_type>(owner_account);
165 if (committee_member_id)
167 std::vector<committee_member_id_type> ids_to_get;
168 ids_to_get.push_back(*committee_member_id);
169 std::vector<fc::optional<committee_member_object>> committee_member_objects =
170 _remote_db->get_committee_members(ids_to_get);
171 if (committee_member_objects.front())
172 return *committee_member_objects.front();
173 FC_THROW(
"No committee_member is registered for id ${id}", (
"id", owner_account));
181 _remote_db->get_committee_member_by_account(owner_account);
182 if (committee_member)
183 return *committee_member;
185 FC_THROW(
"No committee_member is registered for account ${account}", (
"account", owner_account));
189 FC_THROW(
"No account or committee_member named ${account}", (
"account", owner_account));
197 string url,
bool broadcast )
201 int witness_key_index = find_first_unused_derived_key_index(active_private_key);
209 witness_create_op.
url = url;
212 FC_THROW(
"Account ${owner_account} is already a witness", (
"owner_account", owner_account));
225 string block_signing_key,
bool broadcast )
234 witness_update_op.
new_url = url;
235 if( block_signing_key !=
"" )
247 time_point_sec work_end_date,
share_type daily_pay,
string name,
string url,
248 variant worker_settings,
bool broadcast)
251 std::string wtype = worker_settings[
"type"].
get_string();
254 if( wtype ==
"burn" )
255 init = _create_worker_initializer< burn_worker_initializer >( worker_settings );
256 else if( wtype ==
"refund" )
257 init = _create_worker_initializer< refund_worker_initializer >( worker_settings );
258 else if( wtype ==
"vesting" )
259 init = _create_worker_initializer< vesting_balance_worker_initializer >( worker_settings );
262 FC_ASSERT(
false,
"unknown worker[\"type\"] value" );
283 string committee_member,
bool approve,
bool broadcast )
287 _remote_db->get_committee_member_by_account(committee_member);
288 if (!committee_member_obj)
289 FC_THROW(
"Account ${committee_member} is not registered as a committee_member",
290 (
"committee_member", committee_member));
293 auto insert_result = voting_account_object.
options.
votes.insert(committee_member_obj->
vote_id);
294 if (!insert_result.second)
295 FC_THROW(
"Account ${account} was already voting for committee_member ${committee_member}",
296 (
"account", voting_account)(
"committee_member", committee_member));
300 auto votes_removed = voting_account_object.
options.
votes.erase(committee_member_obj->
vote_id);
301 if( 0 == votes_removed )
302 FC_THROW(
"Account ${account} is already not voting for committee_member ${committee_member}",
303 (
"account", voting_account)(
"committee_member", committee_member));
306 account_update_op.
account = voting_account_object.
id;
318 bool approve,
bool broadcast )
324 FC_THROW(
"Account ${witness} is not registered as a witness", (
"witness", witness));
328 if (!insert_result.second)
329 FC_THROW(
"Account ${account} was already voting for witness ${witness}",
330 (
"account", voting_account)(
"witness", witness));
335 if( 0 == votes_removed )
336 FC_THROW(
"Account ${account} is already not voting for witness ${witness}",
337 (
"account", voting_account)(
"witness", witness));
340 account_update_op.
account = voting_account_object.
id;
357 account_id_type new_voting_account_id =
get_account_id(*voting_account);
359 FC_THROW(
"Voting proxy for ${account} is already set to ${voter}",
360 (
"account", account_to_modify)(
"voter", *voting_account));
366 FC_THROW(
"Account ${account} is already voting for itself", (
"account", account_to_modify));
371 account_update_op.
account = account_object_to_modify.
id;
383 string account_to_modify, uint16_t desired_number_of_witnesses, uint16_t desired_number_of_committee_members,
390 FC_THROW(
"Account ${account} is already voting for ${witnesses} witnesses" 391 " and ${committee_members} committee_members",
392 (
"account", account_to_modify)(
"witnesses", desired_number_of_witnesses)
393 (
"committee_members",desired_number_of_witnesses));
398 account_update_op.
account = account_object_to_modify.
id;
408 (desired_number_of_committee_members)(broadcast) ) }
411 fc::time_point_sec expiration_time,
const variant_object& changed_values,
bool broadcast )
413 FC_ASSERT( !changed_values.contains(
"current_fees") );
431 current_params.get_current_fees().set_fee( prop_op.
proposed_ops.back().op );
442 fc::time_point_sec expiration_time,
const variant_object& changed_fees,
bool broadcast )
447 flat_map< int, fee_parameters > fee_map;
448 fee_map.reserve( current_fees.
parameters.size() );
450 fee_map[ op_fee.which() ] = op_fee;
451 uint32_t scale = current_fees.
scale;
453 for(
const auto& item : changed_fees )
455 const string& key = item.key();
458 int64_t _scale = item.value().as_int64();
460 FC_ASSERT( _scale <= std::numeric_limits<uint32_t>::max() );
461 scale = uint32_t( _scale );
465 auto is_numeric = [&key]() ->
bool 467 size_t n = key.size();
468 for(
size_t i=0; i<n; i++ )
470 if( 0 == isdigit( key[i] ) )
478 which = std::stoi( key );
482 auto it = n2w.find( key );
483 FC_ASSERT( it != n2w.end(),
"unknown operation" );
488 fee_map[ which ] = fp;
493 for(
const std::pair< int, fee_parameters >& item : fee_map )
495 new_fees.
scale = scale;
flat_set< worker_id_type > vote_for
Create a committee_member object, as a bid to hold a committee_member seat on the network...
signed_transaction update_witness(string witness_name, string url, string block_signing_key, bool broadcast)
chain_parameters parameters
witness_id_type witness
The witness object to update.
signed_transaction propose_parameter_change(const string &proposing_account, fc::time_point_sec expiration_time, const variant_object &changed_values, bool broadcast=false)
void set_operation_fees(signed_transaction &tx, const fee_schedule &s) const
vector< operation > operations
public_key get_public_key() const
time_point_sec work_begin_date
#define GRAPHENE_MAX_NESTED_OBJECTS
contains all of the parameters necessary to calculate the fee for any operation
const fee_schedule & get_current_fees() const
This class represents an account on the object graphAccounts are the primary unit of authority on the...
account_id_type witness_account
signed_transaction set_voting_proxy(string account_to_modify, optional< string > voting_account, bool broadcast)
Create a witness object, as a bid to hold a witness position on the network.Accounts which wish to be...
Update an existing account.
#define GRAPHENE_PROXY_TO_SELF_ACCOUNT
Represents the canonical account for specifying you will vote directly (as opposed to a proxy) ...
Used to generate a useful error report when an exception is thrown.At each level in the stack where t...
std::vector< variant > variants
signed_transaction create_committee_member(string owner_account, string url, bool broadcast)
time_point_sec work_end_date
transform_to_fee_parameters< operation >::type fee_parameters
optional< account_options > new_options
New account options.
uint32_t committee_proposal_review_period
minimum time in seconds that a proposed transaction requiring committee authority may not be signed...
signed_transaction create_worker(string owner_account, time_point_sec work_begin_date, time_point_sec work_end_date, share_type daily_pay, string name, string url, variant worker_settings, bool broadcast)
map< string, string > pending_witness_registrations
account_id_type voting_account
fc::ecc::private_key get_private_key_for_account(const account_object &account) const
optional< public_key_type > new_signing_key
The new block signing key.
The proposal_create_operation creates a transaction proposal, for use in multi-sig scenariosCreates a...
provides stack-based nullable value similar to boost::optional
std::string key_to_wif(const fc::sha256 &private_secret)
static_variant_map _operation_which_map
flat_set< worker_id_type > vote_abstain
account_id_type committee_member_account
The account which owns the committee_member. This account pays the fee for this operation.
fc::ecc::private_key derive_private_key(const std::string &prefix_string, int sequence_number)
time_point_sec expiration_time
chain_parameters new_parameters
fc::api< database_api > _remote_db
account_id_type get_account_id(string account_name_or_id) const
optional< string > new_url
The new URL.
flat_set< vote_id_type > votes
defines visit functions for T Unless this is specialized, visit() will not be defined for T...
signed_transaction sign_transaction(signed_transaction tx, bool broadcast=false)
global_property_object get_global_properties() const
signed_transaction propose_fee_change(const string &proposing_account, fc::time_point_sec expiration_time, const variant_object &changed_fees, bool broadcast=false)
flat_set< worker_id_type > vote_against
Update a witness object's URL and block signing key.
#define FC_CAPTURE_AND_RETHROW(...)
worker_initializer initializer
This should be set to the initializer appropriate for the type of worker to be created.
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
optional< uint32_t > review_period_seconds
adds a signature to a transaction
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
vector< op_wrapper > proposed_ops
account_id_type witness_account
The account which owns the witness. This account pays the fee for this operation. ...
signed_transaction update_worker_votes(string account, worker_vote_delta delta, bool broadcast)
public_key_type block_signing_key
witness_object get_witness(string owner_account)
signed_transaction set_desired_witness_and_committee_member_count(string account_to_modify, uint16_t desired_number_of_witnesses, uint16_t desired_number_of_committee_members, bool broadcast)
account_id_type account
The account to update.
signed_transaction vote_for_witness(string voting_account, string witness, bool approve, bool broadcast)
void from_variant(const variant &var, flat_set< T, A... > &vo, uint32_t _max_depth)
flat_map< string, int > name_to_which
vote_id_type vote_against
Voting ID which represents disapproval of this worker.
virtual void validate() const
Worker object contains the details of a blockchain worker. See The Blockchain Worker System for detai...
vote_id_type vote_for
Voting ID which represents approval of this worker.
const std::string & get_string() const
account_id_type witness_account
The account which owns the witness. This account pays the fee for this operation. ...
committee_member_object get_committee_member(string owner_account)
asset set_fee(operation &op, const price &core_exchange_rate=price::unit_price()) const
Used by committee_members to update the global parameters of the blockchain.This operation allows the...
an elliptic curve private key.
signed_transaction vote_for_committee_member(string voting_account, string committee_member, bool approve, bool broadcast)
account_object get_account(account_id_type id) const
account_id_type fee_paying_account
tracks information about a committee_member account.A committee_member is responsible for setting blo...
fee_schedule & get_mutable_fees()
signed_transaction create_witness(string owner_account, string url, bool broadcast)
uint32_t scale
fee * scale / GRAPHENE_100_PERCENT
Create a new worker object.
fee_parameters::flat_set_type parameters