High-performance Bitcoin Cash development platform.
Knuth is a high-performance implementation of the Bitcoin protocol aimed at users that need extra performance and flexibility — wallets, exchanges, block explorers and miners.
Knuth is a multi-crypto full node, but also a development platform.
The core is written in C++23. On top of it we ship a set of libraries and modules in several languages that you can use as the foundation for your own application:
C++ · C · JavaScript · TypeScript · JS/TS WebAssembly · C# · Python
You can also build your own binding in any language on top of our C library.
🏗️ Core Infrastructure (k-nuth/kth)
The complete Bitcoin Cash node, ready to run. Suitable as a standalone full node, miner backend, or as the storage tier for an application that needs blockchain access.
The C++23 library at the core of the node, exposing direct access to every protocol primitive. This is the layer to use when you want maximum performance and the full surface area.
A stable C ABI on top of the C++ library. This is the foundation every other-language binding builds on, and the layer to use from C, language bindings, FFI, or anything that prefers a versioned C interface to a templated C++ one.
Built on top of the C API:
| Language | Repository | Notes |
|---|---|---|
| 🟨 JavaScript / TypeScript | js-api |
Full-featured Node.js binding |
| 🟦 WebAssembly (browser) | js-wasm |
Browser-compatible WASM binding |
| 🟣 C# | cs-api |
.NET on Windows, Linux and macOS |
| 🐍 Python | py-api |
Pythonic interface |
- Ask DeepWiki: deepwiki.com/k-nuth/kth — auto-generated, conversational documentation indexed over the codebase. Useful when you want to ask "where is X handled?" or "show me an example of Y" without grepping the tree yourself.
- Version history & repo transition:
docs/VERSION_HISTORY.md
Every Knuth component is published as a single unified Conan package.
-
Install the build helper:
$ pip install kthbuild --user --upgrade $ conan config install https://github.com/k-nuth/ci-utils/raw/master/conan/config2023.zip
-
Install the unified Knuth package. Replace
<VERSION>with the latest release tag from GitHub Releases:$ conan install --requires=kth/<VERSION> --update --deployer=direct_deploy
The deployment lays out:
bin/kth— the node executablelib/— every static library (libnode.a,libc-api.a, …)include/kth/— C++ and C API headers
# Run the node
$ ./kth/bin/kthThe example below constructs a full node with mainnet defaults, opens the chain database and prints the current tip. The configuration constructor pulls in the network defaults for you; tweak any field on cfg before handing it to full_node if you want to override a default.
The chain interface is asynchronous: you call methods on node.chain() and your callback fires when the result is ready, so you can interact with the node while it keeps doing its work.
// example.cpp
#include <latch>
#include <print>
#include <system_error>
#include <kth/node.hpp>
int main() {
// Mainnet defaults — equivalent to what the node-exe ships with.
kth::node::configuration cfg{kth::domain::config::network::mainnet};
// Override individual settings if you need to, e.g.:
// cfg.database.directory = "/var/lib/kth";
// cfg.network.threads = 8;
kth::node::full_node node{cfg};
std::latch done{1};
node.start_chain([&](std::error_code const& ec) {
if (ec) { done.count_down(); return; }
node.chain().fetch_last_height([&](std::error_code const& fec, std::size_t height) {
if ( ! fec) std::println("Current height: {}", height);
done.count_down();
});
});
done.wait();
node.close();
}Compile against the static libraries shipped under lib/:
$ g++ -std=c++23 example.cpp -I./kth/include -L./kth/lib \
-lnode -lblockchain -ldomain -linfrastructureThe C API mirrors the same pattern: kth_config_settings_default(kth_network_mainnet) returns a pre-populated settings struct that you hand to kth_node_construct. The chain interface comes in two flavours — kth_chain_sync_* (blocks the caller) and kth_chain_async_* (callback fires when the answer is ready). The example below uses the async surface to mirror the C++ snippet above.
// hello_knuth.c
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <kth/capi.h>
// Fires once the chain has resolved the request.
static void on_height(kth_chain_t chain, void* ctx, kth_error_code_t ec, kth_size_t height) {
(void)chain; (void)ctx;
if (ec == kth_ec_success) {
printf("Current height: %" PRIu64 "\n", (uint64_t)height);
}
}
int main(void) {
// Mainnet defaults.
kth_settings settings = kth_config_settings_default(kth_network_mainnet);
// Override individual settings if you need to, e.g.:
// settings.database.directory = "/var/lib/kth";
// settings.network.threads = 8;
kth_node_t node = kth_node_construct(&settings, /*stdout_enabled=*/1);
// Submit the height query asynchronously; on_height fires once the chain
// can answer it.
kth_chain_t chain = kth_node_get_chain(node);
kth_chain_async_last_height(chain, /*ctx=*/NULL, on_height);
// Bring the node up and block until SIGINT/SIGTERM. The async query
// resolves while the node is running.
kth_node_init_run_and_wait_for_signal(node, NULL, kth_start_modules_all, NULL);
kth_node_destruct(node);
return 0;
}Link against the C API library:
$ gcc hello_knuth.c -I./kth/include -L./kth/lib -lc-apiFor deeper guides, ask DeepWiki — it indexes the codebase and answers natural-language questions about it.
Latest release across the family. Each badge is the live shields.io endpoint, so the version updates as soon as a new release tag or package version is published.
| Component | Latest |
|---|---|
Knuth (k-nuth/kth) |
|
| C++ library | |
| C library | |
JS / TS — npm @knuth/bch |
|
JS / TS WebAssembly — npm @knuth/js-wasm |
|
C# — NuGet kth-bch |
|
Python — PyPI kth |
For the story behind the version numbers (and why Node appears to "skip" 0.59 → 0.67), see docs/VERSION_HISTORY.md.
Knuth was built as a high-performance node. The build system can detect the microarchitecture of your processor at build time and produce an optimized binary for it. If you don't want to wait for compilation, we ship pre-built binaries targeting Intel's Haswell microarchitecture. The build system handles the choice automatically.
The codebase is organized as a set of focused modules — infrastructure, domain, consensus, database, blockchain, network, node, c-api. Each one is small enough to read in an afternoon and replace if you need to. Protocol changes can be introduced in Knuth significantly faster than in monolithic reference implementations.
Knuth runs on any 64-bit system. We routinely test x86-64 on FreeBSD, Linux, macOS and Windows; ARM64 on macOS is also part of the CI matrix. If you hit a problem on a platform that isn't in the matrix, please let us know.
Knuth is community-backed. Donations subsidize development costs, general maintenance and support.
bitcoincash:qrlgfg2qkj3na2x9k7frvcmv06ljx5xlnuuwx95zfn
See fund.kth.cash for active Flipstarter campaigns.
Knuth is released under the MIT license. See COPYING or opensource.org/licenses/MIT.
See docs/BRANCH_CONVENTIONS.md in the main repo for branch-naming conventions and the rest of the contribution flow.
Telegram group, or email info@kth.cash.
Please report security issues to security@kth.cash.