NBXplorer.Client
4.3.5
See the version list below for details.
dotnet add package NBXplorer.Client --version 4.3.5
NuGet\Install-Package NBXplorer.Client -Version 4.3.5
<PackageReference Include="NBXplorer.Client" Version="4.3.5" />
paket add NBXplorer.Client --version 4.3.5
#r "nuget: NBXplorer.Client, 4.3.5"
// Install NBXplorer.Client as a Cake Addin #addin nuget:?package=NBXplorer.Client&version=4.3.5 // Install NBXplorer.Client as a Cake Tool #tool nuget:?package=NBXplorer.Client&version=4.3.5
NBXplorer
A minimalist UTXO tracker for HD Wallets. The goal is to have a flexible, .NET based UTXO tracker for HD wallets. The explorer supports P2SH,P2PKH,P2WPKH,P2WSH and Multi-sig derivation.
This explorer is not meant to be exposed on internet, but should be used as an internal tool for tracking the UTXOs of your own service.
It has a bunch of features:
- Can pass arguments via environment variable, command line or configuration file
- Automatically reconnect to your node if the connection goes temporarily down
- An easy to use REST API
- Persistence via Postgres
- Connect via RPC to broadcast transaction instead of using the P2P protocol like this example
- Connect via RPC to your trusted node to get the proper fee rate.
- Altcoin support
- Huge test suite
- Pruning of transaction data (in practice, we don't need to save the whole transaction, only the spent outpoint and received coin for the wallet)
- Multi-wallet
- Flexible address generation schemes (multisig, segwit, legacy etc...)
- Pruning for big wallets (Removal of tracked transaction which do not impact the resulting UTXO set)
It currently supports the following altcoins:
- Althash
- Argoneum
- BCash (also known as Bitcoin Cash)
- BGold (also known as Bitcoin Gold)
- BitCore
- Chaincoin
- ColossusXT
- Dash
- Dogecoin
- Feathercoin
- Gobyte
- Groestlcoin
- Litecoin
- Monacoin
- MonetaryUnit
- Monoeci
- Polis
- Qtum
- Terracoin
- Ufo
- Viacoin
Read our API Specification.
Prerequisite
- Install .NET Core SDK v8.0 or above
- Bitcoin Core instance synched and running (at least 24.0).
- PostgresSQL v13+
Use --postgres
flag to setup the connection string. See schema documentation.
API Specification
Read our API Specification.
How to build and run?
If you are using Bitcoin core default settings:
On Powershell:
.\build.ps1
On Linux:
./build.sh
Then to run:
On Powershell:
.\run.ps1 --help
On Linux:
./run.sh --help
Example, if you have ltc node and btc node on regtest (default configuration), and want to connect to them: (see documentation for other options in the postgres connection string)
./run.sh --chains=btc,ltc --network=regtest --postgres "User ID=postgres;Host=127.0.0.1;Port=39382;Database=nbxplorer"
How to use the API?
Check the API documentation, you can then use any client library:
- NBXplorer.NodeJS for NodeJS clients.
- NBXplorer.Client for .NET clients.
Here is a small C# example showing a 2-2 multisig with Alice and Bob that you can run on regtest.
With Docker
Use our image. You can check the sample for configuring and composing it bitcoin core.
How to develop on it?
If you are on Windows, I recommend Visual Studio 2022 (17.8.0). If you are on other platform and want lightweight environment, use Visual Studio Code. If you are hardcore, you can code on vim.
I like Visual Studio Code and Visual Studio 2022 as it allows me to debug in step by step.
How to configure?
NBXplorer supports configuration through command line arguments, configuration file, or environment variables.
Configuration file
If you are not using standard install for bitcoind, you will have to change the configuration file: In Windows it is located in
C:\Users\<user>\AppData\Roaming\NBXplorer\<network>\settings.config
On linux or mac:
~/.nbxplorer/<network>/settings.config
The default configuration assumes mainnet
with only btc
chain supported, and uses the default settings of bitcoind.
You can change the location of the configuration file with the --conf=pathToConf
command line argument.
Command line parameters
Please note that NBXplorer uses cookie authentication by default. If you run your Bitcoin/Litecoin/Dash nodes using their daemon (like bitcoind
, litecoind
or dashd
), they generate a new cookie every time you start them, and that should work without any extra configuration.
If you run the node(s) using the GUI versions, like Bitcoin\Litecoin\Dash Core Qt with the -server
parameter while you set the rpcusername and rpcpassword in their .conf
files, you must set those values for every crypto you are planning to support.
See samples below.
Run from source (requires .NET Core SDK)
You should use run.ps1
(Windows) or run.sh
(Linux) to execute NBXplorer, but you can also execute it manually with the following command:
dotnet run --no-launch-profile -p .\NBXplorer\NBXplorer.csproj -- <parameters>
Run using built DLL (requires .NET Core Runtime only)
If you already have a compiled DLL, you can run the executable with the following command:
dotnet NBXplorer.dll <parameters>
Sample parameters
Running NBXplorer HTTP server on port 20300, connecting to the BTC mainnet node locally.
--port=20300 --network=mainnet --btcnodeendpoint=127.0.0.1:32939
Running NBXplorer on testnet, supporting Bitcoin, Litecoin and Dash, using cookie authentication for BTC and LTC, and RPC username and password for Dash, connecting to all of them locally.
--chains=btc,ltc,dash --network=testnet --dashrpcuser=myuser --dashrpcpassword=mypassword
Environment variables
The same settings as above, for example export NBXPLORER_PORT=20300
. This is usefull for configuring docker.
How to Run
Command Line
You can use the dotnet command which is part of .NET Core to run NBXplorer. To run from source you must have the .NET Core SDK installed e.g.
dotnet run NBXplorer.dll
As described above you may add configuration parameters if desired.
If you have a compiled version of NBXplorer you should have a file in your build folder named NBXplorer.dll. This cannot itself be directly executed on the command line as it is not an executable file. Instead we can use the dotnet
runtime to execute the dll file.
e.g. dotnet NBXplorer.dll
Important Note
This tool will only start scanning from the configured startheight
. (By default, the height of the blockchain during your first run)
This means that you might not see old payments from your HD key.
If you need to see old payments, you need to configure --[crypto]startheight
to a specific height of your choice, then run it again with --[crypto]rescan
, e.g.
./run.sh --chains=ltc --ltcrescan --ltcstartheight=101
How to query?
Using Postman
Postman is a useful tool for testing and experimenting with REST API's.
You can test the NBXplorer API quickly and easily using Postman.
If you use cookie authentication (enabled by default) in your locally run NBXplorer, you need to set that up in Postman:
- Run NBXplorer and locate you cookie file (NBXplorer will generate a new Cookie file each time it runs in its default data folder)
- In Postman create a new GET API test
- In Authorization select Basic Auth, you should see 2 input boxes for username and password
- Open your cookie file with a text editor e.g. Notepad on windows . You should see a cookie string e.g.
__cookie__:0ff9cd83a5ac7c19a6b56a3d1e7a5c96e113d42dba7720a1f72a3a5e8c4b6c66
- Back in Postman paste the
__cookie__
part of your cookie file into username (whatever comes before the 😃 - Paste the Hex string (after the : ) into the password box
- Click the Update Request button in Postman - this will force Postman to generate the correct HTTP headers based on your cookie details
- You should now see a new entry in the Headers section with a Key of Authorization and Value of Basic xxxxxxxxx where the string after
Basic
will be your Base64 encoded username and password. - Enter the API URL you are going to test
You can also disable authentication in NBXplorer for testing with the --noauth
parameter. This makes testing quicker:
- Run NBXplorer with the
--noauth
command line argument or the environment variableNBXPLORER_NOAUTH=1
- In Postman create a new GET API test
- In Authorization select No Auth
- Enter the API URL you are going to test
You are now ready to test the API - it is easiest to start with something simple such as the fees endpoint e.g.
http://localhost:24444/v1/cryptos/btc/fees/3
this should return a JSON payload e.g.
{ "feeRate": 9, "blockCount": 3 }
Message Brokers
Azure Service Bus
Support has been added for Azure Service Bus as a message broker. Currently 2 Queues and 2 Topics are supported
Queues
- New Block
- New Transaction
Topics
- New Block
- New Transaction
Filters should be applied on the client, if required.
To activate Azure Service Bus Mesages you should add an Azure Service Bus Connection string to your config file or on the command line.
- To use queues you should specify the queue names you wish to use
- To use topics you should specify the topic names you wish to use
You can use both queues and topics at the same time.
Config Settings
If you use the Configuration file to setup your NBXplorer options:
asbcnstr=Your Azure Service Bus Connection string
asbblockq=Name of queue to send New Block message to
asbtranq=Name of queue to send New Transaction message to
asbblockt=Name of topic to send New Block message to
asbtrant=Name of queue to send New Transaction message to
RabbitMq
Support has been added for RabbitMq as a message broker. Currently 2 exchanges supported;
- New Block
- New Transaction
Filters can be applied on the client by defining routing keys;
For transactions;
transactions.#
to get all transactions.transactions.[BTC].#
to get all [Bitcoin] transactions.transactions.[BTC].confirmed
to get only confirmed [Bitcoin] transactions.transactions.[BTC].unconfirmed
to get only unconfirmed [Bitcoin] transactions.transactions.*.confirmed
to get all confirmed transactions.transactions.*.unconfirmed
to get all unconfirmed transactions.
For blocks;
blocks.#
to get all blocks.blocks.[BTC]
to get all [Bitcoin] blocks.
To activate RabbitMq mesages you should add following settings to your config file or on the command line.
- rmqhost, rmquser, rmqpass
Config Settings
If you use the Configuration file to setup your NBXplorer options:
rmqhost= RabbitMq host name
rmqvirtual= RabbitMq virtual host
rmquser= RabbitMq username
rmqpass= RabbitMq password
rmqtranex= Name of exchange to send transaction messages
rmqblockex= Name of exchange to send block messages
Payloads are JSON and map to NewBlockEvent
, NewTransactionEvent
in the NBXplorer.Models
namespace. There is no support in NBXplorer client for message borkers at the current time. You will need to use the Serializer
in NBXplorer.Client
to de-serialize the objects or then implement your own JSON de-serializers for the custom types used in the payload.
For configuring serializers you can get crypto code info from BasicProperties.Headers[CryptoCode]
of RabbitMq messages or UserProperties[CryptoCode]
of Azure Service Bus messages.
Examples can be found in unit tests.
Troubleshooting
If you receive a 401 Unauthorized then your cookie data is not working. Check you are using the current cookie by opening the cookie file again - also check the date/time of the cookie file to ensure it is the latest cookie (generated when you launched NBXplorer).
If you receive a 404 or timeout then Postman cannot see the endpoint
- are you using the correct Port ?
- are you running postman on localhost ?
Client API
A better documentation is on the way, for now the only documentation is the client API in C# on nuget.
The ExplorerClient
classes allows you to query unused addresses, and the UTXO of an HD PubKey.
You can take a look at the tests to see how it works.
There is a simple use case documented on Blockchain Programming in C#.
How to run the tests?
This is easy, from repo directory:
cd NBXplorer.Tests
dotnet test
The tests can take long the first time, as it download Bitcoin Core binaries. (Between 5 and 10 minutes)
How to add support to my altcoin
First you need to add support for your altcoin to NBitcoin.Altcoins
. (See here).
Once this is done and NBXplorer
updated to use the last version of NBitcoin.Altcoins
, follow Litecoin example.
If you want to test if everything is working, modify ServerTester.Environment.cs to match your altcoin.
Then run the tests.
Licence
This project is under MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- NBitcoin (>= 7.0.45)
- NBitcoin.Altcoins (>= 3.0.31)
- System.Net.WebSockets.Client (>= 4.3.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on NBXplorer.Client:
Package | Downloads |
---|---|
NLCoreBase
Package Description |
GitHub repositories (3)
Showing the top 3 popular GitHub repositories that depend on NBXplorer.Client:
Repository | Stars |
---|---|
btcpayserver/btcpayserver
Accept Bitcoin payments. Free, open-source & self-hosted, Bitcoin payment processor.
|
|
dgarage/NBXplorer
NBitcoin Explorer
|
|
bizanc/Bizanc.io.Core
Bizanc Blockchain
|
Version | Downloads | Last updated |
---|---|---|
4.3.6 | 63 | 11/30/2024 |
4.3.5 | 43 | 11/28/2024 |
4.3.4 | 852 | 11/14/2024 |
4.3.3 | 82 | 11/14/2024 |
4.3.2 | 3,461 | 6/4/2024 |
4.3.1 | 6,535 | 5/21/2024 |
4.3.0 | 7,664 | 1/18/2024 |
4.2.6 | 4,048 | 11/15/2023 |
4.2.5 | 13,103 | 6/1/2023 |
4.2.4 | 600 | 5/9/2023 |
4.2.3 | 11,384 | 1/16/2023 |
4.2.2 | 3,751 | 12/8/2022 |
4.2.1 | 3,239 | 10/18/2022 |
4.2.0 | 14,910 | 4/3/2022 |
4.1.3 | 10,664 | 10/23/2021 |
4.1.2 | 1,927 | 9/2/2021 |
4.1.1 | 858 | 8/31/2021 |
4.1.0 | 2,641 | 8/30/2021 |
4.0.3 | 1,544 | 8/5/2021 |
4.0.2 | 822 | 7/31/2021 |
4.0.1 | 1,058 | 7/31/2021 |
4.0.0 | 1,082 | 7/28/2021 |
3.0.21 | 6,268 | 4/23/2021 |
3.0.20 | 8,017 | 1/25/2021 |
3.0.19 | 5,665 | 10/24/2020 |
3.0.18 | 2,811 | 8/19/2020 |
3.0.17 | 3,536 | 7/28/2020 |
3.0.16 | 10,535 | 6/11/2020 |
3.0.15 | 2,407 | 5/23/2020 |
3.0.14 | 1,111 | 5/23/2020 |
3.0.13 | 1,015 | 5/22/2020 |
3.0.12 | 1,014 | 5/22/2020 |
3.0.11 | 2,029 | 5/5/2020 |
3.0.10 | 1,011 | 5/4/2020 |
3.0.9 | 3,706 | 4/8/2020 |
3.0.8 | 975 | 4/3/2020 |
3.0.7 | 1,382 | 4/1/2020 |
3.0.6 | 1,088 | 3/31/2020 |
3.0.5 | 3,884 | 3/10/2020 |
3.0.4 | 1,001 | 3/10/2020 |
3.0.3 | 2,547 | 1/27/2020 |
3.0.2 | 3,463 | 1/13/2020 |
3.0.1 | 3,131 | 12/2/2019 |
3.0.0 | 1,124 | 12/1/2019 |
2.0.0.26 | 1,591 | 11/16/2019 |
2.0.0.25 | 1,036 | 11/16/2019 |
2.0.0.24 | 1,132 | 11/15/2019 |
2.0.0.23 | 1,206 | 11/11/2019 |
2.0.0.22 | 1,085 | 11/11/2019 |
2.0.0.21 | 1,784 | 10/23/2019 |
2.0.0.20 | 1,026 | 10/23/2019 |
2.0.0.19 | 2,744 | 8/13/2019 |
2.0.0.18 | 1,780 | 7/15/2019 |
2.0.0.17 | 1,921 | 5/30/2019 |
2.0.0.16 | 1,324 | 5/19/2019 |
2.0.0.15 | 1,189 | 5/16/2019 |
2.0.0.14 | 1,138 | 5/16/2019 |
2.0.0.13 | 1,282 | 5/14/2019 |
2.0.0.12 | 1,338 | 5/10/2019 |
2.0.0.11 | 1,398 | 5/3/2019 |
2.0.0.10 | 1,143 | 5/2/2019 |
2.0.0.9 | 1,115 | 5/2/2019 |
2.0.0.7 | 1,090 | 5/1/2019 |
2.0.0.6 | 9,035 | 3/31/2019 |
2.0.0.5 | 1,407 | 3/2/2019 |
2.0.0.4 | 1,371 | 3/1/2019 |
2.0.0.3 | 2,025 | 1/16/2019 |
2.0.0.2 | 1,393 | 1/16/2019 |
2.0.0.1 | 2,160 | 12/1/2018 |
2.0.0 | 3,072 | 11/21/2018 |
1.0.3.11 | 1,440 | 11/15/2018 |
1.0.3.10 | 1,480 | 11/9/2018 |
1.0.3.8 | 1,140 | 11/4/2018 |
1.0.3.6 | 1,159 | 11/4/2018 |
1.0.3.5 | 1,314 | 11/2/2018 |
1.0.3.4 | 1,244 | 10/31/2018 |
1.0.3.3 | 1,285 | 10/26/2018 |
1.0.3.2 | 1,232 | 10/25/2018 |
1.0.3.1 | 1,310 | 10/18/2018 |
1.0.3 | 1,569 | 10/2/2018 |
1.0.2.19 | 1,378 | 9/28/2018 |
1.0.2.18 | 1,628 | 8/14/2018 |
1.0.2.17 | 2,413 | 8/10/2018 |
1.0.2.16 | 1,281 | 8/7/2018 |
1.0.2.15 | 1,613 | 7/23/2018 |
1.0.2.14 | 1,365 | 7/21/2018 |
1.0.2.13 | 1,422 | 7/13/2018 |
1.0.2.12 | 1,641 | 6/29/2018 |
1.0.2.11 | 1,613 | 6/23/2018 |
1.0.2.10 | 1,627 | 5/31/2018 |
1.0.2.8 | 1,595 | 5/11/2018 |
1.0.2.7 | 1,513 | 5/8/2018 |
1.0.2.6 | 1,503 | 5/7/2018 |
1.0.2.5 | 1,469 | 5/7/2018 |
1.0.2.4 | 1,692 | 5/5/2018 |
1.0.2.3 | 1,613 | 4/26/2018 |
1.0.2.2 | 1,510 | 4/25/2018 |
1.0.2.1 | 1,521 | 4/25/2018 |
1.0.2 | 1,573 | 4/19/2018 |
1.0.1.24 | 1,664 | 4/13/2018 |
1.0.1.23 | 1,667 | 4/13/2018 |
1.0.1.22 | 1,494 | 4/13/2018 |
1.0.1.21 | 1,513 | 4/12/2018 |
1.0.1.20 | 1,558 | 4/10/2018 |
1.0.1.19 | 1,437 | 4/10/2018 |
1.0.1.18 | 1,539 | 4/9/2018 |
1.0.1.17 | 1,662 | 4/6/2018 |
1.0.1.16 | 1,914 | 3/12/2018 |
1.0.1.15 | 1,482 | 3/9/2018 |
1.0.1.14 | 1,588 | 3/6/2018 |
1.0.1.13 | 1,537 | 3/4/2018 |
1.0.1.11 | 1,533 | 3/3/2018 |
1.0.1.10 | 1,608 | 3/2/2018 |
1.0.1.9 | 1,690 | 2/12/2018 |
1.0.1.8 | 1,648 | 2/1/2018 |
1.0.1.7 | 1,573 | 2/1/2018 |
1.0.1.6 | 1,539 | 1/31/2018 |
1.0.1.5 | 1,571 | 1/31/2018 |
1.0.1.4 | 1,519 | 1/31/2018 |
1.0.1.3 | 1,561 | 1/31/2018 |
1.0.1.2 | 1,735 | 1/17/2018 |
1.0.1 | 1,579 | 1/16/2018 |
1.0.0.34 | 1,534 | 1/15/2018 |
1.0.0.33 | 1,610 | 1/12/2018 |
1.0.0.32 | 1,570 | 1/12/2018 |
1.0.0.31 | 1,484 | 1/12/2018 |
1.0.0.30 | 1,397 | 1/12/2018 |
1.0.0.29 | 1,554 | 1/11/2018 |
1.0.0.28 | 1,499 | 1/10/2018 |
1.0.0.27 | 1,533 | 1/10/2018 |
1.0.0.26 | 1,604 | 1/9/2018 |
1.0.0.25 | 1,561 | 1/8/2018 |
1.0.0.24 | 1,522 | 1/7/2018 |
1.0.0.23 | 1,566 | 1/7/2018 |
1.0.0.22 | 1,544 | 12/30/2017 |
1.0.0.21 | 1,513 | 12/20/2017 |
1.0.0.20 | 1,580 | 12/16/2017 |
1.0.0.19 | 1,540 | 12/16/2017 |
1.0.0.18 | 1,659 | 11/4/2017 |
1.0.0.17 | 1,507 | 10/6/2017 |
1.0.0.16 | 1,492 | 10/5/2017 |
1.0.0.15 | 1,429 | 10/5/2017 |
1.0.0.14 | 1,399 | 10/4/2017 |
1.0.0.12 | 1,430 | 9/15/2017 |
1.0.0.11 | 1,399 | 9/15/2017 |
1.0.0.10 | 1,423 | 9/15/2017 |
1.0.0.9 | 1,460 | 9/14/2017 |
1.0.0.8 | 1,387 | 9/12/2017 |
1.0.0.7 | 1,415 | 9/1/2017 |
1.0.0.6 | 1,477 | 8/30/2017 |
1.0.0.5 | 1,343 | 8/30/2017 |
1.0.0.4 | 1,462 | 8/25/2017 |
1.0.0.3 | 1,438 | 8/23/2017 |
1.0.0.2 | 1,369 | 8/22/2017 |
1.0.0.1 | 1,416 | 8/22/2017 |
1.0.0 | 1,447 | 8/18/2017 |