bitshares基本概念详解【帐户】

in #bitshares6 years ago (edited)

刚接触bitshares(或steem)时,对普通帐户、终身会员、注册人、引荐人、见证人、董事会这几个身份一直有些不清楚,现在也碰到一些新接触的人问到这些问题,我试图先从概念来说明这些名词,并穿插实际代码来精确解释,对代码不感兴趣的只看概念就好!

1. 普通帐户

bitshares链上必须注册帐户,帐户名只能是a-z、-、0-9这些字符组成,第一个字符必须是a-z,最后一个字符必须是a-z或0-9,帐户名不能超过64字符。

普通帐户又分为两种,一种是basic,一种是premium,可以理解为基本帐户和尊贵帐户?

  • basic account

帐户名中必须有0-9的数字或者"-",不能是全英文字符。如barnard18

  • premium account

帐户名为全英文字符。如barnard

一般的“水龙头”注册不了全英文的帐户名,bitshares官网的也注册不了,因为注册时代码做了限制。如下:

        if !is_cheap_name(account_name)
            @logger.warn("---- Attempt to register premium name: '#{account_name}'")
            return {error: {'message' => 'Premium names registration is not supported by this faucet'}}
        end

要注册这种帐户可以直接调用注册帐号接口。

注册费用

每个帐户注册都有费用,这个费用注册人(什么是注册人往下看)出,那为什么我们在bitshares注册时没有交费也没有注册人呢?实际上注册人也是存在的,只是第一次注册时感觉不到而已(参见水龙头相关文章),一旦注册了一个帐户继续使用同一浏览器注册帐号时就可以看到注册人这个选项了。

全英文帐户名注册费用是多少?来看看代码

share_type account_create_operation::calculate_fee( const fee_parameters_type& k )const
{
   auto core_fee_required = k.basic_fee;

   if( !is_cheap_name(name) )
      core_fee_required = k.premium_fee;

   // Authorities and vote lists can be arbitrarily large, so charge a data fee for big ones
   auto data_fee =  calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); 
   core_fee_required += data_fee;

   return core_fee_required;
}

代码中指明一个basic_fee,一个premium_fee,用get_object 2.0.0看下 account_create_operation 的费用:

            5,{
              "basic_fee": 57891,
              "premium_fee": 2894592,
              "price_per_kbyte": 4052
            }

费用单位都是BTS,因为BTS精度是5,所以注册普通帐号费用约0.6个BTS,premium帐户费用约29BTS。

对精度不了解的参看bitshares研究系列【喂价和资产抵押率】

id

每个帐户除了帐户名外,还有一个id,大部分对象(如帐户、资产等)都使用id,当然也有不使用id的对象(如块、交易等),bitshares中主要是对这个id进行处理。

id格式类似:1.2.x,这个x就是帐户注册时的一个递增值,例如我的其中一个帐号"barnard18"就是"1.2.861586"

更多id说明参见bitshares研究系列【bitshares-ui代码分析之api】

object_id.hpp

帐户id代码中是一个64位整数,按以下方式组织:

      object_id_type( uint8_t s, uint8_t t, uint64_t i )
      {
         assert( i>>48 == 0 );
         FC_ASSERT( i >> 48 == 0, "instance overflow", ("instance",i) );
         number = (uint64_t(s)<<56) | (uint64_t(t)<<48) | i;
      }

2. 终身会员

终身会员当然首先得有帐户(以后讨论的所有身份都需要有帐户),然后花费一笔钱可以升级终身会员。

普通帐户升级终身会员,可以在cli_wallet中直接 upgrade_account,那升级终身会员需要多少费用呢?

            8,{
              "membership_annual_fee": "57312931034482",
              "membership_lifetime_fee": 69470219
            }

这个是 account_upgrade_operation 的费用,现价就是694.70219BTS。

终身会员可以向网络注册用户(成为注册人),也可以推荐用户(成为引荐人),同时终身会员在bitshares中的交易费用很大一部分(80%)会返还给自己。

如果你在bitshares中经常交易,当然是成为终身会员比较合适。

3. 注册人

注册人就是帮新注册帐户交费用的人。

注册人必须是终身会员,登录bitshares钱包后再注册用户就可以选择原登录用户成为注册人,当然也可以自己搭建“水龙头”把自己设置成注册人。

通过注册人注册的用户,在bitshares中的交易费用的很大一部分(80%)会转给注册人。

4. 引荐人

引荐人是推荐新用户注册的人。

引荐人主要是用来激励用户吸引更多的人来注册,简单说就是人拉人。

通过引荐人注册的用户,在bitshares中的交易费用可能有一部分会转给引荐人,有没有这个提成取决于注册人的“水龙头”设置。

referrer_percent: 50
refcode_prefix: F01

这个配置在faucet.yml中,指定了引荐人所得费用比率和引荐人帐户前缀。

帐户数据

我们来看一个普通帐户数据和终身会员帐户数据,这样会有更直观的认识。

普通帐户"barnard18"

get_account barnard18
{
  "id": "1.2.861586",
  "membership_expiration_date": "1970-01-01T00:00:00",
  "registrar": "1.2.450921",
  "referrer": "1.2.450921",
  "lifetime_referrer": "1.2.450921",
  "network_fee_percentage": 2000,
  "lifetime_referrer_fee_percentage": 3000,
  "referrer_rewards_percentage": 7000,
  "name": "barnard18",
  ...
}

见证人"fox"

get_account fox
{
  "id": "1.2.167",
  "membership_expiration_date": "1969-12-31T23:59:59",
  "registrar": "1.2.167",
  "referrer": "1.2.167",
  "lifetime_referrer": "1.2.167",
  "network_fee_percentage": 2000,
  "lifetime_referrer_fee_percentage": 8000,
  "referrer_rewards_percentage": 0,
  "name": "fox",
  ...
}

从以上数据对比我们可以看出,终身会员的 membership_expiration_date 为“1969-12-31T23:59:59”,而普通帐户的会员过期时间是“1970-01-01T00:00:00”。

终身会员的注册人、引荐人都是自己,而普通帐户的推荐人、引荐人是其它帐户。通过“水龙头”注册的用户则注册人帐户由famcet.yml中指定,引荐人帐户和注册人帐户相同。

account_object.hpp

帐户对象的部分数据定义如下:

   class account_object : public graphene::db::abstract_object<account_object>
   {
      public:
         static const uint8_t space_id = protocol_ids;
         static const uint8_t type_id  = account_object_type;

         /**
          * The time at which this account's membership expires.
          * If set to any time in the past, the account is a basic account.
          * If set to time_point_sec::maximum(), the account is a lifetime member.
          * If set to any time not in the past less than time_point_sec::maximum(), the account is an annual member.
          *
          * See @ref is_lifetime_member, @ref is_basic_account, @ref is_annual_member, and @ref is_member
          */
         time_point_sec membership_expiration_date;

         ///The account that paid the fee to register this account. Receives a percentage of referral rewards.
         account_id_type registrar;
         /// The account credited as referring this account. Receives a percentage of referral rewards.
         account_id_type referrer;
         /// The lifetime member at the top of the referral tree. Receives a percentage of referral rewards.
         account_id_type lifetime_referrer;

         /// Percentage of fee which should go to network.
         uint16_t network_fee_percentage = GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE;
         /// Percentage of fee which should go to lifetime referrer.
         uint16_t lifetime_referrer_fee_percentage = 0;
         /// Percentage of referral rewards (leftover fee after paying network and lifetime referrer) which should go
         /// to referrer. The remainder of referral rewards goes to the registrar.
         uint16_t referrer_rewards_percentage = 0;

         /// The account's name. This name must be unique among all account names on the graph. May not be empty.
         string name;
         ...
      }

帐户这块相对比较简单一点,也比较容易说明和理解,见证人、董事会那块相对比较复杂,牵涉到的内容比较多,如提议、投票、打包等,有些地方自己也没弄明白,等后期再花点时间单独来整理成文。


感谢您阅读 @chaimyu 的帖子,期待您能留言交流!

Sort:  

你好cn区点赞机器人 @cnbuddy 谢谢你对cn区的贡献。倘若你想让我隐形,请回复“取消”。

請問 升級成終身帳戶 要怎麼使用推薦功能呢 ><?
我是技術小白

应该与注册服务配套使用,注册服务有对推荐人的判断,感觉它这一套使用起来并不方便

Coin Marketplace

STEEM 0.31
TRX 0.11
JST 0.034
BTC 66765.98
ETH 3234.00
USDT 1.00
SBD 4.23