cln-plugin-js

1.8.0 • Public • Published

Example Usage

#!/usr/bin/env node

import Plugin from "./plugin.js";
import FileLogger from "./file-logger.js";

const allNotifications = [
	`channel_opened`,
	`channel_open_failed`,
	`channel_state_changed`,
	`connect`,
	`disconnect`,
	`invoice_payment`,
	`invoice_creation`,
	`forward_event`,
	`sendpay_success`,
	`sendpay_failure`,
	`coin_movement`,
	`balance_snapshot`,
	`block_added`,
	`openchannel_peer_sigs`,
	`shutdown`
]

const plugin = new Plugin({ dynamic: true })
const logger = new FileLogger('[Example]')

plugin.addMethod("testinfo", "get info", "description", async () => {
	return await plugin.rpc.call("getinfo")
})


allNotifications.forEach(notification => {
	plugin.subscribe(notification, (params) => {
		logger.log(`Received notification: ${notification}`)
		logger.log(`Params: ${JSON.stringify(params)}`)
	})
})

plugin.start()

Readme

Keywords

none

Package Sidebar

Install

npm i cln-plugin-js

Weekly Downloads

1

Version

1.8.0

License

MIT

Unpacked Size

9.14 kB

Total Files

6

Last publish

Collaborators

  • joelklabo