@ckb-ccc/core
Version:
Core of CCC - CKBer's Codebase
27 lines (26 loc) • 756 B
JavaScript
import { bech32 } from "bech32";
import { hexFrom } from "../../hex/index.js";
import { SignerNostr } from "./signerNostr.js";
/**
* Signer from Nostr public key
* Support npub and hex format
*/
export class SignerNostrPublicKeyReadonly extends SignerNostr {
constructor(client, publicKey) {
super(client);
if (typeof publicKey === "string" && publicKey.startsWith("npub")) {
const { words } = bech32.decode(publicKey);
this.publicKey = hexFrom(bech32.fromWords(words));
}
else {
this.publicKey = hexFrom(publicKey);
}
}
async connect() { }
async isConnected() {
return true;
}
async getNostrPublicKey() {
return this.publicKey;
}
}