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

1 259
Avatar for kth
Written by
2 years ago

The Knuth project is pleased to announce the release of its C#-API version 0.19.0.

This release includes the following features and fixes:

Using the Knuth C#-API you can use the node as a library.

For the full release notes, please visit:

https://github.com/k-nuth/cs-api/releases/tag/v0.19.0


For information about how to install Knuth, please visit our website at https://kth.cash/#download.


> "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;

            var config = Knuth.Config.Settings.GetDefault(NetworkType.Mainnet);
            using (var node = new Knuth.Node(config)) {
                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.


Thank you!

Knuth is open source software that needs community support to continue its development. Therefore we would like to thank the generosity of our supporters and that of the entire Bitcoin Cash ecosystem. You are the ones that allow us to move forward with our goal, which is everyone's goal at Bitcoin Cash, which is to be the Peer-to-Peer Electronic Cash System for the entire world.

Donation address:
bitcoincash:qrlgfg2qkj3na2x9k7frvcmv06ljx5xlnuuwx95zfn

28
$ 33.00
$ 17.67 from @TheRandomRewarder
$ 9.96 from @majamalu
$ 5.00 from @tango
+ 11
Sponsors of kth
empty
empty
empty
Avatar for kth
Written by
2 years ago

Comments

I have been waiting for the release of the new version of the. Node but I forget now I would go and try it out

$ 0.00
2 years ago