Skip to content

Add hook schemas with msggen and crate integration#9058

Open
daywalker90 wants to merge 4 commits intoElementsProject:masterfrom
daywalker90:hook-schemas
Open

Add hook schemas with msggen and crate integration#9058
daywalker90 wants to merge 4 commits intoElementsProject:masterfrom
daywalker90:hook-schemas

Conversation

@daywalker90
Copy link
Copy Markdown
Collaborator

Added schemas for:

  • peer_connected
  • recover
  • commitment_revocation
  • db_write
  • invoice_payment
  • openchannel
  • openchannel2
  • openchannel2_changed
  • openchannel2_sign
  • rbf_channel
  • htlc_accepted
  • rpc_command
  • custommsg
  • onion_message_recv
  • onion_message_recv_secret

Two new primitives JsonObjectOrArray and JsonScalar to represent the raw json passed in rpc_command more cleanly.

Also added new ways to register hooks in cln-plugin, so you can do something like:

Builder::new(tokio::io::stdin(), tokio::io::stdout())
        .hook_typed("peer_connected", peer_connected)
        
async fn peer_connected(
    p: Plugin<()>,
    hook: events::PeerConnectedEvent,
) -> Result<PeerConnectedAction, anyhow::Error> {
    if hook.peer.direction == PeerConnectedPeerDirection::IN {
        log::info!("Got incoming peer connection");
    }
    Ok(PeerConnectedAction {
        error_message: None,
        result: PeerConnectedResult::CONTINUE,
    })
}

Added schemas for: peer_connected, recover, commitment_revocation, db_write,
invoice_payment, openchannel, openchannel2, openchannel2_changed,
openchannel2_sign, rbf_channel, htlc_accepted, rpc_command, custommsg,
onion_message_recv and onion_message_recv_secret

Changelog-None
…arameters

We use it later for the `rpc_command` hook

Changelog-None
@daywalker90 daywalker90 requested a review from cdecker as a code owner April 14, 2026 14:48
@daywalker90 daywalker90 added this to the 26.06 milestone Apr 14, 2026
hooks are not for grpc, so we create a new object "rpc-only-enum-map" in .msggen.json
and don't generate any grpc related code

Changelog-None
We can now make practical use of the generated code from the hook schemas.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant