Skip to content

Using existing node automatically #8

@Kixunil

Description

@Kixunil

Idea mentioned in janoside/btc-rpc-explorer#279 (comment)

TL;DR: scroll down to "The simplest client-side implementation..."

Currently I solve this in my repository by simply placing proper configuration files in standard location and then reading them from other apps. This is still sub-optimal, so I intend to use interface files. I hope to refactor it in the following months.

The general idea is that we would standardize these locations:

  • /etc/interfaces/$INTERFACE/*
  • $XDG_CONFIG_HOME/interfaces/$INTERFACE/* ($XDG_CONFIG_HOME defaults to ~/.config)

Where $INTERFACE refers to interface name. In case of Bitcoin, we would have these interfaces:

  • bitcoin-rpc-public-$NETWORK - can only execute harmless calls
  • bitcoin-rpc-full-$NETWORK - full access to bitcoind wallet and chain.

$NETWORK refers to mainnet|testnet|regtest|signet. We can have more permission granularity in the future.

There's obligatory _default file in the interfaces directory. This can be used in case the consumer doesn't want to mess with handling multiple services.

The simplest client-side implementation is to just try to read and parse the files in this order:

  1. $XDG_CONFIG_HOME/interfaces/bitcoin-rpc-public-$NETWORK/_default
  2. ~/.config/interfaces/bitcoin-rpc-public-$NETWORK/_default (if XDG_CONFIG_HOME is not set)
  3. /etc/interfaces/bitcoin-rpc-public-$NETWORK/_default

When one of them succeeds, break the loop and use it.

The contents of the file should be:

_spec_vesion = "1.0"
_iface_name = "bitcoin-rpc-public-mainnet"
# This is not bitcoind version but RPC and spec version
_iface_version = "1.0"
_impl_name = "bitcoind"

port = 8332
# user:pasword,
auth_token = "public:public"
# Alternatively:
# cookie_file = "/var/run/bitcoin-mainnet/cookie"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions