abstract base class for your c-lightning plugin. It talks to c-lightning through stdin/stdout. It will automatically create methods necessary for working as a plugin for you.
If you want to handle an rpc call from users,
you must implement the rpc handler, and annotate the handler with
PluginJsonRpcMethod
, which is a class that inherits from
StreamJsonRpc.JsonRpcMethod
It will automatically be exposed as an
additional rpc method for c-lightning. The behavior of argument binding etc
can be found at
StreamJsonRpc
's document
IMPORTANT: plugin will use stdin/stdout for communicating with c-lightning, so you must never write naively to stdout in your application's code otherwise json rpc messages will be corrupted.
If you really want to do it, say for logging, use the same synchronized stream for both plugin and your code. i.e.
1: 2: 3: 4: |
|
Or just use stderr (e.g. from Console.Error
)
If you want to subscribe to a notification from c-lightning
(or other plugins), You must implement it with
PluginJsonRpcSubscription
instead of
PluginJsonRpcMethod
.
By using it, the response value is ignored by c-lightning, and the
method is not exposed to an user.
plugins can send notification to c-lightning,
Use SendNotification
method for it.
But before that, you must register the notification topics with constructor
argument to PluginServerBase
, since c-lightning must know the list of
possible topics beforehand.
For other features, e.g. taking cli options, validating c-lightning init message, etc, see corresponding abstract properties or methods.
If you set ObsoleteAttribute
to methods, those will not be shown to users
unless they specify "allow-deprecated-apis" to true.
Hooks are currently unsupported since it is a quite advanced feature. Please send a PR if you really want it.
Constructor | Description |
|
|
Full Usage:
PluginServerBase(topics, logger)
Parameters:
seq<string>
logger : string -> unit
Returns: PluginServerBase
|
|
Full Usage:
PluginServerBase(topics, dynamic)
Parameters:
seq<string>
dynamic : bool
Returns: PluginServerBase
|
|
|
|
|
|
|
|
Full Usage:
PluginServerBase(notificationTopics, dynamic, logDebug)
Parameters:
seq<string>
-
The list of topic names that might be notified to c-lightning by SendNotification
dynamic : bool
-
Is it ok for this plugin to terminate when the c-lightning sends "stop" call. set false if the plugin is critical for an user and it should never stop.
logDebug : string -> unit
-
custom logging function for debug message on startup.
Returns: PluginServerBase
|
|
Instance member | Description |
|
|
Full Usage:
this.Dynamic
Returns: bool
|
|
Full Usage:
this.FeatureBits
Modifiers: abstract |
|
Full Usage:
this.GetClientOutputStream
|
|
|
|
|
|
Full Usage:
this.Init
Parameters:
LightningInitConfigurationDTO
options : Dictionary<string, obj>
Returns: Task<obj>
|
|
Full Usage:
this.InitCore
Parameters:
LightningInitConfigurationDTO
cliOptions : Dictionary<string, obj>
Modifiers: abstract |
When the c-lightning gets ready, it will send you
|
Full Usage:
this.InitializationStatus
|
|
Full Usage:
this.JsonConverters
|
|
Full Usage:
this.JsonRpc
|
|
Full Usage:
this.Network
|
|
Full Usage:
this.Options
Modifiers: abstract |
|
Full Usage:
this.SendNotification
Parameters:
string
arg : 'T
?cancellationToken : CancellationToken
Returns: Task<unit>
|
Send notification to the c-lightning, the
|
Full Usage:
this.StartAsync
Parameters:
CancellationToken
Returns: Task<PluginJsonRpc>
|
|
|
|
Full Usage:
this.StartAsync
Parameters:
PipeWriter
pipeReader : PipeReader
Returns: Task<PluginJsonRpc>
|
|
|
|
Full Usage:
this.StartAsync
Parameters:
Stream
inStream : Stream
ct : CancellationToken
Returns: Task<PluginJsonRpc>
|
|
Full Usage:
this.StartAsync
Parameters:
PipeWriter
reader : PipeReader
cancellationToken : CancellationToken
Returns: Task<PluginJsonRpc>
|
Start listening as a rpc server, returns a task when finish processing "init" message from c-lightning. You can inject streams other than STDIN/STDOUT with parameters. This feature might be useful for testing.
|