@bsv/sdk
Version:
BSV Blockchain Software Development Kit
27 lines • 1.83 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const utils_js_1 = require("../primitives/utils.js");
class ScriptEvaluationError extends Error {
constructor(params) {
const stackHex = params.stackState.map(s => s != null && typeof s.length !== 'undefined' ? (0, utils_js_1.toHex)(s) : (s === null || s === undefined ? 'null/undef' : 'INVALID_STACK_ITEM')).join(', ');
const altStackHex = params.altStackState.map(s => s != null && typeof s.length !== 'undefined' ? (0, utils_js_1.toHex)(s) : (s === null || s === undefined ? 'null/undef' : 'INVALID_STACK_ITEM')).join(', ');
const pcInfo = `Context: ${params.context}, PC: ${params.programCounter}`;
const stackInfo = `Stack: [${stackHex}] (len: ${params.stackState.length}, mem: ${params.stackMem})`;
const altStackInfo = `AltStack: [${altStackHex}] (len: ${params.altStackState.length}, mem: ${params.altStackMem})`;
const ifStackInfo = `IfStack: [${params.ifStackState.join(', ')}]`;
const fullMessage = `Script evaluation error: ${params.message}\nTXID: ${params.txid}, OutputIdx: ${params.outputIndex}\n${pcInfo}\n${stackInfo}\n${altStackInfo}\n${ifStackInfo}`;
super(fullMessage);
this.name = this.constructor.name;
this.txid = params.txid;
this.outputIndex = params.outputIndex;
this.context = params.context;
this.programCounter = params.programCounter;
this.stackState = params.stackState.map(s => s.slice());
this.altStackState = params.altStackState.map(s => s.slice());
this.ifStackState = params.ifStackState.slice();
this.stackMem = params.stackMem;
this.altStackMem = params.altStackMem;
}
}
exports.default = ScriptEvaluationError;
//# sourceMappingURL=ScriptEvaluationError.js.map