cln-plugin: Add notification subscriptions and hooks to the plugins

For now hooks are treated identically to rpcmethods, with the
exception of not being returned in the `getmanifest` call. Later on we
can add typed handlers as well.
This commit is contained in:
Christian Decker
2022-02-23 19:00:25 +01:00
committed by Rusty Russell
parent 8c6af21169
commit 60e773239c
4 changed files with 141 additions and 75 deletions

View File

@@ -12,50 +12,49 @@ pub(crate) enum Request {
// Builtin
Getmanifest(GetManifestCall),
Init(InitCall),
// Hooks
PeerConnected,
CommitmentRevocation,
DbWrite,
InvoicePayment,
Openchannel,
Openchannel2,
Openchannel2Changed,
Openchannel2Sign,
RbfChannel,
HtlcAccepted,
RpcCommand,
Custommsg,
OnionMessage,
OnionMessageBlinded,
OnionMessageOurpath,
// PeerConnected,
// CommitmentRevocation,
// DbWrite,
// InvoicePayment,
// Openchannel,
// Openchannel2,
// Openchannel2Changed,
// Openchannel2Sign,
// RbfChannel,
// HtlcAccepted,
// RpcCommand,
// Custommsg,
// OnionMessage,
// OnionMessageBlinded,
// OnionMessageOurpath,
// Bitcoin backend
Getchaininfo,
Estimatefees,
Getrawblockbyheight,
Getutxout,
Sendrawtransaction,
// Getchaininfo,
// Estimatefees,
// Getrawblockbyheight,
// Getutxout,
// Sendrawtransaction,
}
#[derive(Deserialize, Debug)]
#[serde(tag = "method", content = "params")]
#[serde(rename_all = "snake_case")]
pub(crate) enum Notification {
ChannelOpened,
ChannelOpenFailed,
ChannelStateChanged,
Connect,
Disconnect,
InvoicePayment,
InvoiceCreation,
Warning,
ForwardEvent,
SendpaySuccess,
SendpayFailure,
CoinMovement,
OpenchannelPeerSigs,
Shutdown,
// ChannelOpened,
// ChannelOpenFailed,
// ChannelStateChanged,
// Connect,
// Disconnect,
// InvoicePayment,
// InvoiceCreation,
// Warning,
// ForwardEvent,
// SendpaySuccess,
// SendpayFailure,
// CoinMovement,
// OpenchannelPeerSigs,
// Shutdown,
}
#[derive(Deserialize, Debug)]
@@ -128,6 +127,8 @@ pub(crate) struct RpcMethod {
pub(crate) struct GetManifestResponse {
pub(crate) options: Vec<ConfigOption>,
pub(crate) rpcmethods: Vec<RpcMethod>,
pub(crate) subscriptions: Vec<String>,
pub(crate) hooks: Vec<String>,
}
#[derive(Serialize, Default, Debug)]