"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cRequestReceiptForTxReqVersion = void 0;
exports.serializeRequestReceiptForTxReq = serializeRequestReceiptForTxReq;
exports.deserializeRequestReceiptForTxReq = deserializeRequestReceiptForTxReq;
const Helpers_1 = require("./ajv/Helpers");
const AJVSchemaEnum_1 = require("./enum/AJVSchemaEnum");
const TypeIdentifierEnum_1 = require("./enum/TypeIdentifierEnum");
exports.cRequestReceiptForTxReqVersion = 1;
function serializeRequestReceiptForTxReq(stream, inp, root = false) {
    if (root) {
        stream.writeUInt16(TypeIdentifierEnum_1.TypeIdentifierEnum.cRequestReceiptForTxReq);
    }
    stream.writeUInt8(exports.cRequestReceiptForTxReqVersion);
    stream.writeString(inp.txid);
    stream.writeString(inp.timestamp.toString());
}
function deserializeRequestReceiptForTxReq(stream) {
    const version = stream.readUInt8();
    if (version !== exports.cRequestReceiptForTxReqVersion) {
        throw new Error('RequestReceiptForTxReq version mismatch');
    }
    const txid = stream.readString();
    const timestamp = Number(stream.readString());
    const result = { txid, timestamp };
    const errors = (0, Helpers_1.verifyPayload)(AJVSchemaEnum_1.AJVSchemaEnum.RequestReceiptForTxReq, result);
    if (errors && errors.length > 0) {
        throw new Error(`AJV: validation error -> ${errors.join(', ')}`);
    }
    return result;
}
//# sourceMappingURL=RequestReceiptForTxReq.js.map