vulpemventures / neutrino-elements

MIT License
3 stars 4 forks source link

Neutrino Elements

Go PkgGoDev Release Go Report Card Bitcoin Donate

Neutrino + Elements

Overview

Neutrino-elements is a set of useful packages and binaries that can be used to "watch" Liquid side-chain events.
It uses Compact Block Filter (BIP0158) to implement a light client for elements based networks.

Two packages, that works independently, are provided if you want to build your own light client:

Two binaries are provided if you want to use ready light client:

Local Development

Requirements

Build neutrinod & neutrino CLI

make build-nd
make build-n

Run test

make test

Run neutrinod and postgres db inside Docker container

make dev

Run neutrinod and postgres db separately

Usage

Run neutrinod

./neutrinod

Config CLI

./neutrino config

Watch for events related to wallet-descriptor(websocket-{HOST:PORT}/neutrino/subscribe/ws)

./neutrino subscribe --descriptor="{WALLET_DESCRIPTOR}" --block_height={BLOCK_HEIGHT} --events=unspentUtxo

Add webhook(http)

curl -X POST http://localhost:8000/neutrino/subscribe/http \
   -H 'Content-Type: application/json' \
   -d '{"actionType":"register", "eventTypes":["unspentUtxo"], "descriptorWallet":"wpkh(037470e26cc774eca62ca19e1a182461a5f3d3680acbc593ce3f38cd142c26c03d)", "startBlockHeight":0, "endpointUrl":"http://127.0.0.1:62900"}'

API

Neutrinod can be used to subscribe to events related to wallet-descriptor using web-socket or by registrating webhook using HTTP.

Web-socket

To subscribe to events related to wallet-descriptor using web-socket connection, send below json :

{
    "actionType":"register", 
    "eventTypes":["unspentUtxo"], 
    "descriptorWallet":"{WALLET_DESCRIPTOR}", 
    "startBlockHeight":"{START_BLOCK_HEIGHT}", 
}

to the following endpoint:

/neutrino/subscribe/ws

HTTP

To register webhook, send bellow json :

{
  "actionType": "register",
  "eventTypes": ["unspentUtxo"],
  "descriptorWallet": "{WALLET_DESCRIPTOR}",
  "startBlockHeight": "{START_BLOCK_HEIGHT}",
  "endpointUrl": "{ENDPOINT_URL}"
}

to the following endpoint:

/neutrino/subscribe/http

Valid actionTypes: "register", "unregister"
Valid eventTypes: "unspentUtxo", "spentUtxo"

License

MIT - see the LICENSE.md file for details

Acknowledgments