Skip to content

Rust implementation of indexer for Ergvein wallet

Notifications You must be signed in to change notification settings

hexresearch/ergvein-rusty

Repository files navigation

Rust implementation of indexing node for ergvein mobile wallet.

How to build

  1. The local nix shell provides rustup or install it manually.
  2. Add toolchain: rustup toolchain add nightly && rustup default nightly
  3. You will need clang and llvm to build rocksdb dependency.
  4. Build: cargo build and cargo build --release for release binary.

How to run

You will need either any public remote node, or local one (prefer for speed of indexation):

cargo run --release -- 127.0.0.1:8333

How to run with docker (or any compatible container runtime)

We have official docker image ergvein/ergvein-index-server:rusty built from the Dockerfile.

docker run --rm --volume ergveindata:/data --network host ergvein/ergvein-index-server:rusty --host 0.0.0.0 --bitcoin 127.0.0.1:8333

Here we use no network isolation and assumes that you have running BitcoinCore on the 8333 port.

How to host as service on NixOS

  1. Create nix module based on following code:
{config, lib, pkgs, ...}:
let
ergvein = (import <nixpkgs> {}).fetchFromGitHub {
  owner = "hexresearch";
  repo = "ergvein-rusty";
  rev = "c4eb3fdb19a90e0a153f97413a8ee68fd3f0efa3";
  sha256 = "19q3g9w8rk5rf4a22c1a8igxbhyh3j1zln57m6px918yfq7aa131";
};
in {
  imports = [
    "${ergvein}/nix/modules/ergvein.nix"
  ];
  config = {
    services.ergvein = {
      enable = true;
      externalAddress = "{ExternalAddress}:8667";
      metrics = true;
    };
    services.ergvein-rusty = {
      blockBatch = 100;
      maxCache = {UTXO_COUNT};
    };
 
   services.bitcoin.passwordHMAC = "{HMAC}";
  };
}

Where:

  • ExternalAddress is IP of hosting machine thus an address of indexer
  • HMAC credentials for bitcoin node RPC. Follow this to generate your own https://github.com/bitcoin/bitcoin/tree/master/share/rpcauth
  • UTXO_COUNT is number of UTXO stored in RAM cache. Max memory consumption: 15Gb at 40000000, 10.5Gb at 20000000. Feel free to experiment with it but beware of out of memory error on high values
  1. Edit configuration.nix
  • add created module to import
imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      ./cachix.nix
      {PATH_TO_MODULE}
    ];

  • allow indexer port (8667 by default for mainnet) in firewall
networking.firewall.allowedTCPPorts = [ 8667 ];

3 Apply changes by running nixos-rebuild switch command

About

Rust implementation of indexer for Ergvein wallet

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages