Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattludwigs/btcrpc
Bitcoin RPC client
https://github.com/mattludwigs/btcrpc
Last synced: about 1 month ago
JSON representation
Bitcoin RPC client
- Host: GitHub
- URL: https://github.com/mattludwigs/btcrpc
- Owner: mattludwigs
- Created: 2023-03-10T02:45:59.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-05-06T21:04:48.000Z (over 1 year ago)
- Last Synced: 2024-04-14T06:08:29.551Z (9 months ago)
- Language: Elixir
- Size: 10.7 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BTCRPC
Work in progress BTCRPC client.
## Quick start
To use `BTCRPC` in an IEx session:
```elixir
iex> {:ok, _pid} = BTCRPC.start_link(hostname: "localhost", port: 8332, user: "Satoshi", password: "hodl")
iex> {:ok, uptime} = BTCRPC.uptime()
```## Usage in an Elixir application
If you're only talking to a single bitcoin RPC server:
```elixir
defmodule MyApp.Application do
use Application@impl true
def start_link(_type, _args) do
children = [
{BTCRPC, hostname: "localhost", port: 8332, user: "Satoshi", password: "hodl"}
]opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(children, opts)
end
end# later in your code
uptime = BTCRPC.uptime()
```However, `BTCRPC` allows for communication to many servers. Just like above you
would add `BTCRPC` to your supervision tree but the configuration a little
different.```elixir
defmodule MyApp.Application do
use Application@impl true
def start_link(_type, _args) do
rpc_servers = %{
"btc1" => [hostname: "hostname", port: 8332, user: "user", password: "password"],
"btc2" => [hostname: "hostname2", port: 8332, user: "user", password: "password"]
}children = [
{BTCRPC, servers: rpc_servers}
]opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(children, opts)
end
end# later in your code, you will have to specify which server
# to use
uptime = BTCRPC.uptime(server: "btc1")uptime = BTCRPC.uptime(server: "btc2")
```## Road map
[x] getblockcount
[x] getblock
[] sendrawtransaction
[] getrawtransaction (with verbose & blockhash)
[] getmempool(stats)
[] adddescriptortowallet
[] addmultisigaddress
[] estimatesmartfee
[] gettxout
[] importaddress
[] importprivkey