2026-07-29 13:54:34 +02:00
|
|
|
// Browser entry point for the registration flow. Everything the register page
|
|
|
|
|
// needs, and nothing that touches the filesystem or a private key we hold.
|
|
|
|
|
//
|
|
|
|
|
// Bundled by build-web.mjs to site/js/bns-register.js as a plain ES module:
|
|
|
|
|
// <script type="module"> import * as BNS from './js/bns-register.js' </script>
|
|
|
|
|
|
|
|
|
|
export { BuiltInWallet, CHIPNET_PREFIX } from "../lib/wallet-web.js";
|
|
|
|
|
export {
|
|
|
|
|
connect,
|
|
|
|
|
checkAvailability,
|
|
|
|
|
quoteRegistration,
|
|
|
|
|
registerWithBuiltInWallet,
|
|
|
|
|
registerWithExternalWallet,
|
2026-09-07 00:18:19 +02:00
|
|
|
registerTldWithBuiltInWallet,
|
2026-09-07 01:39:16 +02:00
|
|
|
registerTldWithExternalWallet,
|
feat(registrar): 90/10 revenue split — TLD owner earns from name mints
Every second-level name registration under a TLD now routes 90% of the
service fee to whoever holds that TLD's certificate on chain, with 10%
going to the platform address. That's the economic incentive for
minting a TLD: you earn from every name registered under it.
The mechanism, end to end:
1. resolver-web.js fetchTldMap now also records mintScriptHex — the
scriptPubKey of the TREG output that carries each TLD's NFT.
Exported so registrar can decode it into a cashaddr with libauth.
MVP: this is the ORIGINAL owner; NFT transfers after mint are not
traced yet (a follow-up will walk the chain of transfers).
2. registrar.js gains findTldOwnerAddress(client, tld) and
splitServiceFee(sats). The split constants live at the top of the
file (TLD_OWNER_SHARE_NUM/DEN = 90/100) so the ratio moves in one
place. Rounding: BigInt division favours the platform on odd sat
counts so the two shares always sum EXACTLY to the input.
3. quoteRegistration wraps the existing flow: it derives the TLD from
the name, looks up the TLD owner, and if the owner ≠ buyer it asks
buildRegistrationTx to add a second fee output. If the owner
couldn't be resolved (TLD not registered, decode failure) the full
fee stays on the platform address — the buyer still pays the same
amount either way.
4. register-tx.js buildRegistrationTx accepts tldFeeAddress/tldFeeSats
and, when set, emits an extra P2PKH output for the TLD owner. Sits
between the beacon dust and the platform-fee output; outputMap
records .tldOwnerFee so callers can find it. costs also carries
tldOwnerFeeSats and netCostSats includes it.
5. priceSummary in registrar-config splits the 'Service fee' row into
'Service fee — TLD owner (90%)' + 'Service fee — platform (10%)'
whenever tldOwnerFeeSats > 0, with a per-line note explaining
where the money goes.
Bundle: re-exported findTldOwnerAddress + splitServiceFee from
register-entry.js. Rebuilt bns-register.js (~34 kB) and deployed;
cache-buster bumped to ?v=20260908split on portal / admin /
register-flow.js.
Verified live: findTldOwnerAddress('.bch') returns the operator
cashaddr; quoteRegistration('tester42.bch') builds cleanly with a
9,000/1,000 split output pair on a 10,000-sat fee; priceSummary
renders both lines. No regressions on the TLD-mint flow (buyer IS
the TLD owner there — split short-circuits and it stays a single
fee output as before).
2026-09-08 02:42:16 +02:00
|
|
|
findTldOwnerAddress,
|
|
|
|
|
splitServiceFee,
|
2026-07-29 13:54:34 +02:00
|
|
|
setRecordsWithBuiltInWallet,
|
|
|
|
|
setRecordsWithExternalWallet,
|
|
|
|
|
findCertificateUtxo,
|
|
|
|
|
getBalance,
|
|
|
|
|
} from "../lib/registrar.js";
|
|
|
|
|
export { REGISTRAR, priceSummary } from "../registrar-config.js";
|
|
|
|
|
export {
|
|
|
|
|
buildRegistrationTx,
|
2026-09-07 00:18:19 +02:00
|
|
|
buildTldRegistrationTx,
|
2026-07-29 13:54:34 +02:00
|
|
|
buildUpdateTx,
|
|
|
|
|
buildPrepTx,
|
|
|
|
|
hasGenesisInput,
|
|
|
|
|
toWcTransactionObject,
|
|
|
|
|
normalizeName,
|
2026-09-07 00:18:19 +02:00
|
|
|
normalizeTld,
|
2026-07-29 13:54:34 +02:00
|
|
|
displayName,
|
|
|
|
|
payloadBudget,
|
2026-09-07 00:18:19 +02:00
|
|
|
TLD_BEACON,
|
2026-07-29 13:54:34 +02:00
|
|
|
NoGenesisInputError,
|
|
|
|
|
InsufficientFundsError,
|
|
|
|
|
} from "../lib/register-tx.js";
|
|
|
|
|
export { signTransaction, txidOf, txidOfHex } from "../lib/sign-tx.js";
|
2026-08-31 05:40:47 +02:00
|
|
|
export { toTokenAddress, addressToLockingBytecode, addressToScripthash, getUtxos, getUtxosForAddresses, broadcast } from "../lib/chain.js";
|
2026-07-29 13:54:34 +02:00
|
|
|
export { resolveName, buildIndex } from "../lib/resolver-web.js";
|
|
|
|
|
export {
|
|
|
|
|
describeGenesisRequirement,
|
|
|
|
|
pubkeyToAddress,
|
|
|
|
|
pubkeyToLockingBytecode,
|
|
|
|
|
} from "../lib/connect/wallet-session.js";
|
|
|
|
|
export { binToHex, hexToBin } from "@bitauth/libauth";
|
|
|
|
|
export { stringify } from "@bitauth/libauth";
|
|
|
|
|
|
|
|
|
|
// NOT re-exported here on purpose: the WizardConnect and WalletConnect adapters.
|
|
|
|
|
// They are separate bundles (site/js/wizardconnect.js, site/js/walletconnect2.js)
|
|
|
|
|
// that the page dynamic-imports only when the buyer picks that option.
|
|
|
|
|
// - WizardConnect: LGPL-3.0-or-later, must stay separate + unminified (§4d1).
|
|
|
|
|
// - WalletConnect: ~590 kB nobody using the built-in wallet should download.
|