Compare commits
1 Commits
main
...
pybitmessa
Author | SHA1 | Date | |
---|---|---|---|
d03212d310 |
10
Dockerfile
10
Dockerfile
|
@ -1,7 +1,15 @@
|
||||||
FROM node:16.14.2
|
FROM node:18-bullseye
|
||||||
|
|
||||||
|
RUN apt-get update
|
||||||
|
RUN apt-get install -yq --no-install-suggests --no-install-recommends \
|
||||||
|
build-essential libcap-dev libffi-dev \
|
||||||
|
libssl-dev python-all-dev python-is-python2 python-setuptools python-six
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN git clone https://github.com/Bitmessage/PyBitmessage.git
|
||||||
|
RUN cd PyBitmessage && python setup.py install
|
||||||
|
|
||||||
COPY package.json package.json
|
COPY package.json package.json
|
||||||
COPY package-lock.json package-lock.json
|
COPY package-lock.json package-lock.json
|
||||||
|
|
||||||
|
|
106
index.js
106
index.js
|
@ -1,68 +1,52 @@
|
||||||
var messages = require('bitmessage').messages;
|
|
||||||
var objects = require('bitmessage').objects;
|
const objects = require('bitmessage').objects,
|
||||||
var Address = require('bitmessage').Address;
|
Address = require('bitmessage').Address;
|
||||||
var TcpTransport = require('bitmessage-transports').TcpTransport;
|
|
||||||
var eccrypto = require("eccrypto");
|
const { spawn } = require('child_process');
|
||||||
|
const { setTimeout } = require('timers');
|
||||||
|
const xmlrpc = require('xmlrpc');
|
||||||
|
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const from = Address.fromPassphrase('loremipsum1');
|
spawn('pybitmessage', ['-t'], {timeout: 31000}).on('close', (code) => {
|
||||||
console.log('[from]', from.encode());
|
spawn('pybitmessage', ['-d'], {timeout: 300000})
|
||||||
console.log('[from sign priv key]', from.signPrivateKey.toString('hex'));
|
});
|
||||||
console.log('[from version]', from.version);
|
|
||||||
console.log('[from stream]', from.stream);
|
const sender = Address.fromRandom(),
|
||||||
console.log('[from behaviour]', from.behavior);
|
recipient = Address.fromPassphrase('test');
|
||||||
const toAddr = Address.fromPassphrase('gru');
|
console.log('sender:', sender.encode());
|
||||||
console.log('[toAddr]', toAddr.encode());
|
console.log('recipient:', recipient.encode());
|
||||||
console.log('[toAddr enc pub key]', toAddr.encPublicKey.toString('hex'));
|
|
||||||
console.log('[toAddr version]', toAddr.version);
|
var msg = await objects.msg.encodePayloadAsync({
|
||||||
console.log('[toAddr stream]', toAddr.stream);
|
|
||||||
console.log('[toAddr ripe]', toAddr.ripe);
|
|
||||||
const encodedMsg = await objects.msg.encodePayloadAsync({
|
|
||||||
ttl: 1800,
|
ttl: 1800,
|
||||||
from: from,
|
from: sender,
|
||||||
to: toAddr,
|
to: recipient,
|
||||||
message: 'hey there!',
|
message: 'The quick brown fox jumps over the lazy dog.',
|
||||||
subject: 'Lorem Ipsum',
|
subject: 'hello',
|
||||||
encoding: 2,
|
encoding: 2,
|
||||||
friend: true,
|
skipPow: true
|
||||||
skipPow: true,
|
|
||||||
});
|
});
|
||||||
const strippedMsg = encodedMsg.slice(8);
|
|
||||||
console.log('[check messages]', strippedMsg);
|
|
||||||
console.log('[check messages]', strippedMsg.toString('hex'));
|
|
||||||
var d = await objects.msg.decodePayloadAsync(encodedMsg, {
|
|
||||||
skipPow: true,
|
|
||||||
identities: toAddr,
|
|
||||||
});
|
|
||||||
console.log('[decoded]', d.message);
|
|
||||||
// const encPublicKey = '04a60f6cd97ecd16768215ef059ccfbb1840b736bcdb0763872ddfeef4c417d2ec8439383ce68de9a2b30ad44e9f0e56a13fc2895a6e41f7cf3757e46181d32dd0';
|
|
||||||
// const encPrivateKey = '2cb5ae4e8cf8c71d1221f5c6c46810b448207cacedd86cc52219c3f107048c10';
|
|
||||||
// const dec = await objects.msg.decPayloadTest(encPrivateKey, e);
|
|
||||||
// console.log('[dec]', dec);
|
|
||||||
// var encObj = encrypted.decode(buf);
|
|
||||||
// resolve(eccrypto.decrypt(privateKey, encObj));
|
|
||||||
|
|
||||||
|
msg = msg.slice(8).toString('hex');
|
||||||
|
console.log('msg:', msg);
|
||||||
|
|
||||||
|
const client = xmlrpc.createClient({
|
||||||
|
host: '127.0.0.1', port: '8442', path: '/',
|
||||||
|
basic_auth: {user: 'username', pass: 'password'}
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(
|
||||||
|
function () {
|
||||||
|
console.log('Sending the msg');
|
||||||
|
|
||||||
|
client.methodCall(
|
||||||
|
'disseminatePreEncryptedMsg', [msg, 1000, 1000],
|
||||||
|
function (error, value) {
|
||||||
|
if (error) {
|
||||||
|
console.error('An error has occurred:', error);
|
||||||
|
} else {
|
||||||
|
console.log('the response was', value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 30000);
|
||||||
})();
|
})();
|
||||||
// var tcp = new TcpTransport({
|
|
||||||
// dnsSeeds: [['bootstrap8444.bitmessage.org', 8444]],
|
|
||||||
// });
|
|
||||||
|
|
||||||
// tcp.bootstrap().then(function (nodes) {
|
|
||||||
// var remoteHost = nodes[0][0];
|
|
||||||
// var remotePort = nodes[0][1];
|
|
||||||
// console.log('Connecting to', nodes[0]);
|
|
||||||
// tcp.connect(remotePort, remoteHost);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// tcp.on('established', function (version) {
|
|
||||||
// console.log('Connection established to', version.userAgent);
|
|
||||||
|
|
||||||
// tcp.on('message', function (command, payload) {
|
|
||||||
// console.log('Got new', command, 'message');
|
|
||||||
// var decoded;
|
|
||||||
// if (command === 'addr') {
|
|
||||||
// decoded = messages.addr.decodePayload(payload);
|
|
||||||
// console.log('Got', decoded.addrs.length, 'node addresses');
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
|
@ -11,7 +11,9 @@
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bignum": "^0.13.1",
|
"bignum": "^0.13.1",
|
||||||
"bitmessage": "^0.6.6",
|
"bitmessage": "git+https://git.bitmessage.org/Bitmessage/bitmessage-js.git#mac",
|
||||||
"bitmessage-transports": "^0.1.4"
|
"nan": "2.15.0",
|
||||||
|
"secp256k1": "3.7.1",
|
||||||
|
"xmlrpc": "1.3.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user