@node-lightning/wire
Version:
Lightning Network Wire Protocol
19 lines • 700 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeTor3 = void 0;
const bufio_1 = require("@node-lightning/bufio");
const torStringToBuffer_1 = require("./torStringToBuffer");
/**
* Serializes a Tor v3 address in a Buffer that can be sent
* over the wire.
*/
function serializeTor3(address) {
const writer = new bufio_1.BufferWriter(Buffer.alloc(38));
const hostBytes = torStringToBuffer_1.torStringToBuffer(address.host);
writer.writeUInt8(address.type);
writer.writeBytes(hostBytes);
writer.writeUInt16BE(address.port);
return writer.toBuffer();
}
exports.serializeTor3 = serializeTor3;
//# sourceMappingURL=serializeTor3.js.map