[WITNESS server - part III] Wallet and Price Feed

in #witness5 years ago

In this last part of a series of 3 posts about setting up a Witness server on HIVE blockchain we will see how to setup the wallet, install a tool to manage the price feed and make the witness announcement.

If you missed:
[WITNESS server - part I] - Setup & Tuning Ubuntu 18.04
[WITNESS server - part II] - HIVE - The manual way

Wallet and Price Feed

For the wallet we will use a new screen session. If you are in the steemd screen session use CTRL+A+D to detach and then use the command:

witness@witness:~$ screen -S wallet

Setup the Wallet

After the replay of the blockchain you can use your server (my case) otherwise if you don't want to wait you have to use another one.

Use the command below to start the interactive process.

witness@witness:~$ ~/bin/cli_wallet -s ws://localhost:8090

Process start

Logging RPC to file: logs/rpc/rpc.log
Starting a new wallet
1071832ms main.cpp:169                 main                ] wdata.ws_server: ws://localhost:8090 
Please use the set_password method to initialize a new wallet before continuing
new >>>
I/ PASSWORD

You will first be asked to create a password with the command set_password.

new >>> set_password "my secure password"

Which will lock the wallet.

set_password "my secure password"
null
locked >>>
II/ ACTIVE PRIVATE KEY

Unlock the wallet and import your ACTIVE PRIVATE KEY (you can retrieve it from https://wallet.hive.blog/@your_username/permissions)

locked >>> unlock "my secure password"
unlock "my secure password"
null
unlocked >>> 

Replace XXXXXXXXXXXXX... with your ACTIVE PRIVATE KEY

unlocked >>> import_key XXXXXXXXXXXXX...
import_key XXXXXXXXXXXXX...
3444354ms wallet.cpp:427                save_wallet_file     ] saving wallet to file wallet.json
true
unlocked >>>
III/ PRIVATE KEY

Use the command suggest_brain_key to create a public and a private key for your witness (keep this information in a safe place)

unlocked >>> suggest_brain_key
{
  "brain_priv_key": "LOREM IPSUM DOLOR SIT AMET AT MEA PRIMA IISQUE EUM UT",
  "wif_priv_key": "YYYYYYYYYYYYY...",
  "pub_key": "STMZZZZZZZZZZ..."
}
IV/ UPDATE

Update the ~/.steemd/config.ini file with the wif_priv_key value and HIVE username. First detach from the screen wallet (CTRL+A+D) and re-attach the screen steemd

witness@witness:~$ screen -r steemd

Stop the steemd process (CTRL+C) and edit the ~/.steemd/config.ini file

witness@witness:~$ vim ~/.steemd/config.ini

Set the witness property with the HIVE username

# name of witness controlled by this node (e.g. initwitness )
witness = "HIVE username"

Set the private-key property with the wif_priv_key

# WIF PRIVATE KEY to be used by one or more witnesses or miners
private-key = YYYYYYYYYYYYY...

Save the ~/.steemd/config.ini file and restart the steemd process (without the replay option)

witness@witness:~$ ~/bin/steemd

Announcement of your witness

It's time to make the annoucement of your HIVE witness. It's preferable to have published a post presenting your witness to use it link in the annoucement.

First detach from the screen steemd (CTRL+A+D) and re-attach the screen wallet. Then prepare everything needed for the annoucement.

  • HIVE username
  • link to your witness post
  • STMZZZZZZZZZZ (pub_key generated by the previous usage of suggest_brain_key)
  • account_creation_fee price for creating a new account (currently = 3.000 HIVE)
  • maximum_block_size The maximum size of a single block in bytes (currently = 65536)
  • sbd_interest_rate This property defines the interest rate that SBD deposits receive.

Note: Maximum block size is decided by the set of active witnesses which change every round. Each witness posts what they think the maximum size should be as part of their witness properties, the median size is chosen to be the maximum block size for the round.

To do this, we will use the update_witness command

unlocked >>> update_witness "HIVE username" "link to your witness post" "STMZZZZZZZZZZ" {"account_creation_fee":"3.000 HIVE","maximum_block_size":65536,"sbd_interest_rate":0} true

if all goes well, you'll see an answer like this and you will be able to check on https://hiveblocks.com/ with the transaction_id that everything is OK

{
  "ref_block_num": 60556,
  "ref_block_prefix": 2958805662,
  "expiration": "2020-04-28T00:44:51",
  "operations": [[
      "witness_update",{
        "owner": "mintrawa",
        "url": "https://peakd.com/@mintrawa",
        "block_signing_key": ...,
        "props": {
      ...
        },
        "fee": "0.000 HIVE"
      }
    ]
  ],
  "extensions": [],
  "signatures": [
   ...
  ],
  "transaction_id": ...,
  "block_num": ...,
  "transaction_num": 4
}

Price Feed

First detach from the screen wallet (CTRL+A+D)

For the price feed we will use steemfeed-js (works for Steem and Hive) from @someguy123

But you can use another one such as pricefeed from @yabapmatt or steemprice-feed from @coingecko (in this case edit the variables.ts with Hive rpc)

clone the repository in the home directory (nodejs & pm2 required for my case of use)

witness@witness:~/.steemd/blockchain$ cd
witness@witness:~$ git clone https://github.com/Someguy123/steemfeed-js.git

copy the config.example.json file to config.json and edit

witness@witness:~$ cd steemfeed-js
witness@witness:~/steemfeed-js$ cp config.example.json config.json
witness@witness:~/steemfeed-js$ vim config.json

Replace the default values with your value
For the wif use your Private active Key

{
    "name": "HIVE username",
    "wif": "XXXXXXXXXXXXX...",
    "network": "hive",
    "interval": 60,
    "peg": false,
    "peg_multi": 1
}

Create the ecosystem.config.js file (for pm2)

witness@witness:~/steemfeed-js$ vim ecosystem.config.js

And insert the content below

module.exports = {
  apps : [
    {
      name: 'SteemFeed',
      script: './app.js',
      args: 'publishnow',
      instances: 1,
      autorestart: true,
      watch: false,
      max_memory_restart: '1G'
    },                                    
  ],
};

Install

witness@witness:~/steemfeed-js$ npm install

Run pm2 and save

witness@witness:~/steemfeed-js$ pm2 start ecosystem.config.js
witness@witness:~/steemfeed-js$ pm2 save

Your HIVE Witness Server is now ALIVE!

... THE END ...


Disable your witness server

For maintenance or definitively you can disable your witness server by sending the following command from your wallet

unlocked>> update_witness "HIVE username" "link to your witness post" "STM1111111111111111111111111111111114T1Anm" {"account_creation_fee":"3.000 HIVE","maximum_block_size":65536,"sbd_interest_rate":0} true

Mintrawa app logo


If you liked Upvote, Follow, Reblog or Cross post are welcome - @mintrawa

Sort:  

@mintrawa, thank you for supporting the HiveBuzz project by voting for @steemitboard as a witness.

Here is a small present to show our gratitude
Click on the badge to view your Board of Honor.

Once again, thanks for your support!

Do not miss the last post from @hivebuzz:

HiveBuzz - Hive Gamification Experience