Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/packages/create-dpp-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ npm run connection

### Run the November source candidate

The source candidate adds `npm run go-live` to request publisher registration and check wallet funding and index admission. Its go-live check requires `managed-custody@2`. To use another compatible index, run `npm run connect-index -- --from <file>` with the connection file from its operator. Both commands enable publishing when all checks pass. [Connect an application](../operate/README.md#connect-an-application)
The source candidate adds `npm run go-live` to request publisher registration and check wallet funding and index admission. Its go-live check requires `managed-custody@2`. For hosted testnet, use `NETWORK=test` with `INDEX_URL=https://dpp-overlay-testnet.bsvb.net`. For hosted mainnet, use `NETWORK=main` with `INDEX_URL=https://dpp-overlay-mainnet.bsvb.net`. Confirm the network at `/health` and the custody profile at `/capabilities` before registering. To use another compatible index, run `npm run connect-index -- --from <file>` with the connection file from its operator. Both commands enable publishing when all checks pass. [Connect an application](../operate/README.md#connect-an-application)

## What is included

Expand Down
6 changes: 3 additions & 3 deletions packages/create-dpp-app/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ npm run go-live

One command checks everything a real write needs and names the fix for each failure; nothing reaches the chain until every check passes. In order:

1. **Configuration.** The secrets in `.env` are not placeholders; `INDEX_URL` is set and a hosted index matches `NETWORK` (`https://dpp-overlay-testnet.bsvb.net` is `test`, `https://dpp-overlay.bsvb.net` is `main`); on mainnet, `GS1_PREFIX` is a prefix licensed to you and `PASSPORT_HOST` a host you serve.
1. **Configuration.** The secrets in `.env` are not placeholders; `INDEX_URL` is set and a hosted index matches `NETWORK` (`https://dpp-overlay-testnet.bsvb.net` is `test`, `https://dpp-overlay-mainnet.bsvb.net` is `main`); on mainnet, `GS1_PREFIX` is a prefix licensed to you and `PASSPORT_HOST` a host you serve.
2. **Wallet.** The first run generates `WALLET_ROOT_KEY` into `.env` and prints the publisher key. Back the file up: a root key alone is not a full wallet backup, so read the wallet toolbox's recovery guidance and keep the SQLite file in `local/` on a persistent volume.
3. **Index.** The index answers, serves the same network, and admits under the managed custody profile this app writes.
4. **Registration.** The app signs a registration request with its wallet and sends it to the index's `POST /register`; the index names the publisher key in its policy and answers with the app's two write tokens, which go into `.env`. An index whose operator approves registrations holds the request; run `go-live` again once approved. An index that does not register publishers says so and names `connect-index`.
Expand All @@ -318,13 +318,13 @@ One command checks everything a real write needs and names the fix for each fail

Then `LIVE_PUBLISHING=true` is written and the next write spends real satoshis. Until then, a write is built, checked and admitted as a draft, and aborted before the send, which is the dry run you can rehearse with. `SPEND_CAP_SATOSHIS` refuses writes once the platform has spent that much in a day.

Mainnet needs MongoDB (`docker compose -f deploy/compose.yml --env-file .env up -d mongo`, or a hosted one, in `MONGO_URL`) for sign-in and persistence, a WhatsOnChain API key in `WOC_API_KEY` for the wallet's monitor and the reader, `NETWORK=main` with `INDEX_URL=https://dpp-overlay.bsvb.net`, and your own `PASSPORT_HOST` and `GS1_PREFIX`. Changing an identity secret changes every key derived from it, so decide `BRAND_ROOT_SECRET` and `MANAGED_IDENTITY_SECRET` once.
Mainnet needs MongoDB (`docker compose -f deploy/compose.yml --env-file .env up -d mongo`, or a hosted one, in `MONGO_URL`) for sign-in and persistence, a WhatsOnChain API key in `WOC_API_KEY` for the wallet's monitor and the reader, `NETWORK=main` with `INDEX_URL=https://dpp-overlay-mainnet.bsvb.net`, and your own `PASSPORT_HOST` and `GS1_PREFIX`. Changing an identity secret changes every key derived from it, so decide `BRAND_ROOT_SECRET` and `MANAGED_IDENTITY_SECRET` once.

## Connect an index

An index is where your passports become findable: the app announces every state to it before sending, and readers, including other platforms, look states and their evidence up there. The technology behind it is a BSV overlay service. It admits only states countersigned by a publisher key it names, and it follows this app's custody model. Three routes; this app's Compose file starts only the application database.

**The default index.** `.env` names the hosted testnet index, and `npm run go-live` registers this app with it. Mainnet is `INDEX_URL=https://dpp-overlay.bsvb.net` with `NETWORK=main`, where the operator approves each registration.
**The default index.** `.env` names the hosted testnet index, and `npm run go-live` registers this app with it. Mainnet is `INDEX_URL=https://dpp-overlay-mainnet.bsvb.net` with `NETWORK=main`, where the operator approves each registration.

**Another provider's index.** `npm run connect-index -- --url https://index.example` writes the address and runs the checks; `go-live` then registers if the index registers publishers. A provider that hands out tokens itself: `npm run connect-index -- --url https://index.example --submit-token <t> --callback-token <t>`. Match the wallet's network and the managed custody profile; public lookup access alone is insufficient.

Expand Down
2 changes: 1 addition & 1 deletion packages/create-dpp-app/template/_env.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ BRAND_ROOT_SECRET=
MANAGED_IDENTITY_SECRET=

# The index this app announces passports to and readers look them up in. The default is the
# hosted testnet index (mainnet: https://dpp-overlay.bsvb.net with NETWORK=main). Until
# hosted testnet index (mainnet: https://dpp-overlay-mainnet.bsvb.net with NETWORK=main). Until
# `npm run go-live` has registered the app's publisher key and stored the two tokens below, the
# API runs an index in this process instead. `npm run connect-index` takes another provider's
# address and tokens, or with --from the connection file an index operator wrote with
Expand Down
1 change: 1 addition & 0 deletions packages/create-dpp-app/template/apps/api/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const text = (env: NodeJS.ProcessEnv, name: string): string | undefined => {
/** The hosted indexes and the network each serves: go-live refuses a known host on the other network. */
export const KNOWN_INDEX_HOSTS: Record<string, Network> = {
'dpp-overlay-testnet.bsvb.net': 'test',
'dpp-overlay-mainnet.bsvb.net': 'main',
'dpp-overlay.bsvb.net': 'main',
}

Expand Down
4 changes: 2 additions & 2 deletions packages/create-dpp-app/template/apps/api/src/go-live.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export async function goLive(options: GoLiveOptions): Promise<GoLiveResult> {
}
const known = host == null ? undefined : KNOWN_INDEX_HOSTS[host]
if (known != null && known !== config.network) {
fail('configuration', `${host} serves ${known} and NETWORK is ${config.network}`, `set NETWORK=${known} for that index, or INDEX_URL to the ${config.network} index (${config.network === 'test' ? 'https://dpp-overlay-testnet.bsvb.net' : 'https://dpp-overlay.bsvb.net'})`)
fail('configuration', `${host} serves ${known} and NETWORK is ${config.network}`, `set NETWORK=${known} for that index, or INDEX_URL to the ${config.network} index (${config.network === 'test' ? 'https://dpp-overlay-testnet.bsvb.net' : 'https://dpp-overlay-mainnet.bsvb.net'})`)
}
}
if (config.network === 'main') {
Expand Down Expand Up @@ -141,7 +141,7 @@ export async function goLive(options: GoLiveOptions): Promise<GoLiveResult> {
registrationMode = (document.profiles?.find((p) => p.kind === 'operator')?.options?.registration as string | undefined) ?? 'off'
publisherKeys = document.publisherPolicy?.publisherKeys ?? []
if (custodyProfile !== CUSTODY_PROFILE) {
fail('index', `${indexUrl} admits under custody profile ${custodyProfile ?? 'none'} and this app writes under ${CUSTODY_PROFILE}`, 'use an index that declares managed custody (the default indexes and the DPP operator preset do), then run npm run connect-index')
fail('index', `${indexUrl} admits under custody profile ${custodyProfile ?? 'none'} and this app writes under ${CUSTODY_PROFILE}`, `use an index on ${config.network} that advertises ${CUSTODY_PROFILE}, then run npm run connect-index`)
}
} catch (cause) {
fail('index', `${indexUrl} could not be reached: ${describe(cause)}`, 'check the address and that the index is running; to use another index, run npm run connect-index -- --url <index>')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ describe('configuration', () => {

it('knows which network each hosted index serves', () => {
expect(KNOWN_INDEX_HOSTS['dpp-overlay-testnet.bsvb.net']).toBe('test')
expect(KNOWN_INDEX_HOSTS['dpp-overlay-mainnet.bsvb.net']).toBe('main')
expect(KNOWN_INDEX_HOSTS['dpp-overlay.bsvb.net']).toBe('main')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ describe('go-live', () => {
const wrong = await run({ url: 'https://dpp-overlay.bsvb.net' })
expect(failure(wrong.result, 'configuration')?.problem).toMatch(/dpp-overlay\.bsvb\.net.*main/)
expect(wrong.file.WALLET_ROOT_KEY).toBeUndefined()
const wrongTestnet = await run({ url: 'https://dpp-overlay-testnet.bsvb.net' }, { NETWORK: 'main' })
expect(failure(wrongTestnet.result, 'configuration')?.fix).toContain('https://dpp-overlay-mainnet.bsvb.net')
expect(wrongTestnet.file.WALLET_ROOT_KEY).toBeUndefined()
const placeholder = await run({ url: 'https://dpp-overlay-testnet.bsvb.net' }, { AUTH_SECRET: 'change-me-to-32-random-bytes-hex' })
expect(failure(placeholder.result, 'configuration')?.problem).toContain('AUTH_SECRET')
expect(placeholder.lines.join('\n')).not.toContain('change-me-to-32-random-bytes-hex')
Expand Down