pub struct Builder { /* private fields */ }uniffi only.Expand description
A builder for an Node instance, allowing to set some configuration and module choices from
the getgo.
§Defaults
- Wallet entropy is sourced from a
keys_seedfile located underConfig::storage_dir_path - Chain data is sourced from the Esplora endpoint
https://blockstream.info/api - Gossip data is sourced via the peer-to-peer network
Implementations§
Source§impl NodeBuilder
impl NodeBuilder
Sourcepub fn from_config(config: Config) -> Self
pub fn from_config(config: Config) -> Self
Creates a new builder instance from an Config.
Sourcepub fn set_runtime(&mut self, runtime_handle: Handle) -> &mut Self
pub fn set_runtime(&mut self, runtime_handle: Handle) -> &mut Self
Configures the Node instance to (re-)use a specific tokio runtime.
If not provided, the node will spawn its own runtime or reuse any outer runtime context it can detect.
Sourcepub fn set_entropy_seed_path(&mut self, seed_path: String) -> &mut Self
pub fn set_entropy_seed_path(&mut self, seed_path: String) -> &mut Self
Configures the Node instance to source its wallet entropy from a seed file on disk.
If the given file does not exist a new random seed file will be generated and stored at the given location.
Sourcepub fn set_entropy_seed_bytes(&mut self, seed_bytes: [u8; 64]) -> &mut Self
pub fn set_entropy_seed_bytes(&mut self, seed_bytes: [u8; 64]) -> &mut Self
Configures the Node instance to source its wallet entropy from the given
WALLET_KEYS_SEED_LEN seed bytes.
Sourcepub fn set_entropy_bip39_mnemonic(
&mut self,
mnemonic: Mnemonic,
passphrase: Option<String>,
) -> &mut Self
pub fn set_entropy_bip39_mnemonic( &mut self, mnemonic: Mnemonic, passphrase: Option<String>, ) -> &mut Self
Sourcepub fn set_chain_source_esplora(
&mut self,
server_url: String,
sync_config: Option<EsploraSyncConfig>,
) -> &mut Self
pub fn set_chain_source_esplora( &mut self, server_url: String, sync_config: Option<EsploraSyncConfig>, ) -> &mut Self
Configures the Node instance to source its chain data from the given Esplora server.
If no sync_config is given, default values are used. See EsploraSyncConfig for more
information.
Sourcepub fn set_chain_source_esplora_with_headers(
&mut self,
server_url: String,
headers: HashMap<String, String>,
sync_config: Option<EsploraSyncConfig>,
) -> &mut Self
pub fn set_chain_source_esplora_with_headers( &mut self, server_url: String, headers: HashMap<String, String>, sync_config: Option<EsploraSyncConfig>, ) -> &mut Self
Configures the Node instance to source its chain data from the given Esplora server.
The given headers will be included in all requests to the Esplora server, typically used for
authentication purposes.
If no sync_config is given, default values are used. See EsploraSyncConfig for more
information.
Sourcepub fn set_chain_source_electrum(
&mut self,
server_url: String,
sync_config: Option<ElectrumSyncConfig>,
) -> &mut Self
pub fn set_chain_source_electrum( &mut self, server_url: String, sync_config: Option<ElectrumSyncConfig>, ) -> &mut Self
Configures the Node instance to source its chain data from the given Electrum server.
If no sync_config is given, default values are used. See ElectrumSyncConfig for more
information.
Sourcepub fn set_chain_source_bitcoind_rpc(
&mut self,
rpc_host: String,
rpc_port: u16,
rpc_user: String,
rpc_password: String,
) -> &mut Self
pub fn set_chain_source_bitcoind_rpc( &mut self, rpc_host: String, rpc_port: u16, rpc_user: String, rpc_password: String, ) -> &mut Self
Configures the Node instance to connect to a Bitcoin Core node via RPC.
This method establishes an RPC connection that enables all essential chain operations including transaction broadcasting and chain data synchronization.
§Parameters:
rpc_host,rpc_port,rpc_user,rpc_password- Required parameters for the Bitcoin Core RPC connection.
Sourcepub fn set_chain_source_bitcoind_rest(
&mut self,
rest_host: String,
rest_port: u16,
rpc_host: String,
rpc_port: u16,
rpc_user: String,
rpc_password: String,
) -> &mut Self
pub fn set_chain_source_bitcoind_rest( &mut self, rest_host: String, rest_port: u16, rpc_host: String, rpc_port: u16, rpc_user: String, rpc_password: String, ) -> &mut Self
Configures the Node instance to synchronize chain data from a Bitcoin Core REST endpoint.
This method enables chain data synchronization via Bitcoin Core’s REST interface. We pass additional RPC configuration to non-REST-supported API calls like transaction broadcasting.
§Parameters:
rest_host,rest_port- Required parameters for the Bitcoin Core REST connection.rpc_host,rpc_port,rpc_user,rpc_password- Required parameters for the Bitcoin Core RPC connection
Sourcepub fn set_gossip_source_p2p(&mut self) -> &mut Self
pub fn set_gossip_source_p2p(&mut self) -> &mut Self
Configures the Node instance to source its gossip data from the Lightning peer-to-peer
network.
Sourcepub fn set_gossip_source_rgs(&mut self, rgs_server_url: String) -> &mut Self
pub fn set_gossip_source_rgs(&mut self, rgs_server_url: String) -> &mut Self
Configures the Node instance to source its gossip data from the given RapidGossipSync
server.
Sourcepub fn set_pathfinding_scores_source(&mut self, url: String) -> &mut Self
pub fn set_pathfinding_scores_source(&mut self, url: String) -> &mut Self
Configures the Node instance to source its external scores from the given URL.
The external scores are merged into the local scoring system to improve routing.
Sourcepub fn set_liquidity_source_lsps1(
&mut self,
node_id: PublicKey,
address: SocketAddress,
token: Option<String>,
) -> &mut Self
pub fn set_liquidity_source_lsps1( &mut self, node_id: PublicKey, address: SocketAddress, token: Option<String>, ) -> &mut Self
Configures the Node instance to source inbound liquidity from the given
bLIP-51 / LSPS1 service.
Will mark the LSP as trusted for 0-confirmation channels, see Config::trusted_peers_0conf.
The given token will be used by the LSP to authenticate the user.
Sourcepub fn set_liquidity_source_lsps2(
&mut self,
node_id: PublicKey,
address: SocketAddress,
token: Option<String>,
) -> &mut Self
pub fn set_liquidity_source_lsps2( &mut self, node_id: PublicKey, address: SocketAddress, token: Option<String>, ) -> &mut Self
Configures the Node instance to source just-in-time inbound liquidity from the given
bLIP-52 / LSPS2 service.
Will mark the LSP as trusted for 0-confirmation channels, see Config::trusted_peers_0conf.
The given token will be used by the LSP to authenticate the user.
Sourcepub fn set_liquidity_provider_lsps2(
&mut self,
service_config: LSPS2ServiceConfig,
) -> &mut Self
pub fn set_liquidity_provider_lsps2( &mut self, service_config: LSPS2ServiceConfig, ) -> &mut Self
Sourcepub fn set_storage_dir_path(&mut self, storage_dir_path: String) -> &mut Self
pub fn set_storage_dir_path(&mut self, storage_dir_path: String) -> &mut Self
Sets the used storage directory path.
Sourcepub fn set_filesystem_logger(
&mut self,
log_file_path: Option<String>,
max_log_level: Option<LogLevel>,
) -> &mut Self
pub fn set_filesystem_logger( &mut self, log_file_path: Option<String>, max_log_level: Option<LogLevel>, ) -> &mut Self
Configures the Node instance to write logs to the filesystem.
The log_file_path defaults to DEFAULT_LOG_FILENAME in the configured
Config::storage_dir_path if set to None.
If set, the max_log_level sets the maximum log level. Otherwise, the latter defaults to
DEFAULT_LOG_LEVEL.
Sourcepub fn set_log_facade_logger(&mut self) -> &mut Self
pub fn set_log_facade_logger(&mut self) -> &mut Self
Sourcepub fn set_custom_logger(&mut self, log_writer: Arc<dyn LogWriter>) -> &mut Self
pub fn set_custom_logger(&mut self, log_writer: Arc<dyn LogWriter>) -> &mut Self
Sourcepub fn set_network(&mut self, network: Network) -> &mut Self
pub fn set_network(&mut self, network: Network) -> &mut Self
Sets the Bitcoin network used.
Sourcepub fn set_listening_addresses(
&mut self,
listening_addresses: Vec<SocketAddress>,
) -> Result<&mut Self, BuildError>
pub fn set_listening_addresses( &mut self, listening_addresses: Vec<SocketAddress>, ) -> Result<&mut Self, BuildError>
Sets the IP address and TCP port on which Node will listen for incoming network connections.
Sourcepub fn set_announcement_addresses(
&mut self,
announcement_addresses: Vec<SocketAddress>,
) -> Result<&mut Self, BuildError>
pub fn set_announcement_addresses( &mut self, announcement_addresses: Vec<SocketAddress>, ) -> Result<&mut Self, BuildError>
Sets the IP address and TCP port which Node will announce to the gossip network that it accepts connections on.
Note: If unset, the listening_addresses will be used as the list of addresses to announce.
Sourcepub fn set_node_alias(
&mut self,
node_alias: String,
) -> Result<&mut Self, BuildError>
pub fn set_node_alias( &mut self, node_alias: String, ) -> Result<&mut Self, BuildError>
Sets the node alias that will be used when broadcasting announcements to the gossip network.
The provided alias must be a valid UTF-8 string and no longer than 32 bytes in total.
Sourcepub fn set_async_payments_role(
&mut self,
role: Option<AsyncPaymentsRole>,
) -> Result<&mut Self, BuildError>
pub fn set_async_payments_role( &mut self, role: Option<AsyncPaymentsRole>, ) -> Result<&mut Self, BuildError>
Sets the role of the node in an asynchronous payments context.
See https://github.com/lightning/bolts/pull/1149 for more information about the async payments protocol.
Sourcepub fn build(&self) -> Result<Node, BuildError>
pub fn build(&self) -> Result<Node, BuildError>
Builds a Node instance with a SqliteStore backend and according to the options
previously configured.
Sourcepub fn build_with_fs_store(&self) -> Result<Node, BuildError>
pub fn build_with_fs_store(&self) -> Result<Node, BuildError>
Builds a Node instance with a FilesystemStore backend and according to the options
previously configured.
Sourcepub fn build_with_vss_store(
&self,
vss_url: String,
store_id: String,
lnurl_auth_server_url: String,
fixed_headers: HashMap<String, String>,
) -> Result<Node, BuildError>
pub fn build_with_vss_store( &self, vss_url: String, store_id: String, lnurl_auth_server_url: String, fixed_headers: HashMap<String, String>, ) -> Result<Node, BuildError>
Builds a Node instance with a VSS backend and according to the options
previously configured.
Uses LNURL-auth based authentication scheme as default method for authentication/authorization.
The LNURL challenge will be retrieved by making a request to the given lnurl_auth_server_url.
The returned JWT token in response to the signed LNURL request, will be used for
authentication/authorization of all the requests made to VSS.
fixed_headers are included as it is in all the requests made to VSS and LNURL auth server.
Caution: VSS support is in alpha and is considered experimental. Using VSS (or any remote persistence) may cause LDK to panic if persistence failures are unrecoverable, i.e., if they remain unresolved after internal retries are exhausted.
Sourcepub fn build_with_vss_store_and_fixed_headers(
&self,
vss_url: String,
store_id: String,
fixed_headers: HashMap<String, String>,
) -> Result<Node, BuildError>
pub fn build_with_vss_store_and_fixed_headers( &self, vss_url: String, store_id: String, fixed_headers: HashMap<String, String>, ) -> Result<Node, BuildError>
Builds a Node instance with a VSS backend and according to the options
previously configured.
Uses FixedHeaders as default method for authentication/authorization.
Given fixed_headers are included as it is in all the requests made to VSS.
Caution: VSS support is in alpha and is considered experimental. Using VSS (or any remote persistence) may cause LDK to panic if persistence failures are unrecoverable, i.e., if they remain unresolved after internal retries are exhausted.
Sourcepub fn build_with_vss_store_and_header_provider(
&self,
vss_url: String,
store_id: String,
header_provider: Arc<dyn VssHeaderProvider>,
) -> Result<Node, BuildError>
pub fn build_with_vss_store_and_header_provider( &self, vss_url: String, store_id: String, header_provider: Arc<dyn VssHeaderProvider>, ) -> Result<Node, BuildError>
Builds a Node instance with a VSS backend and according to the options
previously configured.
Given header_provider is used to attach headers to every request made
to VSS.
Caution: VSS support is in alpha and is considered experimental. Using VSS (or any remote persistence) may cause LDK to panic if persistence failures are unrecoverable, i.e., if they remain unresolved after internal retries are exhausted.
Sourcepub fn build_with_store(
&self,
kv_store: Arc<DynStore>,
) -> Result<Node, BuildError>
pub fn build_with_store( &self, kv_store: Arc<DynStore>, ) -> Result<Node, BuildError>
Builds a Node instance according to the options previously configured.