const objects = require('bitmessage').objects, Address = require('bitmessage').Address; const { spawn } = require('child_process'); const zmq = require('zeromq'); (async () => { const sock = zmq.socket('pub'); sock.bindSync('tcp://127.0.0.1:5566'); console.log('Publisher bound to port 5566'); spawn( 'minode', ['--request-queue', 'tcp://127.0.0.1:5566'], {timeout: 300000, killSignal: 'SIGQUIT'} ).stderr.on('data', (data) => { console.log(`${data}`); }); const sender = Address.fromRandom(), recipient = Address.fromPassphrase('test'); console.log('sender:', sender.encode()); console.log('recipient:', recipient.encode()); var msg = await objects.msg.encodePayloadAsync({ ttl: 1800, from: sender, to: recipient, message: 'The quick brown fox jumps over the lazy dog.', subject: 'hello', encoding: 2, friend: true }); console.log('msg:', msg.toString('hex')); console.log('Sending the msg'); sock.send(Buffer.concat([ Buffer.from('msg', 'ascii'), Buffer.from('00', 'hex'), msg ])); })();