Giter Site home page Giter Site logo

hivefeed-js's Introduction

Hive Feed JS

This is a Hive Price Feed for witnesses on the HIVE Network. It's written in Node.JS and uses Hive's Hive-JS.

Recommended Node Version: Node 18

Installation

First, download the git repository, then edit config.json as needed. The interval is in minutes.

git clone https://github.com/Someguy123/hivefeed-js.git
cd hivefeed-js
cp config.example.json config.json
nano config.json

I recommend using Docker, however you can also use a locally installed copy of Node v8.11.4 or higher.

Starting Via Docker

# If you don't have docker installed yet, you can easily install it using run.sh
./run.sh install_docker

# (Optional) To save a little time, you can use my binary docker image, instead of having
# to build the container - which takes a few minutes (vs. a few seconds via binary install)
./run.sh install

# Now just start your feed :)
./run.sh start

# Check the logs / status to make sure it's working properly
./run.sh logs       # Check the status with docker logs
./run.sh status     # This will also help you check if it's running or not.

# If you need to force update your feed at any point
./run.sh publish

# Other useful commands:
./run.sh stop       # To stop the hivefeed-js container
./run.sh restart    # To restart the hivefeed-js container (e.g. after config changes)
./run.sh build      # If you don't want to / can't use my binary image, this will force build a new image locally.

Starting Via NodeJS (assuming you have the correct version installed)

npm install
npm start

Full explanation for usage with nodejs: https://peakd.com/witness/@rishi556/how-to-setup-hive-witness-pricefeed-using-hivefeed-js

Easy update with Docker

To update the dockerised version simply do the following:

git pull
./run.sh install
./run.sh restart

Configuration

{
    "name": "your hive name",
    "signing_keys" : {
    "Public Signing Key" : "Private Signing Key"
    },
    "network": "hive",
    "interval": 60,
    "peg": false,
    "peg_multi": 1
}
  • name (REQUIRED) - The name of the hive account that will publish the feed

  • signing_keys (dictionary - alternative/combo to wif) - Witness signing keys as a dictionary {"pubkey": "privkey", ...}, can be used as either an alternative to wif, or in combination as backup keys

  • node (default: https://api.deathwing.me/) - The HTTP(S) URL of the hive node to use, e.g. https://hived.privex.io

  • interval (default: 60) - The number of minutes between publishing the feed

  • network (default: hive) - The network (chain) you're using this for. For using the hive long term testnet, set to testnet. Options are: hive testnet

  • peg (default: false) - Set to true only if you want to adjust your price feed bias

  • peg_multi (default: 1) - If "peg" is set to true, then this will change the "quote" to 1 / peg_multi. If you set "peg_multi" to 2 it will show a 100% bias on your feed.

Advanced Configuration Options

NOTE: The settings ex_symbol, ex_compare, base_symbol and quote_symbol normally do not need to be adjusted.

Just set the correct network, and those settings will be automatically updated to the correct values.

wif - Your private active key if you'd use that instead. You can use this in replacement to signing_keys or alongside it.

ex_symbol - The symbol we're obtaining the price of. Default: hive

ex_compare - The symbol we're pricing ex_symbol with (i.e. the other half of the exchange pair). Default: usd

base_symbol - The symbol used for the "base": "0.512 HBD" part of the feed. Default: HBD

quote_symbol - The symbol used for the "quote": "1.000 HIVE" part of the feed. Default: HIVE

alternate_nodes - Alternate nodes to use if the main provided one is down. Provided as an array of nodes. Default : ["https://api.hive.blog", "https://api.deathwing.me"]

chain_id - Chain id of the chain that you are using. Default: beeab0de00000000000000000000000000000000000000000000000000000000

address_prefix - Address prefix of the chain that you are using. Default: STM

disable_exchanges - A list of exchange code 's to disable. Exchanges listed here will not be used directly (i.e. get price for A/B), nor indirectly (i.e. get price for A/D by converting A/C then C/D).

Example (disable all exchanges...):

{
    "disable_exchanges": ["bittrex", "poloniex", "kraken", "ionomy", "binance"]
}

exchanges_no_provide - Disable use of specific coin pairs per exchange, for example, you might want to temporarily ban the usage of HIVE/BTC from Poloniex.

Example (block HIVE/BTC from poloniex, block BTC/USDT on Kraken):

{
    "exchanges_no_provide": {
        "poloniex": [
            ["hive", "btc"]
        ],
        "kraken": [
            ["btc", "usdt"]
        ]
    },
}

exchanges_provide - Add new coin pairs to exchanges, allowing the user to inform hivefeed-js of new pairs supported by a given exchange.

By default, most exchange adapters have the following pairs enabled (if the exchange supports them):

- BTC/USD
- BTC/USDT
- USDT/USD
- HIVE/BTC
- HIVE/USD (preferred over HIVE/BTC)

Example (add BTC/DASH, EOS/USD, EOS/BTC to bittrex - add EOS/BTC to kraken):

{
    "exchanges_provide": {
        "bittrex": [
            ["btc","dash"],
            ["eos","usd"],
            ["eos","btc"]
        ],
        "kraken": [
            ["eos", "btc"]
        ]
    }
}

hivefeed-js's People

Contributors

jolly-pirate avatar mattyice avatar rishi556 avatar shmoogleosukami avatar someguy123 avatar techcoderx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hivefeed-js's Issues

steemfeed-js crashes when checking with BTC-e

I noticed that my steemfeed-js dockerised instance was crashing. I tried to start it without deamonising it, and I noticed that it checks the price with BTC-e. Since BTC-e is down, I figured this must be the problem. Did some lurking around in the source, disabled BTCEAdapter and now it works correctly!

I made a quickfix post on steemit, but this should be fixed in the repo as well, for future installations.

Thanks!

hivefeed-js unhandled promise rejection error when witness is disabled

Hivefeed-js throws this error if your public key is not the same as one configured in hivefeed-js
In my case my witness is currently disabled so the public key for my witness is not the same as configured in hivefeed-js.

(node:5859) UnhandledPromiseRejectionWarning: ReferenceError: reject is not defined
    at delay.then.catch (/home/shmoogle/hivefeed-js/app.js:258:47)
(node:5859) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:5859) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Seeing as unhandled promises rejections are deprecated we should handle this error gracefully in some way.

Naming

Since this works with hive as well, the name is outdated. What about pricefeed-js?

Failed to Publish feed: HTTP 404 Not Found

I just saw that my feed was out of date, saw an error in the log and so decided to update steemfeed-js in case that was the cause. After updating using the steps listed in the readme, I see this every time I start it:

Failed to publish feed...
reason: HTTP 404: Not Found
Will retry in 60 seconds

Haven't found the cause yet.

hivefeed-js silently crashes when unable to get current signing key

Log at time of error.

[2021-08-11T20:09:15.637Z] Querying Bittrex (hive/btc)
[2021-08-11T20:09:15.637Z] Querying Binance (hive/btc)
[2021-08-11T20:09:15.637Z] Querying Ionomy (hive/btc)
[2021-08-11T20:09:15.637Z] Querying Huobi (hive/btc)
[2021-08-11T20:09:15.637Z] Querying Poloniex (btc/usdt)
[2021-08-11T20:09:15.638Z] Querying Bittrex (btc/usdt)
[2021-08-11T20:09:15.638Z] Querying Binance (btc/usdt)
[2021-08-11T20:09:15.638Z] Querying Kraken (btc/usdt)
[2021-08-11T20:09:15.638Z] Querying Huobi (btc/usdt)
[2021-08-11T20:09:15.638Z] Querying Bittrex (usdt/usd)
[2021-08-11T20:09:15.638Z] Querying Kraken (usdt/usd)
[2021-08-11T20:09:16.259Z] HIVE/USD is: 0.465 USD per HIVE
[2021-08-11T20:09:16.259Z] Attempting to publish feed...
A problem occurred while getting current signing key
Most likely the RPC node is down.
The error returned was: Internal Error
Switched node to https://api.deathwing.me.
Will retry in 60 seconds
(node:10826) UnhandledPromiseRejectionWarning: ReferenceError: reject is not defined
    at delay.then.catch (/home/shmoogle/hivefeed-js/app.js:207:51)
(node:10826) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:10826) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.