-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from G8XSU/s2-apis
Implement ListChannels and GetNodeInfo Api.
- Loading branch information
Showing
10 changed files
with
252 additions
and
40 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
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
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
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,28 @@ | ||
use ldk_node::Node; | ||
use protos::{BestBlock, GetNodeInfoRequest, GetNodeInfoResponse}; | ||
use std::sync::Arc; | ||
|
||
pub(crate) const GET_NODE_INFO: &str = "GetNodeInfo"; | ||
|
||
pub(crate) fn handle_get_node_info_request( | ||
node: Arc<Node>, _request: GetNodeInfoRequest, | ||
) -> Result<GetNodeInfoResponse, ldk_node::NodeError> { | ||
let node_status = node.status(); | ||
|
||
let best_block = BestBlock { | ||
block_hash: node_status.current_best_block.block_hash.to_string(), | ||
height: node_status.current_best_block.height, | ||
}; | ||
|
||
let response = GetNodeInfoResponse { | ||
node_id: node.node_id().to_string(), | ||
current_best_block: Some(best_block), | ||
latest_wallet_sync_timestamp: node_status.latest_wallet_sync_timestamp, | ||
latest_onchain_wallet_sync_timestamp: node_status.latest_onchain_wallet_sync_timestamp, | ||
latest_fee_rate_cache_update_timestamp: node_status.latest_fee_rate_cache_update_timestamp, | ||
latest_rgs_snapshot_timestamp: node_status.latest_rgs_snapshot_timestamp, | ||
latest_node_announcement_broadcast_timestamp: node_status | ||
.latest_node_announcement_broadcast_timestamp, | ||
}; | ||
Ok(response) | ||
} |
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,15 @@ | ||
use crate::util::proto_adapter::channel_to_proto; | ||
use ldk_node::Node; | ||
use protos::{ListChannelsRequest, ListChannelsResponse}; | ||
use std::sync::Arc; | ||
|
||
pub(crate) const LIST_CHANNELS_PATH: &str = "ListChannels"; | ||
|
||
pub(crate) fn handle_list_channels_request( | ||
node: Arc<Node>, _request: ListChannelsRequest, | ||
) -> Result<ListChannelsResponse, ldk_node::NodeError> { | ||
let channels = node.list_channels().into_iter().map(|c| channel_to_proto(c)).collect(); | ||
|
||
let response = ListChannelsResponse { channels }; | ||
Ok(response) | ||
} |
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
mod api; | ||
mod service; | ||
mod util; | ||
|
||
use crate::service::NodeService; | ||
|
||
|
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
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 @@ | ||
pub(crate) mod proto_adapter; |
Oops, something went wrong.