steem研究系列【mac下编译安装steem】

in #steem7 years ago (edited)

自己早已习惯于在steemit上面发文章,也习惯于和steemit上认识的朋友交流,而且前期投入过一万RMB买了STEEM(今天来看也算是翻倍了,什么时候价格能到15元再买点),怎么也该更深入的研究一下它!

安装

下载steem源代码

按照build.md进行mac下编译,官方是建议用docker进行安装上布署,不过bitshares我都各种设置编译过了,steem基于同样的graphene,应该难度不会太大吧!

由于我机器上xcode、brew等都已安装正常,如果你没有请查看官方文档或按以下:

sudo xcodebuild -license accept

安装Homebrew方法,[https://brew.sh/](https://brew.sh/)

初始化:
brew doctor
brew update

安装依赖库:

brew install \
    autoconf \
    automake \
    cmake \
    git \
    boost160 \
    libtool \
    openssl \
    snappy \
    zlib \
    python3
    
pip3 install --user jinja2

编译:

export OPENSSL_ROOT_DIR=$(brew --prefix)/Cellar/openssl/1.0.2h_1/
export BOOST_ROOT=$(brew --prefix)/Cellar/boost@1.60/1.60.0/
export SNAPPY_LIBRARIES=$(brew --prefix)/Cellar/snappy/1.1.7_1/lib/
export SNAPPY_INCLUDE_DIR=$(brew --prefix)/Cellar/snappy/1.1.7_1/include/
export ZLIB_LIBRARIES=$(brew --prefix)/Cellar/zlib/1.2.11/lib/
git checkout stable
git submodule update --init --recursive
mkdir build && cd build
cmake -DBOOST_ROOT="$BOOST_ROOT" -DCMAKE_BUILD_TYPE=Release ..
make -j$(sysctl -n hw.logicalcpu)

但是make时会出错:

[ 22%] Building CXX object libraries/fc/CMakeFiles/fc.dir/src/crypto/_digest_common.cpp.o
[ 22%] Building CXX object libraries/fc/CMakeFiles/fc.dir/src/crypto/openssl.cpp.o
In file included from /Users/Chaim/Documents/workspace/steem/libraries/fc/src/crypto/openssl.cpp:1:
/Users/Chaim/Documents/workspace/steem/libraries/fc/include/fc/crypto/openssl.hpp:2:10: fatal error: 'openssl/ec.h' file not found
#include <openssl/ec.h>
         ^~~~~~~~~~~~~~
1 error generated.
make[2]: *** [libraries/fc/CMakeFiles/fc.dir/src/crypto/openssl.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [libraries/fc/CMakeFiles/fc.dir/all] Error 2
make: *** [all] Error 2

openssl出现问题,重新安装一下openssl看看:

(env3) Chaim:build Chaim$ brew reinstall openssl
==> Reinstalling openssl 
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2o_1.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2o_1.high_sierra.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include
For pkg-config to find this software you may need to set:
    PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig

==> Summary
🍺  /usr/local/Cellar/openssl/1.0.2o_1: 1,791 files, 12.3MB

发现openssl安装的目录是1.0.2o_1,而不是export的目录1.0.2h_1,重新export openssl路径:

(env3) Chaim:build Chaim$ export OPENSSL_ROOT_DIR=$(brew --prefix)/Cellar/openssl/1.0.2o_1/

继续执行make还是出同样错误!

我们看到安装openssl时提示编译时应该加上lib目录和include目录,找到steem目录下CMakeLists.txt,加入以下语句:

include_directories(/usr/local/Cellar/openssl/1.0.2o_1/include)
link_directories("/usr/local/Cellar/openssl/1.0.2o_1/lib")

重新cmake和make,编译成功!

运行

steemd

进入steemd目录,运行steemd,会提示增加配置文件:

(env3) Chaim:witness_node_data_dir Chaim$ pwd
/Users/Chaim/Documents/workspace/steem/build/programs/steemd/witness_node_data_dir

(env3) Chaim:steemd Chaim$ ./steemd 
------------------------------------------------------

            STARTING STEEM NETWORK

------------------------------------------------------
initminer public key: STM8GC13uCZbP44HzMLV6zPZGwVQ8Nt4Kji8PapsPiNq1BK153XTX
chain id: 0000000000000000000000000000000000000000000000000000000000000000
blockchain version: 0.19.3
------------------------------------------------------
1329234ms th_a       witness_plugin.cpp:545        plugin_startup       ] No witnesses configured! Please add witness names and private keys to configuration.

这样会在steemd目录下生成 目录,并且里面有config.ini文件,修改增加以下项:

seed-node = 52.38.66.234:2001
seed-node = 52.37.169.52:2001
seed-node = 52.26.78.244:2001
seed-node = 192.99.4.226:2001
seed-node = 46.252.27.1:1337
seed-node = 81.89.101.133:2001
seed-node = 52.4.250.181:39705
seed-node = steemd.pharesim.me:2001
seed-node = seed.steemed.net:2001
seed-node = steem.clawmap.com:2001
seed-node = seed.steemwitness.com:2001
seed-node = steem-seed1.abit-more.com:2001

增加rpc-endpoint

rpc-endpoint = 127.0.0.1:8090

重新回steemd目录,启动steemd,这样就能同步区块了:

(env3) Chaim:steemd Chaim$ ./steemd 
------------------------------------------------------

            STARTING STEEM NETWORK

------------------------------------------------------
initminer public key: STM8GC13uCZbP44HzMLV6zPZGwVQ8Nt4Kji8PapsPiNq1BK153XTX
chain id: 0000000000000000000000000000000000000000000000000000000000000000
blockchain version: 0.19.3
------------------------------------------------------
...
1596270ms th_a       main.cpp:198                  operator()           ] Started witness node on a chain with 0 blocks.
1608102ms th_a       application.cpp:491           handle_block         ] Syncing Blockchain --- Got block: #10000 time: 2016-03-25T00:34:48
1614005ms th_a       application.cpp:491           handle_block         ] Syncing Blockchain --- Got block: #20000 time: 2016-03-25T09:07:51

等待区块同步完成。

cli_wallet

进入cli_wallet目录,运行钱包程序:

Chaim:~ Chaim$ cd Documents/workspace/steem/build/programs/cli_wallet/
Chaim:cli_wallet Chaim$ ./cli_wallet 
Logging RPC to file: logs/rpc/rpc.log
Starting a new wallet
1884799ms th_a       main.cpp:154                  main                 ] wdata.ws_server: ws://localhost:8090 
1886008ms th_a       main.cpp:159                  main                 ] wdata.ws_user:  wdata.ws_password:  
1886008ms th_a       websocket_api.cpp:88          on_message           ] message: {"id":1,"result":true} 
1886009ms th_a       websocket_api.cpp:88          on_message           ] message: {"id":2,"result":0} 
1886010ms th_a       websocket_api.cpp:88          on_message           ] message: {"id":3,"result":3} 
Please use the set_password method to initialize a new wallet before continuing

set_password、unlock后,调用help:

unlocked >>> help
                          variant_object about()
            annotated_signed_transaction cancel_order(string owner, uint32_t orderid, bool broadcast)
            annotated_signed_transaction cancel_transfer_from_savings(string from, uint32_t request_id, bool broadcast)
            annotated_signed_transaction challenge(string challenger, string challenged, bool broadcast)
            annotated_signed_transaction change_recovery_account(string owner, string new_recovery_account, bool broadcast)
            annotated_signed_transaction claim_reward_balance(string account, asset reward_steem, asset reward_sbd, asset reward_vests, bool broadcast)
            annotated_signed_transaction convert_sbd(string from, asset amount, bool broadcast)
            annotated_signed_transaction create_account(string creator, string new_account_name, string json_meta, bool broadcast)
            annotated_signed_transaction create_account_delegated(string creator, asset steem_fee, asset delegated_vests, string new_account_name, string json_meta, bool broadcast)
            annotated_signed_transaction create_account_with_keys(string creator, string newname, string json_meta, public_key_type owner, public_key_type active, public_key_type posting, public_key_type memo, bool broadcast)
            annotated_signed_transaction create_account_with_keys_delegated(string creator, asset steem_fee, asset delegated_vests, string newname, string json_meta, public_key_type owner, public_key_type active, public_key_type posting, public_key_type memo, bool broadcast)
            annotated_signed_transaction create_order(string owner, uint32_t order_id, asset amount_to_sell, asset min_to_receive, bool fill_or_kill, uint32_t expiration, bool broadcast)
            annotated_signed_transaction decline_voting_rights(string account, bool decline, bool broadcast)
                                  string decrypt_memo(string memo)
            annotated_signed_transaction delegate_vesting_shares(string delegator, string delegatee, asset vesting_shares, bool broadcast)
            annotated_signed_transaction escrow_approve(string from, string to, string agent, string who, uint32_t escrow_id, bool approve, bool broadcast)
            annotated_signed_transaction escrow_dispute(string from, string to, string agent, string who, uint32_t escrow_id, bool broadcast)
            annotated_signed_transaction escrow_release(string from, string to, string agent, string who, string receiver, uint32_t escrow_id, asset sbd_amount, asset steem_amount, bool broadcast)
            annotated_signed_transaction escrow_transfer(string from, string to, string agent, uint32_t escrow_id, asset sbd_amount, asset steem_amount, asset fee, time_point_sec ratification_deadline, time_point_sec escrow_expiration, string json_meta, bool broadcast)
            annotated_signed_transaction follow(string follower, string following, set<string> what, bool broadcast)
                         account_api_obj get_account(string account_name)
        map<uint32_t, applied_operation> get_account_history(string account, uint32_t from, uint32_t limit)
               vector<account_name_type> get_active_witnesses()
          optional<signed_block_api_obj> get_block(uint32_t num)
         vector<convert_request_api_obj> get_conversion_requests(string owner)
                                  string get_encrypted_memo(string from, string to, string memo)
                    feed_history_api_obj get_feed_history()
         vector<extended_message_object> get_inbox(string account, fc::time_point newest, uint32_t limit)
               vector<account_name_type> get_miner_queue()
            vector<extended_limit_order> get_open_orders(string accountname)
               vector<applied_operation> get_ops_in_block(uint32_t block_num, bool only_virtual)
                              order_book get_order_book(uint32_t limit)
         vector<extended_message_object> get_outbox(string account, fc::time_point newest, uint32_t limit)
 vector<owner_authority_history_api_obj> get_owner_history(string account)
                                  string get_private_key(public_key_type pubkey)
           pair<public_key_type, string> get_private_key_from_password(string account, string role, string password)
                               operation get_prototype_operation(string operation_type)
                              app::state get_state(string url)
            annotated_signed_transaction get_transaction(transaction_id_type trx_id)
                  vector<withdraw_route> get_withdraw_routes(string account, withdraw_route_type type)
               optional<witness_api_obj> get_witness(string owner_account)
                                  string gethelp(const string & method)
                                  string help()
                                    bool import_key(string wif_key)
                                 variant info()
                                    bool is_locked()
                                    bool is_new()
                             set<string> list_accounts(const string & lowerbound, uint32_t limit)
            map<public_key_type, string> list_keys()
                 vector<account_api_obj> list_my_accounts()
                  set<account_name_type> list_witnesses(const string & lowerbound, uint32_t limit)
                                    bool load_wallet_file(string wallet_filename)
                                    void lock()
                                    void network_add_nodes(const vector<string> & nodes)
                         vector<variant> network_get_connected_peers()
                                  string normalize_brain_key(string s)
            annotated_signed_transaction post_comment(string author, string permlink, string parent_author, string parent_permlink, string title, string body, string json, bool broadcast)
            annotated_signed_transaction prove(string challenged, bool broadcast)
            annotated_signed_transaction publish_feed(string witness, price exchange_rate, bool broadcast)
            annotated_signed_transaction recover_account(string account_to_recover, authority recent_authority, authority new_authority, bool broadcast)
            annotated_signed_transaction request_account_recovery(string recovery_account, string account_to_recover, authority new_authority, bool broadcast)
                                    void save_wallet_file(string wallet_filename)
            annotated_signed_transaction send_private_message(string from, string to, string subject, string body, bool broadcast)
                                  string serialize_transaction(signed_transaction tx)
                                    void set_password(string password)
                                    void set_transaction_expiration(uint32_t seconds)
            annotated_signed_transaction set_voting_proxy(string account_to_modify, string proxy, bool broadcast)
            annotated_signed_transaction set_withdraw_vesting_route(string from, string to, uint16_t percent, bool auto_vest, bool broadcast)
            annotated_signed_transaction sign_transaction(signed_transaction tx, bool broadcast)
                          brain_key_info suggest_brain_key()
            annotated_signed_transaction transfer(string from, string to, asset amount, string memo, bool broadcast)
            annotated_signed_transaction transfer_from_savings(string from, uint32_t request_id, string to, asset amount, string memo, bool broadcast)
            annotated_signed_transaction transfer_to_savings(string from, string to, asset amount, string memo, bool broadcast)
            annotated_signed_transaction transfer_to_vesting(string from, string to, asset amount, bool broadcast)
                                    void unlock(string password)
            annotated_signed_transaction update_account(string accountname, string json_meta, public_key_type owner, public_key_type active, public_key_type posting, public_key_type memo, bool broadcast)
            annotated_signed_transaction update_account_auth_account(string account_name, authority_type type, string auth_account, weight_type weight, bool broadcast)
            annotated_signed_transaction update_account_auth_key(string account_name, authority_type type, public_key_type key, weight_type weight, bool broadcast)
            annotated_signed_transaction update_account_auth_threshold(string account_name, authority_type type, uint32_t threshold, bool broadcast)
            annotated_signed_transaction update_account_memo_key(string account_name, public_key_type key, bool broadcast)
            annotated_signed_transaction update_account_meta(string account_name, string json_meta, bool broadcast)
            annotated_signed_transaction update_witness(string witness_name, string url, public_key_type block_signing_key, const chain_properties & props, bool broadcast)
            annotated_signed_transaction vote(string voter, string author, string permlink, int16_t weight, bool broadcast)
            annotated_signed_transaction vote_for_witness(string account_to_vote_with, string witness_to_vote_for, bool approve, bool broadcast)
            annotated_signed_transaction withdraw_vesting(string from, asset vesting_shares, bool broadcast)

很熟悉的命令操作了,和bitshares一模一样!

更多操作等我先研究下steem开发者的内容...


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

Sort:  

期待更多的steem技术文~

期待你来,你能研究

这方面你是专家

Hi! I am a robot. I just upvoted you! I found similar content that readers might be interested in:
https://steemit.com/guide/@bitcoinparadise/using-the-cliwallet

就知道一放help内容这机器人就会出现...

好多机器人?

cheetah是个机器人,说文章内容有相似的地方

@chaimyu, 码农好棒哇~~~ img

看来互联网的产品早期的使用者都是互联网从业人员

我算早期吗?

我觉得算是。16年steem 才上线

那你也是啦,一起玩

努力追上你的等级