-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
PurpleTimez
committed
Apr 24, 2024
1 parent
a574b1e
commit 159d063
Showing
3 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
use async_trait::async_trait; | ||
use bitcoin::secp256k1::PublicKey; | ||
use bitcoin::Network; | ||
|
||
use lightning::ln::PaymentHash; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
use triggered::Listener; | ||
|
||
use crate::{ | ||
serializers, LightningError, LightningNode, PaymentResult, NodeId, NodeInfo, | ||
}; | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
pub struct EclairConnection { | ||
#[serde(with = "serializers::serde_node_id")] | ||
pub id: NodeId, | ||
pub address: String, | ||
#[serde(deserialize_with = "serializers::deserialize_path")] | ||
pub ca_cert: String, | ||
#[serde(deserialize_with = "serializers::deserialize_path")] | ||
pub client_cert: String, | ||
#[serde(deserialize_with = "serializers::deserialize_path")] | ||
pub client_key: String, | ||
} | ||
|
||
//TODO: Feels tmp to code real client library to connect with eclair. | ||
struct Client {} | ||
|
||
pub struct EclairNode { | ||
client: Client, | ||
info: NodeInfo, | ||
} | ||
|
||
impl EclairNode { | ||
pub async fn new(connection: EclairConnection) -> Result<Self, LightningError> { | ||
Err(LightningError::ConnectionError("tmp err".to_string())) | ||
} | ||
|
||
async fn node_channels(&mut self, is_source: bool) -> Result<Vec<u64>, LightningError> { | ||
Err(LightningError::ConnectionError("tmp err".to_string())) | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl LightningNode for EclairNode { | ||
fn get_info(&self) -> &NodeInfo { | ||
&self.info | ||
} | ||
|
||
async fn get_network(&mut self) -> Result<Network, LightningError> { | ||
Err(LightningError::ConnectionError("tmp err".to_string())) | ||
} | ||
|
||
async fn send_payment( | ||
&mut self, | ||
dest: PublicKey, | ||
amount_msat: u64, | ||
) -> Result<PaymentHash, LightningError> { | ||
Err(LightningError::ConnectionError("tmp err".to_string())) | ||
} | ||
|
||
async fn track_payment( | ||
&mut self, | ||
hash: &PaymentHash, | ||
shutdown: Listener, | ||
) -> Result<PaymentResult, LightningError> { | ||
Err(LightningError::ConnectionError("tmp err".to_string())) | ||
} | ||
|
||
async fn get_node_info(&mut self, node_id: &PublicKey) -> Result<NodeInfo, LightningError> { | ||
Err(LightningError::ConnectionError("tmp err".to_string())) | ||
} | ||
|
||
async fn list_channels(&mut self) -> Result<Vec<u64>, LightningError> { | ||
Err(LightningError::ConnectionError("tmp err".to_string())) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
use async_trait::async_trait; | ||
use bitcoin::secp256k1::PublicKey; | ||
use bitcoin::Network; | ||
|
||
use lightning::ln::PaymentHash; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
use triggered::Listener; | ||
|
||
use crate::{ | ||
serializers, LightningError, LightningNode, PaymentResult, NodeId, NodeInfo, | ||
}; | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
pub struct LdkConnection { | ||
#[serde(with = "serializers::serde_node_id")] | ||
pub id: NodeId, | ||
pub address: String, | ||
#[serde(deserialize_with = "serializers::deserialize_path")] | ||
pub ca_cert: String, | ||
#[serde(deserialize_with = "serializers::deserialize_path")] | ||
pub client_cert: String, | ||
#[serde(deserialize_with = "serializers::deserialize_path")] | ||
pub client_key: String, | ||
} | ||
|
||
//TODO: Feels tmp to code real client library to connect with ldk. | ||
struct Client {} | ||
|
||
pub struct LdkNode { | ||
client: Client, | ||
info: NodeInfo, | ||
} | ||
|
||
impl LdkNode { | ||
pub async fn new(connection: LdkConnection) -> Result<Self, LightningError> { | ||
Err(LightningError::ConnectionError("tmp err".to_string())) | ||
} | ||
|
||
async fn node_channels(&mut self, is_source: bool) -> Result<Vec<u64>, LightningError> { | ||
Err(LightningError::ConnectionError("tmp err".to_string())) | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl LightningNode for LdkNode { | ||
fn get_info(&self) -> &NodeInfo { | ||
&self.info | ||
} | ||
|
||
async fn get_network(&mut self) -> Result<Network, LightningError> { | ||
Err(LightningError::ConnectionError("tmp err".to_string())) | ||
} | ||
|
||
async fn send_payment( | ||
&mut self, | ||
dest: PublicKey, | ||
amount_msat: u64, | ||
) -> Result<PaymentHash, LightningError> { | ||
Err(LightningError::ConnectionError("tmp err".to_string())) | ||
} | ||
|
||
async fn track_payment( | ||
&mut self, | ||
hash: &PaymentHash, | ||
shutdown: Listener, | ||
) -> Result<PaymentResult, LightningError> { | ||
Err(LightningError::ConnectionError("tmp err".to_string())) | ||
} | ||
|
||
async fn get_node_info(&mut self, node_id: &PublicKey) -> Result<NodeInfo, LightningError> { | ||
Err(LightningError::ConnectionError("tmp err".to_string())) | ||
} | ||
|
||
async fn list_channels(&mut self) -> Result<Vec<u64>, LightningError> { | ||
Err(LightningError::ConnectionError("tmp err".to_string())) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters