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_seed
file 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_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_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 source its chain data from the given Bitcoin Core RPC
endpoint.
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_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 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<dyn KVStore + Sync + Send>,
) -> Result<Node, BuildError>
pub fn build_with_store( &self, kv_store: Arc<dyn KVStore + Sync + Send>, ) -> Result<Node, BuildError>
Builds a Node
instance according to the options previously configured.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NodeBuilder
impl !RefUnwindSafe for NodeBuilder
impl Send for NodeBuilder
impl Sync for NodeBuilder
impl Unpin for NodeBuilder
impl !UnwindSafe for NodeBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more