Skip to content

Network RPCs: getaddednodeinfo, addpeeraddress, getnodedaddresses e getaddrmaninfo.#916

Open
jaoleal wants to merge 4 commits intogetfloresta:masterfrom
jaoleal:rpcsaga_fournetworkrpcs
Open

Network RPCs: getaddednodeinfo, addpeeraddress, getnodedaddresses e getaddrmaninfo.#916
jaoleal wants to merge 4 commits intogetfloresta:masterfrom
jaoleal:rpcsaga_fournetworkrpcs

Conversation

@jaoleal
Copy link
Copy Markdown
Collaborator

@jaoleal jaoleal commented Mar 27, 2026

Description and Notes

These already had the needed subsystems and theyre pretty usefull.

How to verify the changes you have done?

Review the tests and propose exercise extensions whether it applies.

jaoleal added 4 commits March 26, 2026 15:56
Add getaddednodeinfo RPC that returns information about manually added
nodes, including whether each is currently connected.
Cross-references added_peers with active peer connections.

Includes integration test and Python RPC wrapper.
Add addpeeraddress RPC that manually adds a peer address to the address
manager. Accepts address, port, and optional tried parameter. Constructs
a LocalAddress with WITNESS|NETWORK_LIMITED services and pushes it to
AddressMan. Also adds address_count() helper to AddressMan.

Includes integration test and Python RPC wrapper.
Add getnodeaddresses RPC that returns known peer addresses from the
address manager. Accepts an optional count parameter and optional network
filter (ipv4, ipv6, onion, i2p, cjdns).

Includes integration test and Python RPC wrapper.
Add getaddrmaninfo RPC that returns address manager statistics broken
down by network type (ipv4, ipv6, cjdns). Each network
reports total, new (untried), and tried address counts. Adds
get_addrman_info() aggregation method to AddressMan.

Includes integration test and Python RPC wrapper.
@jaoleal jaoleal force-pushed the rpcsaga_fournetworkrpcs branch from ea030cf to 9f84eb4 Compare March 27, 2026 16:34
@moisesPompilio moisesPompilio self-requested a review March 27, 2026 17:33
@luisschwab
Copy link
Copy Markdown
Member

Can you add a changelog to the PR description?

@jaoleal jaoleal mentioned this pull request Apr 2, 2026
3 tasks
@moisesPompilio moisesPompilio added the ecosystem support Enable interoperability, compatibility and practical integration with the broader Bitcoin ecosystem label Apr 2, 2026
Comment on lines +126 to +131
pub(crate) async fn get_added_node_info(&self) -> Result<Vec<AddedNodeInfo>> {
self.node
.get_added_node_info()
.await
.map_err(|e| JsonRpcError::Node(e.to_string()))
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jaoleal ..looking at the RPC docs for bitocoin core, https://bitcoincore.org/en/doc/30.0.0/rpc/network/getaddednodeinfo/ the rpc endpoint is meant to take the node address and return info for that address else it returns node information for all nodes...

Image

Comment on lines +360 to +363
"getaddednodeinfo" => state
.get_added_node_info()
.await
.map(|v| serde_json::to_value(v).unwrap()),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should take something like let node = get_optional_field(&params, 0, "node", get_string)?;

#[derive(Debug, Clone, Serialize)]
/// Information about a manually added node (via `addnode`).
pub struct AddedNodeInfo {
/// The address of the added node in "ip:port" format.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as @moisesPompilio raised , we need to have the RPCs as close as possible to the core standard which requires only IP without the port

Comment on lines +151 to 156
pub struct AddedNodeInfo {
/// The address of the added node in "ip:port" format.
pub addednode: String,
/// Whether we are currently connected to this node.
pub connected: bool,
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

we are missing the addresses response which is meant to return {address, connected, port} (only when connected)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ecosystem support Enable interoperability, compatibility and practical integration with the broader Bitcoin ecosystem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants