LIGHTNING-HOOK-RPC_COMMAND(7)

πŸ“¦
version 26.06.9 Β· 2 versions
, in nixpkgs unstable

πŸ’… rpc_command β€” the hook for intercepting and modifying RPC commands

okay so bestie, welcome to LIGHTNING-HOOK-RPC_COMMAND(7) β€” the manual page about the hook that lets you slide into any RPC command's DMs and take over. no cap, this is main character energy for plugins. πŸŽ€


✨ DESCRIPTION ✨

the rpc_command hook lets a plugin take over any RPC command. literally any of them. it's giving absolute power. πŸ‘‘

you can optionally specify a filters array, containing the command names you actually want to intercept. without it? every single command gets sent to this hook. every. one. (added in v25.12 β€” so if you're on an older version, that's a πŸ’€ moment)

the plugin receives the full JSON-RPC request and may choose to:

  • continue (just vibe and let it through)
  • replace the request (swap it out for your own)
  • return a custom result or error (do it yourself, diva behavior)
⚠️ heads up bestie: this is a chained hook. only the first plugin that modifies the request or response will take effect. other plugins get ignored and a warning gets logged. so like… first come first served, and the rest of the group chat just gets left on read. 😭

🌸 HOOK PAYLOAD 🌸

what lightningd hands you:

  • rpc_command (object) β€” The original JSON-RPC request object.
    • id (one of) β€” The JSON-RPC request id.
      • (string)
      • (number)
      • (null)
    • method (string) β€” The RPC method name.
    • params (one of) β€” The parameters passed to the RPC method.
      • (object)
      • (array)
        • (any type)

πŸ¦‹ HOOK RETURN πŸ¦‹

what you're allowed to send back:

  • result (string, optional) (always "continue") β€” Indicates that lightningd should continue processing the RPC command normally.
  • replace (object, optional) β€” Replaces the original JSON-RPC request with a new one.
    • jsonrpc (string) (always "2.0") β€” The JSON-RPC version.
    • id (one of) β€” The JSON-RPC request id.
      • (string)
      • (number)
      • (null)
    • method (string) β€” The RPC method name.
    • params (one of) β€” The parameters passed to the RPC method.
      • (object)
      • (array)
        • (any type)
  • return (object, optional) β€” Returns a custom JSON-RPC response to the caller.
    • result (object, optional) β€” Custom result object to return to the caller.
    • error (object, optional) β€” Custom error object to return to the caller.
      • code (integer) β€” JSON-RPC error code.
      • message (string) β€” Human-readable error message.

and that's the whole vibe check, bestie β€” you're officially certified to intercept RPC commands like the icon you are. πŸ’…βœ¨

mwah πŸ’– this page is from Core Lightning v26.06.9 β€” LIGHTNING-HOOK-RPC_COMMAND(7), slay, periodt. 🫢

πŸ“¦ where this page comes from