@muirglacier/jellyfish-transaction
Version:
A collection of TypeScript + JavaScript tools and libraries for DeFi Blockchain developers to build decentralized finance for Bitcoin
36 lines • 1.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StaticCode = exports.OPCode = void 0;
/**
* Operation code, script words, opcodes, commands and functions there are many names to this.
* This is essentially things to be pushed into the DeFi scripting stack.
*
* Like bitcoin, it uses a scripting system for transactions.
* Script is simple, stack-based, and processed from left to right.
* It is intentionally none Turing-complete, with no loops.
*
* In jellyfish-transaction, this stack scripting is implemented as class for first class type support.
* This allows instanceof assertions and wraps all data to be pushed into a stack as a an instantiatable object.
*/
class OPCode {
constructor(type) {
this.type = type;
}
}
exports.OPCode = OPCode;
/**
* Statically mapped code of OPCode
*/
class StaticCode extends OPCode {
constructor(code, type) {
super(type);
this.code = code;
}
asBuffer() {
const buffer = Buffer.allocUnsafe(1);
buffer.writeUInt8(this.code);
return buffer;
}
}
exports.StaticCode = StaticCode;
//# sourceMappingURL=opcode.js.map