UNPKG

@muirglacier/testcontainers

Version:

A collection of TypeScript + JavaScript tools and libraries for DeFi Blockchain developers to build decentralized finance for Bitcoin

51 lines 1.92 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SPV = void 0; /** * SPV RPCs(test purposes only) for Bitcoin blockchain */ class SPV { constructor(client) { this.client = client; this.assummedSpvHeight = 0; } /** * Funds a Bitcoin address with 1 BTC(for test purposes only) * * @param {number} address A bitcoin address * @return {string} txid */ fundAddress(address) { return __awaiter(this, void 0, void 0, function* () { return yield this.client.call('spv_fundaddress', [address]); }); } /** * Set last processed block height. * * @param {number} height BTC chain height */ setLastHeight(height) { return __awaiter(this, void 0, void 0, function* () { this.assummedSpvHeight = height; return yield this.client.call('spv_setlastheight', [height]); }); } increaseSpvHeight(height = SPV.EXPIRATION) { return __awaiter(this, void 0, void 0, function* () { return yield this.setLastHeight(this.assummedSpvHeight + height); }); } } exports.SPV = SPV; SPV.EXPIRATION = 10; //# sourceMappingURL=SPV.js.map