Giter Site home page Giter Site logo

nostr-control's Introduction

nostr-control

Formatter Tests

Planned Features:

  • Disable events
  • Only settled forwards
  • Channel summary
  • Routing summary
  • NWC (NIP-47, Nostr Wallet Connect)

Description

nostr-control is a Core Lightning plugin that allows you talk to your node over Nostr DM. It also will send you events from your node over Nostr DMs.

Requirements

Tested with Core Lightning v23.02.2 and Node 18. nostr-control uses the sql lightning-cli method so any version that supports that should work.

Screenshots

Info Channel Summary Create Invoice Pay Invoice Get Address See Forwards New Blocks (etc.)
IMG_2262 IMG_2348 IMG_2258 IMG_2352 IMG_2261 IMG_9AF1D5254260-1 IMG_2258

What can I do with it?

When you first set up nostr-control you will start recieving DMs from your node about events that are happening. By default you will receive all events, but you can change this in the config file.

The events you can receive are:

  • 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

The most interesting thing about nostr-control is that you can communicate with your node. You can respond to it in your DMs and get information about your node. /help will give you a list of commands you can use.

Available Commands:

  • /help - Get a list of commands
  • /info - Get information about your node
  • /channels - Get information about your channels
  • /funds - Get information about your funds
  • /invoice - Create an invoice (pass amount_sats, label, and description)
  • /pay - Pay an invoice (pass bolt11)
  • /address - Get a new address (Bech32)
  • /donate - See how you can donate to the project
  • /issues - Open a GitHub issue
  • /verbose - show everything (including failed forwards)
  • /quiet - show only successful forwards (and payment related events)
  • /silent - show no notifications
  • /version - see the version of nostr-control you are running

How do I set it up?

nostr-control uses Node.js and npm. You can install them from here.

  1. Clone the repo into your plugins directory (DO NOT RUN npm install packages are checked in and there is a modification needed for this to run.)
  2. Set up a config file (config.json) in this project's directory (see below)
  3. Register the plugin with lightningd (https://docs.corelightning.org/docs/a-day-in-the-life-of-a-plugin)

Config File

nostr-control needs some Nostr information to work. Specifically these items:

Required

  • relay - The relays you want to send events to
  • bot_secret - The account that will be sending you DMs
  • your_pubkey - Your pubkey so you will receive the events

Optional

  • verbosity - How much information you want to receive (see above)
  • show_failed_forwards - Whether or not to show failed forwards (see above)

There is an example config in the root directory example-config.json it looks like this. Input your information there and nostr-control will pick it up.

{
  relay: "some_relay",
  bot_secret: "some_secret_key_hex",
  your_pubkey: "your_pub_key_hex",
  verbosity: "verbose",
  show_failed_forwards: true
}

nostr-control also keeps track of it's own settings so you can update things on the fly. Create your config.json in the root directory and it will be picked up.

You probably won't need to change that but that's where things you set while running will be stored.

How do I get my bot secret?

Just create an account on any Nostr app and use the secret key (hex). You can also update the profile picture etc. this way.

Contribute ( please do )

PRs and Issues are welcome. Follow me on Nostr npub19a86gzxctwtz68l8zld2u9y2fjvyyj4juyx8m5geylssrmfj27eqs22ckt or leave me a tip at my lightning address: [email protected]. Can also leave a tip on my site: Klabo.blog

nostr-control's People

Contributors

joelklabo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nostr-control's Issues

Crash

at file:///home/azureuser/.lightning/plugins/nostr-control/node_modules/nostr-dm-bot/nostr-dm-bot.js:62:12
Emitted 'error' event on Socket instance at:

at writeOrBuffer (node:internal/streams/writable:392:12)
at _write (node:internal/streams/writable:333:10)
at Writable.write (node:internal/streams/writable:337:10)
at console.value (node:internal/console/constructor:300:16)
at console.log (node:internal/console/constructor:377:26)
at Socket.<anonymous> (file:///home/azureuser/.lightning/plugins/nostr-control/node_modules/cln-plugin-js/rpc.js:46:15)

Emitted 'error' event on Socket instance at:
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -32,
code: 'EPIPE',
syscall: 'write'
}

Node.js v18.14.2
0x56417fdebbdf send_backtrace
common/daemon.c:33
0x56417fdf5cab status_failed
common/status.c:221
0x56417fdd84f1 master_wait_sync_reply
channeld/channeld.c:978
0x56417fdd9566 send_revocation
channeld/channeld.c:1564
0x56417fddc898 handle_peer_commit_sig
channeld/channeld.c:1726
0x56417fddceb0 peer_in
channeld/channeld.c:2235
0x56417fdde18c main
channeld/channeld.c:4078
0x7f3905d30d8f __libc_start_call_main
../sysdeps/nptl/libc_start_call_main.h:58
0x7f3905d30e3f __libc_start_main_impl
../csu/libc-start.c:392
0x56417fdd7724 ???
???:0
0xffffffffffffffff ???
???:0
at writeOrBuffer (node:internal/streams/writable:392:12)
at _write (node:internal/streams/writable:333:10)
at Writable.write (node:internal/streams/writable:337:10)
at console.value (node:internal/console/constructor:300:16)
at console.log (node:internal/console/constructor:377:26)
at Socket. (file:///home/azureuser/.lightning/plugins/nostr-control/node_modules/cln-plugin-js/rpc.js:46:15)
Emitted 'error' event on Socket instance at:
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -32,
code: 'EPIPE',
syscall: 'write'
}

Node.js v18.14.2
0x56417fdebbdf send_backtrace
common/daemon.c:33
0x56417fdf5cab status_failed
common/status.c:221
0x56417fdd84f1 master_wait_sync_reply
channeld/channeld.c:978
0x56417fdd9566 send_revocation
channeld/channeld.c:1564
0x56417fddc898 handle_peer_commit_sig
channeld/channeld.c:1726
0x56417fddceb0 peer_in
channeld/channeld.c:2235
0x56417fdde18c main
channeld/channeld.c:4078
0x7f3905d30d8f __libc_start_call_main
../sysdeps/nptl/libc_start_call_main.h:58
0x7f3905d30e3f __libc_start_main_impl
../csu/libc-start.c:392
0x56417fdd7724 ???
???:0
0xffffffffffffffff ???
???:0
at writeOrBuffer (node:internal/streams/writable:392:12)
at _write (node:internal/streams/writable:333:10)
at Writable.write (node:internal/streams/writable:337:10)
at console.value (node:internal/console/constructor:300:16)
at console.log (node:internal/console/constructor:377:26)
at Socket. (file:///home/azureuser/.lightning/plugins/nostr-control/node_modules/cln-plugin-js/rpc.js:46:15)
Emitted 'error' event on Socket instance at:
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -32,
code: 'EPIPE',
syscall: 'write'
}

Node.js v18.14.2
0x56417fdebbdf send_backtrace
common/daemon.c:33
0x56417fdf5cab status_failed
common/status.c:221
0x56417fdd84f1 master_wait_sync_reply
channeld/channeld.c:978
0x56417fdd9566 send_revocation
channeld/channeld.c:1564
0x56417fddc898 handle_peer_commit_sig
channeld/channeld.c:1726
0x56417fddceb0 peer_in
channeld/channeld.c:2235
0x56417fdde18c main
channeld/channeld.c:4078
0x7f3905d30d8f __libc_start_call_main
../sysdeps/nptl/libc_start_call_main.h:58
0x7f3905d30e3f __libc_start_main_impl
../csu/libc-start.c:392
0x56417fdd7724 ???
???:0
0xffffffffffffffff ???
???:0
azureuser@satoshi:~/lightning$ ^[[1;2A^[[1;2A^[[1;2A^[[1;2A^[[1;2A^[[1;2A
???:0

at writeOrBuffer (node:internal/streams/writable:392:12)
at _write (node:internal/streams/writable:333:10)
at Writable.write (node:internal/streams/writable:337:10)
at console.value (node:internal/console/constructor:300:16)
at console.log (node:internal/console/constructor:377:26)
at Socket.<anonymous> (file:///home/azureuser/.lightning/plugins/nostr-control/node_modules/cln-plugin-js/rpc.js:46:15)

Emitted 'error' event on Socket instance at:
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -32,
code: 'EPIPE',
syscall: 'write'
}

Node.js v18.14.2
0x56417fdebbdf send_backtrace
common/daemon.c:33
0x56417fdf5cab status_failed
common/status.c:221
0x56417fdd84f1 master_wait_sync_reply
channeld/channeld.c:978
0x56417fdd9566 send_revocation
channeld/channeld.c:1564
0x56417fddc898 handle_peer_commit_sig
channeld/channeld.c:1726
0x56417fddceb0 peer_in
channeld/channeld.c:2235
0x56417fdde18c main
channeld/channeld.c:4078
0x7f3905d30d8f __libc_start_call_main
../sysdeps/nptl/libc_start_call_main.h:58
0x7f3905d30e3f __libc_start_main_impl
../csu/libc-start.c:392
0x56417fdd7724 ???
???:0
0xffffffffffffffff ???
???:0
azureuser@satoshi:~/lightning$ ^[[1;2A^[[1;2A^[[1;2A^[[1;2A^[[1;2A^[[1;2A
???:0

at writeOrBuffer (node:internal/streams/writable:392:12)
at _write (node:internal/streams/writable:333:10)
at Writable.write (node:internal/streams/writable:337:10)
at console.value (node:internal/console/constructor:300:16)
at console.log (node:internal/console/constructor:377:26)
at Socket.<anonymous> (file:///home/azureuser/.lightning/plugins/nostr-control/node_modules/cln-plugin-js/rpc.js:46:15)

Emitted 'error' event on Socket instance at:
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -32,
code: 'EPIPE',
syscall: 'write'
}

Node.js v18.14.2
0x56417fdebbdf send_backtrace
common/daemon.c:33
0x56417fdf5cab status_failed
common/status.c:221
0x56417fdd84f1 master_wait_sync_reply
channeld/channeld.c:978
0x56417fdd9566 send_revocation
channeld/channeld.c:1564
0x56417fddc898 handle_peer_commit_sig
channeld/channeld.c:1726
0x56417fddceb0 peer_in
channeld/channeld.c:2235
0x56417fdde18c main
channeld/channeld.c:4078
0x7f3905d30d8f __libc_start_call_main
../sysdeps/nptl/libc_start_call_main.h:58
0x7f3905d30e3f __libc_start_main_impl
../csu/libc-start.c:392
0x56417fdd7724 ???
???:0
0xffffffffffffffff ???
???:0
azureuser@satoshi:~/lightning$ ^[[1;2A^[[1;2A^[[1;2A^[[1;2A^[[1;2A^[[1;2A
at Socket._writeGeneric (node:net:930:11)
at Socket._write (node:net:942:8)
at writeOrBuffer (node:internal/streams/writable:392:12)
at _write (node:internal/streams/writable:333:10)
at Writable.write (node:internal/streams/writable:337:10)
at console.value (node:internal/console/constructor:300:16)
at console.log (node:internal/console/constructor:377:26)
at Socket. (file:///home/azureuser/.lightning/plugins/nostr-control/node_modules/cln-plugin-js/rpc.js:46:15)
Emitted 'error' event on Socket instance at:
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -32,
code: 'EPIPE',
syscall: 'write'
}

Node.js v18.14.2
0x56417fdebbdf send_backtrace
common/daemon.c:33
0x56417fdf5cab status_failed
common/status.c:221
0x56417fdd84f1 master_wait_sync_reply
channeld/channeld.c:978
0x56417fdd9566 send_revocation
channeld/channeld.c:1564
0x56417fddc898 handle_peer_commit_sig
channeld/channeld.c:1726
0x56417fddceb0 peer_in
channeld/channeld.c:2235
0x56417fdde18c main
channeld/channeld.c:4078
0x7f3905d30d8f __libc_start_call_main
../sysdeps/nptl/libc_start_call_main.h:58
0x7f3905d30e3f __libc_start_main_impl
../csu/libc-start.c:392
0x56417fdd7724 ???
???:0
0xffffffffffffffff ???
???:0

Help with starting with CLN v23.02.2 on RPi

Hi Joelklabo, great project!

Tried to run on a Raspiblitz with CLN v23.02.2

Steps taken:

sudo su - bitcoin
cd /home/bitcoin/cl-plugins-available/
git clone https://github.com/joelklabo/nostr-control
# filled in the config.json
chmod +x /home/bitcoin/cl-plugins-available/nostr-control/nostr-control.js
lightning-cli plugin start /home/bitcoin/cl-plugins-available/nostr-control/nostr-control.js

# same when using in the config file:
plugin=/home/bitcoin/cl-plugins-available/nostr-control/nostr-control.js

Results in:

{
   "code": -3,
   "message": "/home/bitcoin/cl-plugins-available/nostr-control/nostr-control.js: exited before replying to getmanifest"
}

and in sudo journalctl -fu lightning

May 05 16:13:40 raspberrypi systemd[1]: Started c-lightning daemon on mainnet.
May 05 16:13:48 raspberrypi sh[2021513]: <--- Last few GCs --->
May 05 16:13:48 raspberrypi sh[2021513]: <--- JS stacktrace --->
May 05 16:13:48 raspberrypi sh[2021513]: #
May 05 16:13:48 raspberrypi sh[2021513]: # Fatal javascript OOM in MemoryChunk allocation failed during deserialization.
May 05 16:13:48 raspberrypi sh[2021513]: #

Are there steps I am missing?
I presume dependencies would need to be installed, but npm install does not work as noted in the readme.

Improve Installation Process

#6 to make it easier to debug what is going on add a few things:

  • versioning (at least log it somewhere)
  • logs should also go to the main plugin log

invoice_creation ReferenceError

[5/3/2023, 9:45:16 AM] [nstrctrl] [plugin] received message:
[5/3/2023, 9:45:16 AM] [nstrctrl] [plugin] {"jsonrpc":"2.0","method":"invoice_creation","params":{"invoice_creation":{"msat":"10000msat","preimage":"96bc1dfedcac505e7397b99098386299f97f4d2b81a9c5ffb955dcefd7c2c627","label":"a4409ca814bb693253a441c351a2e719"}}}
[5/3/2023, 9:45:16 AM] [nstrctrl] notification received: invoice_creation
[5/3/2023, 9:45:16 AM] [nstrctrl] formatting error: ReferenceError: info is not defined

Crash

      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at afterWriteDispatched (node:internal/stream_base_commons:160:15)
    at writeGeneric (node:internal/stream_base_commons:151:3)
    at Socket._writeGeneric (node:net:930:11)
    at Socket._write (node:net:942:8)
    at writeOrBuffer (node:internal/streams/writable:392:12)
    at _write (node:internal/streams/writable:333:10)
    at Writable.write (node:internal/streams/writable:337:10)
    at FileLogger._logStdOut (file:///home/azureuser/.lightning/plugins/nostr-control/node_modules/cln-file-logger/index.js:82:20)
    at FileLogger._log (file:///home/azureuser/.lightning/plugins/nostr-control/node_modules/cln-file-logger/index.js:59:10)
    at FileLogger.logError (file:///home/azureuser/.lightning/plugins/nostr-control/node_modules/cln-file-logger/index.js:40:8)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}

Node.js v18.14.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.