|
1 | 1 | import 'package:cln_plugin_api/cln_plugin.dart';
|
2 | 2 |
|
3 | 3 | class KrakenPlugin extends Plugin {
|
4 |
| - /// Here we extend the base Plugin class of our API. This is the |
5 |
| - /// backbone of our plugin. All interactions with and by the plugin |
6 |
| - /// are done here. |
7 |
| - Future<Map<String, Object>> rpcMethod( |
| 4 | + Future<Map<String, Object>> krakenDoctor( |
8 | 5 | Plugin plugin, Map<String, Object> request) {
|
9 | 6 | log(level: "info", message: "RPC Method call.");
|
10 | 7 | return Future.value({
|
11 | 8 | "greeting": "Hello ${options["name"]!.value.toString()}!",
|
12 | 9 | });
|
13 | 10 | }
|
14 | 11 |
|
15 |
| - Future<Map<String, Object>> notifyMethod( |
| 12 | + Future<Map<String, Object>> krakenPay( |
16 | 13 | Plugin plugin, Map<String, Object> request) {
|
17 |
| - log(level: 'debug', message: 'Notification received!'); |
18 |
| - return Future.value({}); |
19 |
| - } |
20 |
| - |
21 |
| - Future<Map<String, Object>> hookMethod( |
22 |
| - Plugin plugin, Map<String, Object> request) { |
23 |
| - log(level: "info", message: "Hook message."); |
24 |
| - return Future(() => {"result": "continue"}); |
| 14 | + log(level: "info", message: "RPC Method call."); |
| 15 | + return Future.value({ |
| 16 | + "greeting": "Hello ${options["name"]!.value.toString()}!", |
| 17 | + }); |
25 | 18 | }
|
26 |
| - |
27 |
| - /// The important step is to register methods pertaining to our plugin for differed use cases. |
28 |
| - /// The following template demonstrates the standard way of defining a RPC Method, option, hook |
29 |
| - /// and a notification subscription. |
30 | 19 | @override
|
31 | 20 | void configurePlugin() {
|
32 |
| - /// The configurePlugin() override allows developing plugins by simply calling the functions |
33 |
| - /// required for handling the core plugin functionality. These methods allow callbacks that |
34 |
| - /// handle core logic behind the plugins. |
35 | 21 | registerRPCMethod(
|
36 |
| - name: "hello", |
| 22 | + name: "kraken_pay", |
37 | 23 | usage: "",
|
38 | 24 | description:
|
39 | 25 | "This method will greet you and serves as an example of how to register a RPC method.",
|
40 |
| - callback: rpcMethod); |
41 |
| - |
42 |
| - registerOption( |
43 |
| - name: "name", |
44 |
| - type: "string", |
45 |
| - def: "World", |
46 |
| - description: "This is your name and it will be used to greet you.", |
47 |
| - deprecated: false); |
48 |
| - |
49 |
| - registerHook(name: 'rpc_command', callback: hookMethod); |
50 |
| - |
51 |
| - registerSubscriptions(event: 'connect', callback: notifyMethod); |
| 26 | + callback: krakenPay); |
| 27 | + registerRPCMethod( |
| 28 | + name: "kraken_doctor", |
| 29 | + usage: "", |
| 30 | + description: "This method will analyze invoice ", |
| 31 | + callback: krakenDoctor); |
52 | 32 | }
|
53 | 33 | }
|
0 commit comments