clplug: Create Core Lightning Plugins

[ bitcoin, bsd3, library, lightning, plugin ] [ Propose Tags ]

Library to create plugins to extend the functionality of Core Lightning daemon.

[Skip to Readme]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS],,,,,,
Change log
Dependencies aeson (<2.1), attoparsec (<0.15), base (>=4.7 && <5), bytestring (<0.12), conduit (<1.4), mtl (<2.3), network (<3.2), text (<1.3) [details]
License BSD-3-Clause
Copyright 2023
Author Taylor Singleton-Fookes
Category bitcoin, lightning, plugin
Home page
Bug tracker
Source repo head: git clone
Uploaded by autonomousorganization at 2023-04-06T15:31:56Z
Downloads 224 total (10 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-04-06 [all 1 reports]

Readme for clplug-

[back to package description]

Core Lightning Plug

Create Core Lightning plugins in haskell.

To get started import the Library by adding it to your projects stack.yaml:

- clplug-

Once the library is imported there are two main imports.

  • Data.Lightning is all of the data types for the manifest, the notification and the hooks.
  • Control.Plugin contains the monadic context and interface to your node.

The steps to create a plugin are:

  • A manifest defines the interface your plugin will have with core lightning.
import Data.Aeson
import Data.Lightning
manifest = object [
       "dynamic" .= True
     , "subscriptions" .= ([] :: [Text] )
     , "options" .= ([]::[Option])
     , "rpcmethods" .= ([
         , RpcMethod "command" "[label]" "description" Nothing False
     , "hooks" .= ([Hook "invoice_payment" Nothing])
     , "featurebits" .= object [ ]
     , "notifications" .= ([]::[Notification])
  • A start function that returns the initial state.
import Control.Plugin 
import Control.Client
start = do 
    (rpcHandle, Init options config) <- ask
    Just response <- lightningCli (Command "getinfo" filter params)
    _ <- liftIO . forkIO $ < service > 
    return < state >
  • An app function runs every time data comes in from the plugin. You define handlers that processes the data. If an id is present that means that core lightning is expecting a response and default node operation or the operation of other plugins may be pending your response. Use release to allow default to continue, reject to abort default behavior, and respond to send a custom response which in the case of custom rpcmethods will pass through back to the user.
app :: (Maybe Id, Method, Params) -> PluginMonad a b
app (Just i, "method", params) = 
    if contition 
        then release i 
        else reject i      
  • Finally use the plugin function to create an executable that can be installed as a plugin!
main :: IO ()
main = plugin manifest start app

tipjar: bc1q5xx9mathvsl0unfwa3jlph379n46vu9cletshr