Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 56
Implement ListChannels and GetNodeInfo Api.#13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,6 +1,52 @@ | ||
| syntax = "proto3"; | ||
| package ldk_node_server; | ||
| // Retrieve the latest node info like `node_id`, `current_best_block` etc. | ||
| // See more: | ||
| // - https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.node_id | ||
| // - https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.status | ||
| message GetNodeInfoRequest { | ||
| } | ||
| message GetNodeInfoResponse { | ||
| // The hex-encoded `node-id` or public key for our own lightning node. | ||
| string node_id = 1; | ||
| // The best block to which our Lightning wallet is currently synced. | ||
| // | ||
| // Should be always set, will never be `None`. | ||
| BestBlock current_best_block = 3; | ||
| // The timestamp, in seconds since start of the UNIX epoch, when we last successfully synced our Lightning wallet | ||
| // to the chain tip. | ||
| // | ||
| // Will be `None` if the wallet hasn’t been synced since the node was initialized. | ||
| optional uint64 latest_wallet_sync_timestamp = 4; | ||
| // The timestamp, in seconds since start of the UNIX epoch, when we last successfully synced our on-chain | ||
| // wallet to the chain tip. | ||
| // | ||
| // Will be `None` if the wallet hasn’t been synced since the node was initialized. | ||
| optional uint64 latest_onchain_wallet_sync_timestamp = 5; | ||
| // The timestamp, in seconds since start of the UNIX epoch, when we last successfully update our fee rate cache. | ||
| // | ||
| // Will be `None` if the cache hasn’t been updated since the node was initialized. | ||
| optional uint64 latest_fee_rate_cache_update_timestamp = 6; | ||
| // The timestamp, in seconds since start of the UNIX epoch, when the last rapid gossip sync (RGS) snapshot we | ||
| // successfully applied was generated. | ||
| // | ||
| // Will be `None` if RGS isn’t configured or the snapshot hasn’t been updated since the node was initialized. | ||
| optional uint64 latest_rgs_snapshot_timestamp = 7; | ||
| // The timestamp, in seconds since start of the UNIX epoch, when we last broadcasted a node announcement. | ||
| // | ||
| // Will be `None` if we have no public channels or we haven’t broadcasted since the node was initialized. | ||
| optional uint64 latest_node_announcement_broadcast_timestamp = 8; | ||
| } | ||
| // Retrieve a new on-chain funding address. | ||
| // See more: https://docs.rs/ldk-node/latest/ldk_node/payment/struct.OnchainPayment.html#method.new_address | ||
| message OnchainReceiveRequest { | ||
| @@ -174,27 +220,27 @@ message ChannelConfig { | ||
| // Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound | ||
| // over the channel. | ||
| // See more: https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html#structfield.forwarding_fee_proportional_millionths | ||
| uint32 forwarding_fee_proportional_millionths = 1; | ||
| optional uint32 forwarding_fee_proportional_millionths = 1; | ||
| // Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, | ||
| // in excess of forwarding_fee_proportional_millionths. | ||
| // See more: https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html#structfield.forwarding_fee_base_msat | ||
| uint32 forwarding_fee_base_msat = 2; | ||
| optional uint32 forwarding_fee_base_msat = 2; | ||
| // The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded | ||
| // over the channel this config applies to. | ||
| // See more: https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html#structfield.cltv_expiry_delta | ||
| uint32 cltv_expiry_delta = 3; | ||
| optional uint32 cltv_expiry_delta = 3; | ||
| // The maximum additional fee we’re willing to pay to avoid waiting for the counterparty’s | ||
| // to_self_delay to reclaim funds. | ||
| // See more: https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html#structfield.force_close_avoidance_max_fee_satoshis | ||
| uint64 force_close_avoidance_max_fee_satoshis = 4; | ||
| optional uint64 force_close_avoidance_max_fee_satoshis = 4; | ||
| // If set, allows this channel’s counterparty to skim an additional fee off this node’s | ||
| // inbound HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users. | ||
| // See more: https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html#structfield.accept_underpaying_htlcs | ||
| bool accept_underpaying_htlcs = 5; | ||
| optional bool accept_underpaying_htlcs = 5; | ||
| // Limit our total exposure to potential loss to on-chain fees on close, including | ||
| // in-flight HTLCs which are burned to fees as they are too small to claim on-chain | ||
| @@ -259,8 +305,8 @@ message Channel { | ||
| // our counterparty already. | ||
| optional OutPoint funding_txo = 3; | ||
| // The local `user_channel_id` of this channel. | ||
| bytes user_channel_id = 4; | ||
| // The hex-encoded local `user_channel_id` of this channel. | ||
| string user_channel_id = 4; | ||
| // The value, in satoshis, that must always be held as a reserve in the channel for us. This | ||
| // value ensures that if we broadcast a revoked state, our counterparty can punish us by | ||
| @@ -358,7 +404,7 @@ message Channel { | ||
| // claiming at least this value on chain. | ||
| // | ||
| // This value is not included in `inbound_capacity_msat` as it can never be spent. | ||
| optional uint64 counterparty_unspendable_punishment_reserve = 22; | ||
| uint64 counterparty_unspendable_punishment_reserve = 22; | ||
| // Base routing fee in millisatoshis. | ||
| optional uint32 counterparty_forwarding_info_fee_base_msat = 23; | ||
| @@ -378,4 +424,14 @@ message OutPoint { | ||
| // The index of the referenced output in its transaction's vout. | ||
| uint32 vout = 2; | ||
| } | ||
| } | ||
| message BestBlock { | ||
| // The block’s hash | ||
| string block_hash = 1; | ||
| // The height at which the block was confirmed. | ||
| uint32 height = 2; | ||
G8XSU marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.