This repository contains the code to generate FFI bindings for Floresta, a Bitcoin Utreexo full node. The bindings are generated using UniFFI.
| Language | Platform | Published Package | Build Instructions |
|---|---|---|---|
| Kotlin | Android | org.getfloresta:floresta-android |
floresta-android |
| Python | Linux, macOS | (source only) | See below |
floresta-ffi/
├── floresta-ffi/ # Rust crate with UniFFI bindings
│ ├── src/ # Rust source + UDL definition
│ └── Cargo.toml # Rust dependencies
├── floresta-android/ # Android library project (Gradle)
│ ├── lib/ # Android library module
│ └── scripts/ # Cross-compilation build scripts
└── README.md
If you want to generate the bindings and use it, you can use the just command runner to generate the code. The justfile in the floresta-ffi/ directory contains the commands to generate the bindings for the supported languages.
cd floresta-ffi
just gen-<your-language>Where <your-language> is the language you want to generate the bindings for. For example, to generate the bindings for Python:
cd floresta-ffi
just gen-pythonThis will build the shared library and generate glue code to use the shared library. The generated code will be in the floresta-ffi/generated/<language> folder.
See floresta-android/README.md for Android build and usage instructions.
To use it in Python, you need the generated bindings and the shared-object in the same folder. Then you can start florestad with:
from floresta import Florestad
daemon = Florestad()
daemon.start()
# do something
# at the end you need to stop the daemon
daemon.stop()After you start it, you'll have a JSON-RPC server and an Electrum server running on the default ports. You may use them to communicate with the daemon, see your balance, send transactions, etc.
There's a Config object that may be passed to the Florestad constructor. It has the following fields:
datadir(str) - Required: path to the data directory where chain and wallet data will be storednetwork(Network) - Required: the Bitcoin network to run on (Bitcoin, Signet, Testnet, Regtest, Testnet4)assume_valid(AssumeValidArg) - Required: which blocks are assumed to have valid scriptscfilters(bool) - Whether to build and store compact block filtersfilters_start_height(int) - Block height to start downloading compact filters fromlog_to_stdout(bool) - Whether to write logs to stdoutlog_to_file(bool) - Whether to write logs to a filewallet_xpub(list[str]) - SLIP-132-encoded extended public keys to watchwallet_descriptor(list[str]) - Output descriptors to watchconfig_file(str) - Path to a TOML configuration fileproxy(str) - SOCKS5 proxy for outgoing connectionsconnect(list[str]) - Nodes to connect to exclusivelyjson_rpc_address(str) - Address for the JSON-RPC server to listen onzmq_address(str) - Address for the ZMQ server (requires zmq-server feature)electrum_address(str) - Address for the Electrum server to listen onenable_electrum_tls(bool) - Whether to enable the Electrum TLS serverelectrum_address_tls(str) - Address for the Electrum TLS servertls_key_path(str) - Path to TLS private key filetls_cert_path(str) - Path to TLS certificate filegenerate_cert(bool) - Whether to generate a self-signed TLS certificateallow_v1_fallback(bool) - Whether to allow v1 transport fallbackassume_utreexo(bool) - Enable assume-utreexo modeassumeutreexo_value(AssumeUtreexoValue) - Custom Utreexo accumulator statebackfill(bool) - Whether to backfill skipped blocksdebug(bool) - Enable debug loggingdisable_dns_seeds(bool) - Disable DNS seed nodesuser_agent(str) - User agent string advertised to peers
To set them, create a Config object and pass it to the Florestad constructor:
from floresta import Florestad, Config, Network, AssumeValidArg
config = Config(
datadir="/path/to/data",
network=Network.Bitcoin,
assume_valid=AssumeValidArg.Hardcoded(),
cfilters=True,
log_to_stdout=True,
)
daemon = Florestad.from_config(config)
daemon.start()MIT