A proper sample
This commit is contained in:
parent
43ba487d67
commit
d97ea82c1f
51
index.js
51
index.js
|
@ -5,34 +5,39 @@ var TcpTransport = require('bitmessage-transports').TcpTransport;
|
||||||
var eccrypto = require("eccrypto");
|
var eccrypto = require("eccrypto");
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
|
const sender = Address({
|
||||||
|
version: 2, stream: 1,
|
||||||
|
signPrivateKey: Buffer.from(
|
||||||
|
'93d0b61371a54b53df143b954035d612f8efa8a3ed1cf842c2186bfd8f876665', 'hex'
|
||||||
|
),
|
||||||
|
encPrivateKey: Buffer.from(
|
||||||
|
'4b0b73a54e19b059dc274ab69df095fe699f43b17397bca26fdf40f4d7400a3a', 'hex'
|
||||||
|
)}),
|
||||||
|
recipient = Address.fromPassphrase('test');
|
||||||
const from = Address.fromPassphrase('loremipsum1');
|
const from = Address.fromPassphrase('loremipsum1');
|
||||||
console.log('[from]', from.encode());
|
|
||||||
console.log('[from sign priv key]', from.signPrivateKey.toString('hex'));
|
console.log('[sender]', sender.encode());
|
||||||
console.log('[from version]', from.version);
|
console.log('[recipient]', toAddr.encode());
|
||||||
console.log('[from stream]', from.stream);
|
console.log('[recipient enc pub key]', toAddr.encPublicKey.toString('hex'));
|
||||||
console.log('[from behaviour]', from.behavior);
|
console.log('[recipient version]', toAddr.version);
|
||||||
const toAddr = Address.fromPassphrase('gru');
|
console.log('[recipient stream]', toAddr.stream);
|
||||||
console.log('[toAddr]', toAddr.encode());
|
console.log('[recipient ripe]', toAddr.ripe);
|
||||||
console.log('[toAddr enc pub key]', toAddr.encPublicKey.toString('hex'));
|
|
||||||
console.log('[toAddr version]', toAddr.version);
|
var encodedMsg = await objects.msg.encodePayloadAsync({
|
||||||
console.log('[toAddr stream]', toAddr.stream);
|
ttl: 24 * 60 * 60,
|
||||||
console.log('[toAddr ripe]', toAddr.ripe);
|
from: sender,
|
||||||
const encodedMsg = await objects.msg.encodePayloadAsync({
|
to: recipient,
|
||||||
ttl: 1800,
|
message: 'The quick brown fox jumps over the lazy dog.',
|
||||||
from: from,
|
subject: 'hello',
|
||||||
to: toAddr,
|
|
||||||
message: 'hey there!',
|
|
||||||
subject: 'Lorem Ipsum',
|
|
||||||
encoding: 2,
|
encoding: 2,
|
||||||
friend: true,
|
friend: true,
|
||||||
skipPow: true,
|
// skipPow: true,
|
||||||
});
|
});
|
||||||
const strippedMsg = encodedMsg.slice(8);
|
|
||||||
console.log('[check messages]', strippedMsg);
|
console.log('[message]', encodedMsg.toString('hex'));
|
||||||
console.log('[check messages]', strippedMsg.toString('hex'));
|
|
||||||
var d = await objects.msg.decodePayloadAsync(encodedMsg, {
|
var d = await objects.msg.decodePayloadAsync(encodedMsg, {
|
||||||
skipPow: true,
|
// skipPow: true,
|
||||||
identities: toAddr,
|
identities: recipient,
|
||||||
});
|
});
|
||||||
console.log('[decoded]', d.message);
|
console.log('[decoded]', d.message);
|
||||||
// const encPublicKey = '04a60f6cd97ecd16768215ef059ccfbb1840b736bcdb0763872ddfeef4c417d2ec8439383ce68de9a2b30ad44e9f0e56a13fc2895a6e41f7cf3757e46181d32dd0';
|
// const encPublicKey = '04a60f6cd97ecd16768215ef059ccfbb1840b736bcdb0763872ddfeef4c417d2ec8439383ce68de9a2b30ad44e9f0e56a13fc2895a6e41f7cf3757e46181d32dd0';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user