UNPKG

@roochnetwork/rooch-sdk-kit

Version:
69 lines (66 loc) 1.74 kB
// src/wellet/bitcoin.ts import { Authenticator, BitcoinSignMessage, Secp256k1PublicKey, fromHEX } from "@roochnetwork/rooch-sdk"; // src/wellet/wallet.ts import { Signer } from "@roochnetwork/rooch-sdk"; var Wallet = class extends Signer { /** * Checks if the wallet is installed. * @returns A promise that resolves to true if the wallet is installed, otherwise false. */ async checkInstalled() { for (let i = 1; i < 10 && !this.getTarget(); i += 1) { await new Promise((resolve) => setTimeout(resolve, 100 * i)); } return Promise.resolve(this.getTarget() !== void 0); } }; // src/wellet/bitcoin.ts var BitcoinWallet = class extends Wallet { async signTransaction(input) { const message = new BitcoinSignMessage(input.hashData(), input.getInfo() || ""); return Authenticator.bitcoin(message, this, "raw"); } getPublicKey() { if (!this.publicKey) { throw Error("Please connect your wallet first"); } return new Secp256k1PublicKey(fromHEX(this.publicKey)); } getRoochAddress() { if (!this.currentAddress) { throw Error("Please connect your wallet first"); } return this.currentAddress.genRoochAddress(); } getBitcoinAddress() { if (!this.currentAddress) { throw Error("Please connect your wallet first"); } return this.currentAddress; } getKeyScheme() { return "Secp256k1"; } normalize_recovery_id(v) { let normalizeV = v - 27 - 4; if (normalizeV < 0) { normalizeV = normalizeV + 4; } return normalizeV; } switchAccount() { throw new Error("Method not implemented."); } getChain() { return "bitcoin"; } }; export { BitcoinWallet }; //# sourceMappingURL=bitcoin.js.map