@node-lightning/wire
Version:
Lightning Network Wire Protocol
34 lines • 834 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Checksum = void 0;
const checksum_1 = require("@node-lightning/checksum");
/**
* CRC32C checksum for the provided value
*/
class Checksum {
constructor(checksum) {
this._checksum = checksum;
}
static fromBuffer(buf) {
return new Checksum(checksum_1.crc32c(buf));
}
static empty() {
return new Checksum(0);
}
equals(other) {
return this._checksum === other._checksum;
}
toNumber() {
return this._checksum;
}
toBuffer() {
const buf = Buffer.alloc(4);
buf.writeUInt32BE(this._checksum, 0);
return buf;
}
toString() {
return this._checksum.toString(16);
}
}
exports.Checksum = Checksum;
//# sourceMappingURL=Checksum.js.map