bitclimb-ipc
- Bitclimb messaging socket library for listening to notifications from other local processes such as Bitcoin wallet's
blocknotify
. - Supports
IPC(Unix Socket
),Tcp
andUdp
- Installation
npm install bitclimb-ipc --save
- Supports messaging via Bash shell
netcap
ornc
note: all data from clients are on buffer
format. You can convert it to regular text using data.toString()
Usage
// server-side codeconst bipc = ;const sock = bipc //using unix socket, fastest compared to tcp and udpconst sockpath = '/tmp/myunix.sock'; // most events/api from Nodejs Net class are available https://nodejs.org/api/net.html#net_class_net_socket // via events with callback sock; // via pure events// register listeners firstconst onConnect = { client;}const onReady = { iferr throw err sock sock;}socksock;
Sending a message from shell command/terminal
echo 'hello' | nc -U /tmp/myunix.sock# or echo 'hello' | netcat -U /tmp/myunix.sock # you can also send an encrypted message via password or gpg # using aes-256-cbc echo 'test' | openssl aes-256-cbc -e -k 'password' -a -nosalt | xargs -L 1 echo | nc -U /tmp/unix.sock
Sample Bitcoin-qt blocknotify
//server.jsconst socket = ;const sock = const sockpath = '/tmp/btcnotify.sock'; const onConnect = { client;}const onReady = { iferr throw err sock}socksock;
# bitcoin.conf # ...other configs blocknotify=echo %s | nc -U /tmp/myunix.sock
# you can also send it as a JSON string printf for escaping blocknotify=printf '{"type":"block","txid": "%s"}' | nc -U /tmp/unix.sock