Skip to content

Instantly share code, notes, and snippets.

@vladiuz1
Created March 31, 2018 21:04
Show Gist options
  • Save vladiuz1/68237b25f2811753e5b8b7030dc0da9e to your computer and use it in GitHub Desktop.
Save vladiuz1/68237b25f2811753e5b8b7030dc0da9e to your computer and use it in GitHub Desktop.
new account here we go
class account_object : public graphene::db::abstract_object<account_object>
{
public:
account_object(); ///< constructs empty / null address
explicit account_object( const std::string& base58str ); ///< converts to binary, validates checksum
account_object( const fc::ecc::public_key& pub ); ///< converts to binary
explicit account_object( const fc::ecc::public_key_data& pub ); ///< converts to binary
account_object( const pts_address& pub ); ///< converts to binary
account_object( const public_key_type& pubkey );
static bool is_valid( const std::string& base58str, const std::string& prefix = GRAPHENE_ADDRESS_PREFIX );
explicit operator std::string()const; ///< converts to base58 + checksum
friend size_t hash_value( const address& v ) {
const void* tmp = static_cast<const void*>(v.addr._hash+2);
const size_t* tmp2 = reinterpret_cast<const size_t*>(tmp);
return *tmp2;
}
fc::ripemd160 addr;
static const uint8_t space_id = protocol_ids;
static const uint8_t type_id = account_object_type;
/// The account's name. This name must be unique among all account names on the graph. May not be empty.
string name;
/**
* The owner authority represents absolute control over the account. Usually the keys in this authority will
* be kept in cold storage, as they should not be needed very often and compromise of these keys constitutes
* complete and irrevocable loss of the account. Generally the only time the owner authority is required is to
* update the active authority.
*/
authority owner;
typedef account_options options_type;
account_options options;
struct contract_options
{
vector<char> code;
string asset_symbol;
asset_id_type asset;
/// See @ref contract_options_flags
uint16_t flags;
};
optional<contract_options> contract_opts;
/// The reference implementation records the account's statistics in a separate object. This field contains the
/// ID of that object.
account_statistics_id_type statistics;
/**
* Vesting balance which receives cashback_reward deposits.
*/
optional<vesting_balance_id_type> cashback_vb;
/**
* Need to learn this in more detail:
*/
special_authority owner_special_authority = no_special_authority();
/**
* This flag is set when the top_n logic sets both authorities,
* and gets reset when authority or special_authority is set.
*/
uint8_t top_n_control_flags = 0;
static const uint8_t top_n_control_owner = 1;
/**
* This is a set of assets which the account is allowed to have.
* This is utilized to restrict buyback accounts to the assets that trade in their markets.
* In the future we may expand this to allow accounts to e.g. voluntarily restrict incoming transfers.
*/
optional< flat_set<asset_id_type> > allowed_assets;
bool has_special_authority()const
{
return (owner_special_authority.which() != special_authority::tag< no_special_authority >::value);
}
template<typename DB>
const vesting_balance_object& cashback_balance(const DB& db)const
{
FC_ASSERT(cashback_vb);
return db.get(*cashback_vb);
}
account_id_type get_id()const { return id; }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment