UNPKG

scrypt-ts

Version:

A toolset for building sCrypt smart contract applications on Bitcoin SV network written in typescript.

80 lines 2.68 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.P2PK = void 0; const scryptlib_1 = require("scryptlib"); const contract_1 = require("../contract"); const decorators_1 = require("../decorators"); const functions_1 = require("./functions"); const types_1 = require("./types"); class P2PK extends contract_1.SmartContract { constructor(pubKey) { super(...arguments); this.pubKey = pubKey; } unlock(sig) { (0, functions_1.assert)(this.checkSig(sig, this.pubKey), 'signature check failed'); } get lockingScript() { return new scryptlib_1.bsv.Script('') .add(scryptlib_1.bsv.Script.fromASM(this.pubKey)) .add(scryptlib_1.bsv.Opcode.OP_CHECKSIG); } } exports.P2PK = P2PK; __decorate([ (0, decorators_1.prop)(), __metadata("design:type", String) ], P2PK.prototype, "pubKey", void 0); __decorate([ (0, decorators_1.method)(), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], P2PK.prototype, "unlock", null); const desc = { version: 9, compilerVersion: '1.19.0+commit.72eaeba', contract: 'P2PK', md5: '0c046dfb1f1a91cf72b9a852537bdfe1', structs: [], library: [], alias: [], abi: [ { type: 'function', name: 'unlock', index: 0, params: [ { name: 'sig', type: 'Sig', }, ], }, { type: 'constructor', params: [ { name: 'pubKey', type: 'PubKey', }, ], }, ], stateProps: [], buildType: 'release', file: '', hex: '<pubKey>ac', sourceMapFile: '', }; P2PK.loadArtifact(desc); //# sourceMappingURL=p2pk.js.map