Railway deployment of the Pubky marketplace staging payment rails: Lock Server (BitcoinErrorLog/locks, a fork of pubky/locks) + Paykit Server (BitcoinErrorLog/paykit-server, marketplace-rails fork of pubky/paykit-server) + Bitcoin Core regtest + Fulcrum, running real payment mechanics with valueless regtest coins.
This is the hosted version of the locally verified payments-env composed
Docker environment. Every component is pinned to the exact revision /
image digest that passed the full end-to-end payment verification there.
This repo deploys Bitcoin networks side by side: regtest for development, mainnet for the live marketplace rail. The mainnet stacks are watch-only: no component here may hold a Bitcoin private key, seed, mnemonic, or a descriptor containing private material. paykit-server persists account xpubs and derives with Secp256k1::verification_only(); any change that gives it the ability to sign must be refused. A mainnet service may only use a first-party Electrum endpoint; a third-party endpoint, or sharing a database between networks or stack roles, requires owner sign-off and a Kimi audit.
The local payments-env pinned its own pubky-testnet. This deployment does
not. Both servers are configured with network = "mainnet", which makes the
pinned Pubky SDK (pkarr 6.0.1) resolve identities through its default relays
https://pkarr.pubky.app and https://pkarr.pubky.org - the same relays the
official staging Pubky network (homeserver
ufibwbmed6jeq9k4p583go95wofakh9fwpp4k734trq79pd9u1uy /
https://homeserver.staging.pubky.app) publishes through. Users of the
staging pubky-app can therefore act as marketplace sellers (creators) and
buyers (readers) directly against these rails; no separate identity network
exists in this deployment.
| Component | Source | Revision |
|---|---|---|
| Lock Server | BitcoinErrorLog/locks |
53a042826ea9398b16664d7da1af2238962ccde1 |
| Paykit Server | BitcoinErrorLog/paykit-server (marketplace-rails; fork of pubky/paykit-server @ f38c7915e6b9b104e040773e78438f8aa984c46c) |
9687ff07ec4cde7c18970c943d308c6b296a8a42 |
| paykit-rs (build dep) | pubky/paykit-rs |
52a852995bfc457b78d32f5a45f6741766a89bba |
| locks-core (build dep) | pubky/locks |
df5ea1b6d8dcdec3a9b5a915c3f57bca69d75c8a |
| bitcoind | bitcoin/bitcoin:29.1 |
sha256:de62c536feb629bed65395f63afd02e3a7a777a3ec82fbed773d50336a739319 |
| Fulcrum | cculianu/fulcrum:v2.0.0 |
sha256:cb1c006d0cff104696f4791d0f1516699b2c163120165461385e4de206271943 |
The Rust Dockerfiles clone the pinned repos at build time and fail closed if
the checkout does not match the pin. Paykit Server is cloned from the
BitcoinErrorLog/paykit-server fork, not from stock pubky/paykit-server.
The Paykit build additionally runs prepare-local-docker-sources.sh, which
aborts if the supplied trees drift from the dependency pins committed in
paykit-server's manifests.
pubky-app (Vercel) ──HTTPS──► locks-server ──private──► fiat-verifier (gateway)
marketplace-service ──private─► (public domain) │ │
│ signed │ BTC │ USD
│ verbatim ▼ ▼
│ paykit-server Stripe (TEST mode,
│ (public domain: public webhook domain)
│ /setup surface)
│ ▼ electrum
locks-postgres fulcrum ──► bitcoind ◄── miner
paykit-postgres (public TCP proxy (private, RPC)
fiat-postgres for Bitkit)
Since the fiat-rails Phase 1 cutover (2026-08-21) the Lock Server's single
[paykit] server_url names the fiat-verifier gateway
(pubky/pubky-fiat-verifier),
which forwards BTC criteria to paykit-server verbatim (original body +
signature) and settles USD criteria through Stripe test mode. The
post-cutover BTC live purchase was re-proven with this driver the same day.
| Railway service | Built from | Listens | Exposure |
|---|---|---|---|
locks-server |
locks-server/Dockerfile |
[::]:3000 |
public HTTPS domain + private |
fiat-verifier |
pubky-fiat-verifier repo Dockerfile |
[::]:3002 |
public HTTPS domain (Stripe webhooks + buyer checkout-sessions) + private |
paykit-server |
paykit-server/Dockerfile |
[::]:3001 |
public HTTPS domain (setup UI) + private |
bitcoind |
bitcoind/Dockerfile |
[::]:18443 RPC |
private only |
fulcrum |
fulcrum/Dockerfile |
[::]:50001 TCP |
private + public TCP proxy (Bitkit) |
locks-postgres |
Railway managed Postgres | 5432 | private only |
paykit-postgres |
Railway managed Postgres | 5432 | private only |
fiat Postgres (Postgres-sa-c) |
Railway managed Postgres | 5432 | private only |
Inter-service links use Railway private networking
(<service>.railway.internal, IPv6), which is why every listener binds the
IPv6 wildcard.
BITCOIND_RPC_USER,BITCOIND_RPC_PASS- regtest RPC credentials (random, never leave the project).MINE_INTERVAL_SECONDS(default 45) - the entrypoint also runs the block generation loop: it bootstraps the chain to 101 blocks on first run (coin maturity) and then mines one block per interval to a node-held miner wallet so payments confirm without babysitting. The loop lives in this container (not a sidecar) because the image's bitcoin-cli cannot open IPv6 client connections, and Railway private networking is IPv6-only.- Volume mounted at
/data.
BITCOIND_RPC_HOST,BITCOIND_RPC_USER,BITCOIND_RPC_PASSFULCRUM_TCP_BIND(default:::50001, i.e. IPv6 wildcard dual-stack)- Volume mounted at
/data.
LOCKS_KEYPAIR_SEED-keypair-seed:<base64url-no-pad-32B>signing seed. Generated once at deploy time; it IS the Lock Server identity.LOCKS_PUBLIC_KEY-pubky<z-base32>public key derived from the seed.LOCKS_PUBLIC_DOMAIN- the Railway public domain (no scheme); advertised in the server's PKARR record (ICANN HTTPS record, port 443).PUBKY_LOCK_DATABASE_URL- referenceslocks-postgres.PUBKY_LOCK_CREATOR_AUTH_ENCRYPTION_KEY- base64url-no-pad 32B key encrypting creator authority at rest.LOCKS_ALLOWED_RETURN_ORIGINS- comma-separated origins allowed to receive/connectcallback codes (the Vercel app origin).LOCKS_PAYKIT_SERVER_URL(defaulthttp://paykit-server.railway.internal:3001) - currently set tohttp://fiat-verifier.railway.internal:3002: since the fiat-rails Phase 1 cutover (2026-08-21) the Lock Server's payment backend is thefiat-verifiergateway (pubky/pubky-fiat-verifier, deployed in this same Railway project), which proxies BTC criteria verbatim to paykit-server and settlesUSDcriteria through Stripe test mode. Rollback is setting this back to the paykit-server URL and redeploying.LOCKS_PAYKIT_MIN_CONFIRMATIONS(default 1)LOCKS_PKDNS_PUBLIC_IP- advisory A-record IP for the PKARR packet; HTTP clients use the ICANN domain record.LOCKS_GRANT_CONNECT_CLIENT_ID(optional) - the Lock Server's public hostname. When set, the config ismethod = "grant-connect"withgrant_connect.client_idandgrant_connect.allowed_return_origins(theLOCKS_ALLOWED_RETURN_ORIGINSlist; the entrypoint refuses to start if that list is blank after trimming), and/connectoffers a singlesignin_grantlink that Bitkit and Pubky Ring 2.0+ approve (Bitkit shows this value as the requesting app); there is no cookie link. Unset, the config ismethod = "legacy-connect"with nogrant_connectsection and/connectis cookie-only. Switching a deployment to grant connect means creators with a stored cookie authority reconnect once. Only Lock Server builds that knowgrant-connect(pubky/locks) accept this: an image built from the Dockerfile's default pin (the BitcoinErrorLog fork, legacy-connect only) refuses to start with it set. The grant Proof-of-Possession key is derived fromLOCKS_KEYPAIR_SEED, so there is no extra secret; rotating the seed orphans stored grant authorities.LOCKS_RATE_LIMIT_TRUSTED_PROXY_HOPS(optional,0-99) - written as[rate_limits] trusted_proxy_hops. The publicGET /creators/{creator}/authority-statuslimit (120 requests per 60 s per client) keys the NthX-Forwarded-Forvalue from the right and is off while this is unset or0. Read the count first: setPUBKY_LOCK_LOG_FORWARDED_HOP_COUNT=1, request the route, readforwarded_hop_countin the deploy log (the line has no addresses), then delete that variable and set this one to the count. Too many hops lets a client pick its own key; too few puts every client in one bucket.
-
PAYKIT_TRUSTED_LOCKS_PUBLIC_KEY- must equalLOCKS_PUBLIC_KEY. Immutable deployment metadata: if the Lock Server identity is ever rotated, wipe/replacepaykit-postgresin the same operation. -
PAYKIT_DATABASE_URL- referencespaykit-postgres. -
PAYKIT_MASTER_KEY- base64url-no-pad 32B master key. -
PAYKIT_SETUP_ALLOWED_ORIGINS- comma-separated origins for the hosted/setuppage AND the CORS allow-list of the browser-called manual claim routePOST /v0/accounts/claim(the Vercel app origin). -
PAYKIT_ELECTRUM_ENDPOINT(defaulttcp://fulcrum.railway.internal:50001) -
PAYKIT_BITCOIN_NETWORK(defaultregtest) - one ofmainnet,testnet,signet, orregtest. -
PAYKIT_ELECTRUM_POLL_INTERVAL(default1s) - interval matching[0-9]+(ms|s|m); non-regtest networks require at least30s. -
PAYKIT_STACK_ROLE- required on every network; must beproductionorproof. SetPAYKIT_STACK_ROLE=proofon the existing regtest service before pinning paykit-server >= c862005; the server adopts the role once and refuses later mismatches. -
PAYKIT_BITCOIN_CREATION_ENABLED(unset by default) - optional TOML booleantrueorfalsecontrolling Bitcoin creation. -
MARKETPLACE_TRUSTED_PUBLIC_KEY(optional) -pubky<z-base32>public key of the marketplace transaction service's request-signing keypair. When set,x-paykit-signaturerequest signatures by this key are accepted on the signed business routes (/v0/payment-requests,/transactions/status,/invoices) exactly like Lock Server signatures. The transaction service holds the matching ed25519 seed (PAYKIT_REQUEST_SIGNING_KEY). -
MARKETPLACE_TRUSTED_PUBLIC_KEYS(optional) - comma-separated list ofpubky<z-base32>public keys (whitespace tolerated), templated as the TOMLmarketplace.trusted_public_keyslist; every listed key is trusted equally. Mutually exclusive withMARKETPLACE_TRUSTED_PUBLIC_KEY: setting both (or a malformed/empty entry) fails the entrypoint before the server starts. Use the list form to rotate signing keys without downtime (add the new key, cut the service over, remove the old key). Key form note: the paykit-server fork's config parser accepts ONLY the 57-characterpubky-prefixed form (pubky+ 52 z-base-32 chars from the alphabetybndrfg8ejkmcpqxot1uwisza345h769); a bare 52-char key is rejected at server startup, so the entrypoint validator rejects it first. To derive a key's public half from the marketplace-service's hexPAYKIT_REQUEST_SIGNING_KEYseed, use thepaykit-server/tools/derive-marketplace-pubkeytool: it prints ONLY the 57-characterpubky-prefixed public key and zeroizes the seed buffer. Prefer--stdinso the seed never lands in shell history:read -rs PAYKIT_REQUEST_SIGNING_KEY && export PAYKIT_REQUEST_SIGNING_KEY && \ printf '%s' "$PAYKIT_REQUEST_SIGNING_KEY" | \ cargo run --quiet --manifest-path paykit-server/tools/derive-marketplace-pubkey/Cargo.toml -- --stdin; \ unset PAYKIT_REQUEST_SIGNING_KEY
(The tool also still reads
PAYKIT_REQUEST_SIGNING_KEYfrom the environment when--stdinis not passed.) -
PAYKIT_AUTH_RELAY(optional, defaulthttps://httprelay.pubky.app/inbox) - HTTP relay inbox base used by the manual claim session loopback.
The paykit-server image builds from the BitcoinErrorLog/paykit-server fork
(marketplace-rails branch) at 9687ff07ec4cde7c18970c943d308c6b296a8a42,
which adds on top of upstream pubky/paykit-server @ f38c7915:
- network-correct endpoint identifiers, lowercase
"btc"asset, and JSON{"value": address}endpoint payloads (without these, real wallets such as Bitkit silently reject the payment material) POST /v0/accounts/claim- manual watch-only account registration for browser sellers. Body{auth_token, account_xpub, account_index}, whereauth_tokenis the unpadded-base64url serialized Pubky AuthToken whose capabilities exactly match the companion setup capabilities (/pub/paykit/v0/bitkit/server/:rw,/pub/paykit/v0/private/bitkit/server/:rw). The server exchanges the token for a homeserver session through the HTTP relay, publishes the receiver marker, and persists the same encrypted creator record the Bitkit companion flow writes. Re-claims with the same(xpub, account_index)refresh the session; a different account is refused with409 account_mismatch(upstream reauthentication semantics).GET /v0/accounts/{creator}- public{claimed: bool}existence lookup used by the marketplace to report per-seller Bitcoin availability.POST /v0/payment-requests- signed (marketplace key) lock-free payment request creation for physical orders. Body{creator, reader, reference, amount_sats}(canonical JSON, signed like/invoices);referenceis a 26-char Crockford base32 identifier the marketplace also uses asbundle_idin/transactions/statuspolls.[marketplace] trusted_public_keys = [...]config list form (mutually exclusive with the singletrusted_public_key): every listed key is trusted equally for signed-request auth, enabling zero-downtime rotation of the marketplace request-signing key.
No secret is committed to this repo. Driver identity material lives in .env
(see Configuration). All deployment secrets are Railway service
variables, generated fresh at deploy time (openssl rand), distinct from
every local payments-env dev value. The Lock Server seed and the derived
public key live only in Railway variables (plus the operator's offline
records). The marketplace-service consumes LOCKS_SERVER_URL,
LOCKS_BUNDLE_ENCRYPTION_KEY, LOCKS_LOOKUP_HMAC_KEY (fresh 32-byte hex
keys, all-or-nothing fail-closed enablement).
The verification driver (verify/driver.mjs) reads configuration from the
environment. Copy .env.example to .env (gitignored) and run
node --env-file=.env verify/driver.mjs .... Secrets, identities, recovery
files, and device UDIDs have no in-repo defaults; missing required variables
fail fast and name the variable.
| Variable | Required when | Purpose |
|---|---|---|
PUBKY_SDK_REQUIRE |
every driver invocation | Path to a package.json that can resolve @synonymdev/pubky |
STAGING_HOMESERVER |
signup |
Staging homeserver z32 public key |
CREATOR_SECRET_FILE or CREATOR_RECOVERY_FILE |
commands that load the creator keypair | Creator identity |
READER_SECRET_FILE or READER_RECOVERY_FILE |
commands that load the reader keypair | Reader identity |
RECOVERY_PASSWORD |
recovery-file identities | Passphrase for *.pkarr recovery files |
LOCKS_PUBLIC_KEY |
publish |
Deployed Lock Server public key |
LOCKS_SEED_B64URL |
status |
Lock Server signing seed (no keypair-seed: prefix) |
Optional driver overrides: LOCKS_URL, PAYKIT_URL, FIAT_URL,
RETURN_ORIGIN, CREATOR_PUBKY, READER_PUBKY, ASSET, AMOUNT,
GUARDED_PATH, GUARDED_BODY. Wallet-leg operator notes (not read by the
driver) use SELLER_UDID, BUYER_UDID, SELLER_PUBKY, BUYER_PUBKY,
FULCRUM_PUBLIC_HOST, FULCRUM_PUBLIC_PORT, and WALLET_LEG_EVIDENCE_DIR.
Railway service secrets remain Railway variables only; see "Service environment variables" above.
- marketplace-service (same Railway project):
LOCKS_SERVER_URLpoints at the Lock Server over private networking. - pubky-app on Vercel:
PUBKY_RUNTIME_LOCKS_URL= Lock Server public HTTPS URL;PUBKY_RUNTIME_PAYKIT_SETUP_URL= Paykit public HTTPS URL +/setup. - Bitkit (regtest dev build): Electrum endpoint = the Fulcrum public TCP
proxy
host:portrecorded in the deployment notes.
Each service deploys from its subdirectory with the Railway CLI (project
pubky-marketplace-staging, environment production):
railway up --service locks-server --path-as-root locks-server --detach
railway up --service paykit-server --path-as-root paykit-server --detach
railway up --service bitcoind --path-as-root bitcoind --detach
railway up --service fulcrum --path-as-root fulcrum --detachlocks-server can also ship as an immutable image. The Lock Server image
workflow builds locks-server/ (base images pinned by digest) and publishes it
to ghcr.io/bitcoinerrorlog/locks-server only when dispatched on master; the
digest is in the run's publish-evidence.json artifact. Connect it by digest:
railway service source connect --project <project-id> --environment <environment-id> \
--service <locks-server-service-id> \
--image ghcr.io/bitcoinerrorlog/locks-server@sha256:<digest>Rolling back past a locks migration is not supported. The latest are 0010
(0010_creator_authority_refused_at.sql, first in locks 5a984e44) and 0011
(0011_creator_authority_recheck_schedule.sql, first in locks 53a04282).
Every Lock Server image runs its migrations at startup and validates all
applied ones (sqlx::migrate!, ignore_missing: false), so once 0011 has run,
an image that embeds only 0001-0010 fails with VersionMissing(11), and a
Railway deployment rollback to such a deployment does not start. Recovery is
fixing forward: publish and connect a new image that keeps every applied
migration.
Railway's deployment rollback (railway api 'mutation { deploymentRollback(id: "<deployment-id>") }'), which restores a deployment's exact image and custom
variables, applies only between deployments whose images embed the same
migrations. No rebuilt image stands in for a previous deployment: a rebuild of
an older revision is source-equivalent, not byte-identical.
Rebuilding is deterministic: sources are cloned at the pinned revisions during
the image build. To bump a pin, change the ARG default in the service's
Dockerfile and redeploy that service.
State-reset rules (mirror the payments-env volume-coherence note):
- Wiping
paykit-postgresalone is safe (loses invoices/creators; creators re-run setup). - Rotating the Lock Server seed requires wiping BOTH
locks-postgresstate derived from the old identity ANDpaykit-postgres, and updatingPAYKIT_TRUSTED_LOCKS_PUBLIC_KEY- otherwise Paykit rejects every signed call from the new identity. - Wiping the
bitcoindvolume resets the chain; Fulcrum's/datavolume must be wiped with it, and any creator watch-only balances vanish (regtest coins are valueless by design).