How do zonefiles get generated off-chain? When you enter records for a .btc domain do they go straight to this endpoint or is the data stored on-chain and then something else generates the offchain zonefile.
I guess what I’m really wondering is if there is some way to generate or retrieve the zonedata from the blockchain itself?
I’m running a node locally and was thinking that would give us the ability to retrieve the zonedata for Stacks based domains (building a resolver)
Zonefiles are transaction attachments. Contract-call transactions in Stacks can be sent with a blob of offchain binary data that all nodes who subscribe to that contract’s attachments will optimistically replicate amongst themselves. Right now, they are by default configured to replicate attachments for contract-calls to BNS. Zonefiles are stored as attachments.
The /v1/names/${name}/zonefile is a legacy API endpoint that the Stacks API service implements for compatibility. You can get the same data by first POST’ing the name and namespace to /v2/map_entry/SP000000000000000000002Q6VF78/bns/name-properties to get the name metadata out of the name-properties map in the BNS contract, extracting the 20-byte zone-file hash from the returned tuple, and then GET’ing /v2/attachments/${zone-file} with the hash (but do note that the API service does this eagerly by instead subscribing to a Stacks node’s event stream in order to build up a table that binds each BNS name to its zone file).
You’ll have to dig into the innards of btc.us to see exactly how it does it, but at a high level the act of looking up a BNS name is the act of querying the node for this data at some point (either lazily as I have described, or eagerly as the API service does it) in order to link each name to its DNS zone file, and from there, generating the appropriate DNS query responses.