Neutrino + Elements
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:
NodeServiceis a full node maintaining an up-to-date state of the block headers + compact filters. The NodeService writes down headers and filters in repositories.ScannerServiceuses filters and headers repositories to handleScanRequestwhich aims to know if an outpoint (identified by its script) is spent or not.
Two binaries are provided if you want to use ready light client:
neutrinodis a daemon that accepts websocket connections on which clients can send requests to watch for events related to wallet-descriptor
neutrinod also exposes HTTP endpoint that supports adding webhooks to receive notifications when an event occurs.neutrinois a simple command line tool that can be used to watch Liquid side-chain events.
- Go (^1.17.*)
- Nigiri (^0.4.*)
make build-nd
make build-n
make test
make dev
- Run
make pgcreatedbto create database inside postgres container - Run(or use binaries)
go run ./cmd/neutrinod/main.goto start neutrinod - Run
make wpkhto fund address with two transactions and get wpkh wallet descriptor - Run
go run ./cmd/neutrino/* subscribe --descriptor="{WPKH_DESCRIPTOR}" --block_height=0 --events=unspentUtxoto watch for events
./neutrinod
./neutrino config
./neutrino subscribe --descriptor="{WALLET_DESCRIPTOR}" --block_height={BLOCK_HEIGHT} --events=unspentUtxo
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"}'Neutrinod can be used to subscribe to events related to wallet-descriptor using web-socket or by registrating webhook using HTTP.
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
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"
MIT - see the LICENSE.md file for details