Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { BufferWriter } from "@node-lightning/bufio";
import { AddressTor2 } from "../../domain/AddressTor2";
import { torStringToBuffer } from "./torStringToBuffer";
/**
* Serializes a Tor v2 address in a Buffer that can be sent
* over the wire.
*/
export function serializeTor2(address: AddressTor2): Buffer {
const writer = new BufferWriter(Buffer.alloc(13));
const hostBytes = torStringToBuffer(address.host);
writer.writeUInt8(address.type);
writer.writeBytes(hostBytes);
writer.writeUInt16BE(address.port);
return writer.toBuffer();
}
|