@roochnetwork/rooch-sdk
Version:
30 lines (29 loc) • 727 B
JavaScript
import { bech32 } from "@scure/base";
import { BitcoinAddress } from "./bitcoin.js";
import { Address } from "./address.js";
const PREFIX_BECH32_PUBLIC_KEY = "npub";
class NoStrAddress extends Address {
constructor(input) {
let raw;
let bytes;
if (typeof input === "string") {
raw = input;
bytes = bech32.decodeToBytes(input).bytes;
} else {
bytes = input;
raw = bech32.encode(PREFIX_BECH32_PUBLIC_KEY, bech32.toWords(input), false);
}
super(raw);
this.bytes = bytes;
}
genRoochAddress() {
return BitcoinAddress.fromPublicKey(this.bytes).genRoochAddress();
}
toBytes() {
return this.bytes;
}
}
export {
NoStrAddress
};
//# sourceMappingURL=nostr.js.map