UNPKG

@stacks/cli

Version:
45 lines 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isCLITransactionSigner = exports.getPrivateKeyAddress = exports.CLITransactionSigner = exports.setMaxIDSearchIndex = exports.getMaxIDSearchIndex = void 0; const encryption_1 = require("@stacks/encryption"); const argparse_1 = require("./argparse"); const transactions_1 = require("@stacks/transactions"); let maxIDSearchIndex = argparse_1.DEFAULT_MAX_ID_SEARCH_INDEX; function getMaxIDSearchIndex() { return maxIDSearchIndex; } exports.getMaxIDSearchIndex = getMaxIDSearchIndex; function setMaxIDSearchIndex(index) { maxIDSearchIndex = index; } exports.setMaxIDSearchIndex = setMaxIDSearchIndex; class CLITransactionSigner { constructor(address = '') { this.address = address; this.isComplete = false; } getAddress() { return Promise.resolve().then(() => this.address); } signTransaction(_txIn, _signingIndex) { return Promise.resolve().then(() => { }); } signerVersion() { return 0; } } exports.CLITransactionSigner = CLITransactionSigner; function getPrivateKeyAddress(network, privateKey) { if (isCLITransactionSigner(privateKey)) { return privateKey.address; } const pubKey = (0, transactions_1.privateKeyToPublic)(privateKey); const btcAddress = (0, encryption_1.publicKeyToBtcAddress)(pubKey); return network.coerceAddress(btcAddress); } exports.getPrivateKeyAddress = getPrivateKeyAddress; function isCLITransactionSigner(signer) { return signer.signerVersion !== undefined; } exports.isCLITransactionSigner = isCLITransactionSigner; //# sourceMappingURL=common.js.map