UNPKG

@ecash/lib

Version:

Library for eCash transaction building

31 lines 1.1 kB
"use strict"; // Copyright (c) 2024 The Bitcoin developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. Object.defineProperty(exports, "__esModule", { value: true }); exports.emppScript = void 0; const op_js_1 = require("../op.js"); const opcode_js_1 = require("../opcode.js"); const script_js_1 = require("../script.js"); /** Build an eMPP OP_RETURN script with the given pushdata */ function emppScript(pushdata) { if (pushdata.find(pushdata => pushdata.length == 0) !== undefined) { throw new Error('Pushdata cannot be empty'); } return script_js_1.Script.fromOps([ opcode_js_1.OP_RETURN, opcode_js_1.OP_RESERVED, ...pushdata.map(pushdataOpEmpp), ]); } exports.emppScript = emppScript; function pushdataOpEmpp(pushdata) { if (pushdata.length < opcode_js_1.OP_PUSHDATA1) { return { opcode: pushdata.length, data: pushdata, }; } return (0, op_js_1.pushBytesOp)(pushdata); } //# sourceMappingURL=empp.js.map