UNPKG

@stacks/bns

Version:

Library for working with the Stacks Blockchain Naming System BNS.

26 lines (23 loc) 567 B
import { utf8ToBytes } from '@stacks/common'; import { hash160 } from '@stacks/transactions'; /** @ignore */ export function decodeFQN(fqdn: string): { name: string; namespace: string; subdomain?: string; } { const nameParts = fqdn.split('.'); if (nameParts.length > 2) { return { subdomain: nameParts[0], name: nameParts[1], namespace: nameParts[2], }; } return { name: nameParts[0], namespace: nameParts[1], }; } /** @ignore */ export const getZonefileHash = (zonefile: string) => hash160(utf8ToBytes(zonefile));