Skip to content
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

feat(getinfo) : specify address inside getinfo #229

Merged
merged 1 commit into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lampo-common/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub use getinfo::GetInfo;
pub mod request {
pub use crate::model::close_channel::request::*;
pub use crate::model::connect::Connect;
pub use crate::model::getinfo::GetInfo;
pub use crate::model::getinfo::*;
pub use crate::model::invoice::request::*;
pub use crate::model::keysend::request::*;
pub use crate::model::new_addr::request::*;
Expand All @@ -25,7 +25,7 @@ pub mod request {
pub mod response {
pub use crate::model::close_channel::response::*;
pub use crate::model::connect::Connect;
pub use crate::model::getinfo::GetInfo;
pub use crate::model::getinfo::*;
pub use crate::model::invoice::response::*;
pub use crate::model::keysend::response::*;
pub use crate::model::new_addr::response::*;
Expand Down
7 changes: 7 additions & 0 deletions lampo-common/src/model/getinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,11 @@ pub struct GetInfo {
pub alias: String,
pub blockheight: u32,
pub lampo_dir: String,
pub address: Vec<NetworkInfo>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct NetworkInfo {
pub address: String,
pub port: u64,
}
14 changes: 14 additions & 0 deletions lampod/src/ln/inventory_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::sync::Arc;

use lampo_common::error;
use lampo_common::json;
use lampo_common::model::response::NetworkInfo;

use super::{LampoChannelManager, LampoPeerManager};
use crate::actions::InventoryHandler;
Expand Down Expand Up @@ -39,6 +40,18 @@ impl InventoryHandler for LampoInventoryManager {
let (_, height) = self.channel_manager.onchain.backend.get_best_block()?;
let blockheight = height.unwrap_or_default();
let lampo_dir = self.channel_manager.conf.root_path.to_string();
// We provide a vector here as there may be other types of address in future like tor and ipv6.
let mut address_vec = Vec::new();
let address = self.channel_manager.conf.announce_addr.clone();
if let Some(addr) = address {
let port = self.channel_manager.conf.port.clone();
// For now we don't iterate as there is only one type of address.
let address_info = NetworkInfo {
address: addr,
port,
};
address_vec.push(address_info);
}
let getinfo = GetInfo {
node_id: self.channel_manager.manager().get_our_node_id().to_string(),
peers: self.peer_manager.manager().list_peers().len(),
Expand All @@ -47,6 +60,7 @@ impl InventoryHandler for LampoInventoryManager {
alias,
blockheight,
lampo_dir,
address: address_vec,
};
let getinfo = json::to_value(getinfo)?;
chan.send(getinfo)?;
Expand Down
Loading