-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
41 lines (35 loc) · 1.41 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
console.log("Checking for protobuf")
var protobuf = require("protobufjs");
protobuf.load("protobuf/message.proto", function(err, root) {
if (err)
throw err;
// // Obtain a message type
var Signed = root.lookupType("Signed");
var Packet = root.lookupType("Packet")
var Phase = root.lookupEnum("Phase")
var Coins = root.lookupType("Coins")
var Signatures = root.lookupType("Signatures")
var Message = root.lookupType("Message")
var Address = root.lookupType("Address")
var Registration = root.lookupType("Registration")
var VerificationKey = root.lookupType("VerificationKey")
var EncryptionKey = root.lookupType("EncryptionKey")
var DecryptionKey = root.lookupType("DecryptionKey")
var Hash = root.lookupType("Hash")
var Signature = root.lookupType("Signature")
var Transaction = root.lookupType("Transaction")
var Blame = root.lookupType("Blame")
var Reason = root.lookupEnum("Reason")
var Invalid = root.lookupType("Invalid")
var Inputs = root.lookupType("Inputs")
var Packets = root.lookupType("Packets")
var message = Signed.create({
packet: Packet.create({
fromKey: VerificationKey.create({key: "somekeygoeshere"}),
registration: Registration.create({amount: 1000})
})
});
var packets = Packets.create({packet: [message]})
var buffer = Packets.encode(packets).finish()
console.log(buffer)
});