pub struct LightningNetwork {
pub config: LightningConfig,
pub connected: bool,
pub node_pubkey: Option<String>,
pub channels: Vec<LightningChannel>,
}Expand description
Lightning Network implementation
Fields§
§config: LightningConfigLightning configuration
connected: boolConnection status
node_pubkey: Option<String>Node public key
channels: Vec<LightningChannel>Lightning channels
Implementations§
Source§impl LightningNetwork
impl LightningNetwork
Sourcepub fn new(config: LightningConfig) -> Self
pub fn new(config: LightningConfig) -> Self
Create a new Lightning Network instance
Sourcepub fn new_default() -> Self
pub fn new_default() -> Self
Create a new Lightning Network instance with default configuration
Source§impl LightningNetwork
impl LightningNetwork
Sourcepub fn create_invoice(
&self,
amount_sats: u64,
description: &str,
) -> Result<LightningInvoice, Box<dyn Error + Send + Sync>>
pub fn create_invoice( &self, amount_sats: u64, description: &str, ) -> Result<LightningInvoice, Box<dyn Error + Send + Sync>>
Create a payment invoice
Sourcepub fn pay_invoice(
&self,
payment_request: &str,
) -> Result<String, Box<dyn Error + Send + Sync>>
pub fn pay_invoice( &self, payment_request: &str, ) -> Result<String, Box<dyn Error + Send + Sync>>
Pay a lightning invoice
Sourcepub fn open_channel(
&mut self,
remote_pubkey: &str,
capacity: u64,
) -> Result<String, Box<dyn Error + Send + Sync>>
pub fn open_channel( &mut self, remote_pubkey: &str, capacity: u64, ) -> Result<String, Box<dyn Error + Send + Sync>>
Open a lightning channel
Sourcepub fn get_channel_info(
&self,
channel_id: &str,
) -> Result<&LightningChannel, Box<dyn Error + Send + Sync>>
pub fn get_channel_info( &self, channel_id: &str, ) -> Result<&LightningChannel, Box<dyn Error + Send + Sync>>
Get channel information
Sourcepub fn get_balance(
&self,
_asset_id: &str,
) -> Result<u64, Box<dyn Error + Send + Sync>>
pub fn get_balance( &self, _asset_id: &str, ) -> Result<u64, Box<dyn Error + Send + Sync>>
Get balance for an asset
Sourcepub fn get_balance_by_asset(
&self,
asset_id: &str,
) -> Result<u64, Box<dyn Error + Send + Sync>>
pub fn get_balance_by_asset( &self, asset_id: &str, ) -> Result<u64, Box<dyn Error + Send + Sync>>
Get the Lightning Network’s balance for a specific asset
Sourcepub fn send(
&mut self,
to: &str,
amount: u64,
_asset_id: &str,
) -> Result<TransactionStatus, Box<dyn Error + Send + Sync>>
pub fn send( &mut self, to: &str, amount: u64, _asset_id: &str, ) -> Result<TransactionStatus, Box<dyn Error + Send + Sync>>
Send payment
Sourcepub fn create_payment_channel(
&mut self,
node_id: &str,
capacity: u64,
) -> Result<String, Box<dyn Error + Send + Sync>>
pub fn create_payment_channel( &mut self, node_id: &str, capacity: u64, ) -> Result<String, Box<dyn Error + Send + Sync>>
Create a payment channel to a node
Sourcepub fn close_payment_channel(
&mut self,
channel_id: &str,
) -> Result<String, Box<dyn Error + Send + Sync>>
pub fn close_payment_channel( &mut self, channel_id: &str, ) -> Result<String, Box<dyn Error + Send + Sync>>
Close a payment channel
Sourcepub fn get_active_channel_count(&self) -> usize
pub fn get_active_channel_count(&self) -> usize
Get the number of active channels
Sourcepub fn get_transaction_status(
&self,
txid: &str,
) -> Result<TransactionStatus, Box<dyn Error + Send + Sync>>
pub fn get_transaction_status( &self, txid: &str, ) -> Result<TransactionStatus, Box<dyn Error + Send + Sync>>
Get transaction status
Trait Implementations§
Source§impl Clone for LightningNetwork
impl Clone for LightningNetwork
Source§fn clone(&self) -> LightningNetwork
fn clone(&self) -> LightningNetwork
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LightningNetwork
impl Debug for LightningNetwork
Source§impl Default for LightningNetwork
impl Default for LightningNetwork
Source§impl Layer2Protocol for LightningNetwork
impl Layer2Protocol for LightningNetwork
fn initialize<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn connect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_state<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<ProtocolState, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn submit_transaction<'life0, 'life1, 'async_trait>(
&'life0 self,
tx_data: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<String, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn check_transaction_status<'life0, 'life1, 'async_trait>(
&'life0 self,
tx_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<TransactionStatus, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn sync_state<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn issue_asset<'life0, 'async_trait>(
&'life0 self,
params: AssetParams,
) -> Pin<Box<dyn Future<Output = Result<String, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn transfer_asset<'life0, 'async_trait>(
&'life0 self,
transfer: AssetTransfer,
) -> Pin<Box<dyn Future<Output = Result<TransferResult, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn verify_proof<'life0, 'async_trait>(
&'life0 self,
proof: Proof,
) -> Pin<Box<dyn Future<Output = Result<VerificationResult, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn validate_state<'life0, 'life1, 'async_trait>(
&'life0 self,
state_data: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<ValidationResult, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§impl Layer2ProtocolTrait for LightningNetwork
impl Layer2ProtocolTrait for LightningNetwork
fn initialize(&self) -> Result<(), Box<dyn Error + Send + Sync>>
fn get_state(&self) -> Result<ProtocolState, Box<dyn Error + Send + Sync>>
fn submit_transaction( &self, _tx_data: &[u8], ) -> Result<String, Box<dyn Error + Send + Sync>>
fn check_transaction_status( &self, _tx_id: &str, ) -> Result<TransactionStatus, Box<dyn Error + Send + Sync>>
fn sync_state(&mut self) -> Result<(), Box<dyn Error + Send + Sync>>
fn issue_asset( &self, _params: AssetParams, ) -> Result<String, Box<dyn Error + Send + Sync>>
fn transfer_asset( &self, _transfer: AssetTransfer, ) -> Result<TransferResult, Box<dyn Error + Send + Sync>>
fn verify_proof( &self, _proof: Proof, ) -> Result<VerificationResult, Box<dyn Error + Send + Sync>>
fn validate_state( &self, _state_data: &[u8], ) -> Result<ValidationResult, Box<dyn Error + Send + Sync>>
Auto Trait Implementations§
impl Freeze for LightningNetwork
impl RefUnwindSafe for LightningNetwork
impl Send for LightningNetwork
impl Sync for LightningNetwork
impl Unpin for LightningNetwork
impl UnwindSafe for LightningNetwork
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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