UNPKG

wallet-storage-client

Version:
26 lines 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseTxScriptOffsets = parseTxScriptOffsets; const sdk_1 = require("@bsv/sdk"); function parseTxScriptOffsets(rawTx) { const br = new sdk_1.Utils.Reader(rawTx); const inputs = []; const outputs = []; br.pos += 4; // version const inputsLength = br.readVarIntNum(); for (let i = 0; i < inputsLength; i++) { br.pos += 36; // txid and vout const scriptLength = br.readVarIntNum(); inputs.push({ vin: i, offset: br.pos, length: scriptLength }); br.pos += scriptLength + 4; // script and sequence } const outputsLength = br.readVarIntNum(); for (let i = 0; i < outputsLength; i++) { br.pos += 8; // satoshis const scriptLength = br.readVarIntNum(); outputs.push({ vout: i, offset: br.pos, length: scriptLength }); br.pos += scriptLength; } return { inputs, outputs }; } //# sourceMappingURL=parseTxScriptOffsets.js.map