Join 78,741 users and earn money for participation

Announcing Knuth C#/.NET API v0.3.0

0 147 boost
Avatar for kth
Written by   107
1 year ago

Release announcement: Knuth C#/.NET API v0.3.0.

The Knuth team is pleased to announce the release of its C#/.NET API version 0.3.0.

This release includes the following features and fixes:

  • New Configuration API. Now you can configure the node not just with a config file. You can do it using code.

  • Based on the Knuth C-API version 0.4.5.

Our goal is to provide a set of libraries in various programming languages that simplifies application development, ease on-boarding of new developers and let them build their new ideas and really boost the Bitcoin Cash ecosystem.

Using the Knuth C#/.NET API you can use our node as a library.

It is now possible to launch a Knuth node using C# without the need for a configuration file. You can specify the node configuration using C# code.

var settings = Settings.GetDefault(NetworkType.Mainnet);

// avoid connecting to nodes of other coins
settings.Network.UserAgentBlacklist.Add("/Bitcoin SV");
if (DateTime.Now >= new DateTime(2020, 11, 15)) {
    settings.Network.UserAgentBlacklist.Add("/Bitcoin ABC");

> "Hello, Knuth"

Using this library is very simple, since Knuth provides a NuGet package.

1. Create a new C# console project:

$ mkdir HelloKnuth
$ cd HelloKnuth
$ dotnet new console

2. Add a reference to our C# API package:

$ dotnet add package kth-bch

3. Edit Program.cs and write some code:

using System;
using System.Threading.Tasks;
using Knuth;

namespace HelloKnuth {
    public class Program {
        private static bool running_;

        static async Task Main(string[] args) {
            Console.CancelKeyPress += OnSigInterrupt;

            using (var node = new Knuth.Node("mainnet.cfg")) {
                await node.LaunchAsync();
                Console.WriteLine("Knuth node has been launched.");

                var height = await node.Chain.GetLastHeightAsync();
                Console.WriteLine($"Current height in local copy: {height.Result}");

                if (await ComeBackAfterTheBCHHardFork(node)) {
                    Console.WriteLine("Bitcoin Cash has been created!");
            Console.WriteLine("Good bye!");

        private static async Task<bool> ComeBackAfterTheBCHHardFork(Node node) {
            UInt64 hfHeight = 478559;
            while (running_) {
                var res = await node.Chain.GetLastHeightAsync();
                if (res.Result >= hfHeight) return true;
                await Task.Delay(10000);
            return false;

        private static void OnSigInterrupt(object sender, ConsoleCancelEventArgs args) {
            Console.WriteLine("Stop signal detected.");
            args.Cancel = true;
            running_ = false;

4. Enjoy Knuth node as a C# library:

$ dotnet run

You can see the prerequisites here.

Thanks to the Bitcoin Cash ecosystem for your support!

The Knuth team.

$ 1.60
$ 1.00 from @gotamd
$ 0.50 from @ErdoganTalk
$ 0.10 from @unitedstatian
Sponsors of kth
Avatar for kth
Written by   107
1 year ago
Enjoyed this article?  Earn Bitcoin Cash by sharing it! Explain
...and you will also help the author collect more tips.