> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lumenwipe.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rotate the fee sponsor

> Replace the fee-bump sponsor account and its key: fund the new account to its float, switch the API, drain the old account and keep watching it for 24 hours.

> [!NOTE]
>
> Rehearsed end to end for testnet on the deployed service on 2026-11-17, together with the [relay
> account rotation](https://docs.lumenwipe.com/runbooks/rotate-relay-account.md), with step 10 on 2026-11-18; the [measured
> times](#measured-times) are from that rehearsal. Not yet rehearsed on mainnet.

The fee sponsor pays the network fee, through a CAP-15 fee bump, for an account sitting at its minimum balance. It holds a small operational float and spends it only on fees. Only the API knows it: there is no public-key setting and no client change, so a rotation changes one secret, a repository variable and one row of the [monitoring plan](https://docs.lumenwipe.com/monitoring-plan.md#1-what-are-we-monitoring).

The steps follow the [relay account rotation](https://docs.lumenwipe.com/runbooks/rotate-relay-account.md), with the differences below. `<net>` and `<NET>` mean the same as there, and every step runs in a shell started as that page's steps describe (`set -o pipefail`, a throwaway `XDG_CONFIG_HOME`, the `operator` identity). The same rule on deploy runs applies: hold merges that deploy the API until the last env-only revision of the rotation serves.

## When

* **Compromise**: the key may be exposed, or `S4b.Information.1.M.1` or `S4b.Elevation.1.M.1` fired. Pause sponsorship first.
* **Planned**: skip the pause.

## Blast radius

* Only sponsored fees. Every close that pays its own fees is unaffected, and while sponsorship is paused a plan that needed it reports the blocker before anything is built.
* A fee bump signed by the old sponsor is valid only as long as its inner transaction, at most 330 seconds. Submitted after the drain, the network rejects it because its fee account no longer exists: nothing is applied or charged, and the client asks for a new sponsorship.
* At most the old account's float is at risk; draining it ends that. A testnet sponsor funded through friendbot holds far more than a float: the one retired on 2026-11-17 held about 10,000 XLM, which the drain returned to the operator.

## Steps

1. **Compromise only: pause sponsorship.**

   ```bash theme={null}
   gcloud run services update lumenwipe-api --region us-central1 --update-env-vars=FEE_SPONSORSHIP_ENABLED=false
   ```

   Expected: `Done.`, and `POST $API/v1/<net>/fee-bump/sponsor` answers `503 fee_sponsorship_paused`.

2. **Generate the new key**: `stellar keys generate new-sponsor`, then `stellar keys address new-sponsor`. Expected: a `G...` address, `<new>`.

3. **Create the account with the float**, not more. The balance monitor's floor is 50 XLM, so fund above it:

   ```bash theme={null}
   stellar tx new create-account --source-account operator --destination <new> --starting-balance <float in stroops> --network <net>
   curl -s https://horizon-testnet.stellar.org/accounts/<new> | jq -r '.balances[] | select(.asset_type=="native") | .balance'
   ```

   Expected: the float, in XLM.

4. **Check the binding, pin it, then add the secret as a new version.** If the sponsor secret is bound to `latest`, pin its current version number first, as in [the relay runbook, step 4](https://docs.lumenwipe.com/runbooks/rotate-relay-account.md#steps), which also shows pinning both secrets in one revision when both rotations run together. It was bound to `latest` on the production service at the 2026-11-17 rehearsal.

   ```bash theme={null}
   stellar keys secret new-sponsor | tr -d '\n' | gcloud secrets versions add <sponsor-secret> --data-file=-
   ```

   Expected: `Created version [<n>] of the secret [<sponsor-secret>].`

5. **Switch the API**:

   ```bash theme={null}
   gcloud run services update lumenwipe-api --region us-central1 --update-secrets=FEE_ACCOUNT_SECRET_<NET>=<sponsor-secret>:<n>
   gcloud run services describe lumenwipe-api --region us-central1 --format='yaml(spec.template.spec.containers[0].env)'
   ```

   Expected: `Done.`, the new revision serving 100 percent, and the binding showing version `<n>`. In a compromise, turn `FEE_SPONSORSHIP_ENABLED` back to `true`.

6. **Confirm the new account pays.** On testnet, run the sponsored close through the deployed web app:

   ```bash theme={null}
   APP_URL=https://www.lumenwipe.com FEE_ACCOUNT_ADDRESS_TESTNET=<new> bun run --filter @lumenwipe/api test:sponsor
   ```

   It funds two throwaway accounts through friendbot, sends a zero-fee account merge of one into the other, with a 120-second time bound, to `fee-bump/sponsor`, submits the fee bump it gets back, and reads the transaction from Horizon. Expected: it ends with `PASS: fee_account <new>`; on any failure it prints one `FAIL:` line with the reason and exits non-zero.

   Without the script, the same check by hand: create an account with exactly 1 XLM from the operator, build an `accountMerge` back to the operator with fee 0 and a 120-second time bound, sign it, send it to `POST $API/v1/testnet/fee-bump/sponsor` with a testnet test key, submit the returned envelope, and read the transaction from Horizon. Expected either way: `<new>` as `fee_account`, and the closed account, never `<new>`, as `source_account`. On mainnet there is no scripted check: confirm with the first real sponsored close.

7. **Monitors**, before the drain: set `FEE_ACCOUNT_ADDRESS_<NET>` to `<new>` and `FEE_ACCOUNT_ADDRESS_<NET>_RETIRED` to `<old>`, merge the change to the `Fee-bump sponsor (<net>)` row of the inventory table in the same hour, and run the workflow. The row's proof link cites a fee bump paid by the account it names, so replace it with the fee bump from step 6. As in [the relay runbook, step 7](https://docs.lumenwipe.com/runbooks/rotate-relay-account.md#steps), the same pull request changes `SPONSOR` in `apps/api/tests/unit/service-account-monitors.test.ts`, which makes it deploy the API, and on testnet the playground's `PLAYGROUND_EXPECTED_FEE_ACCOUNT_TESTNET` changes too. Expected: the config step lists `sponsor (<net>): <new>` and `sponsor (retired) (<net>): <old>, drained into <operator address>`, every job succeeds, and the balances step reports only `<new>`.

8. **Wait 6 minutes** after the new revision took traffic, so no fee bump signed by the old key can still land.

9. **Drain the old account** with the operator as the transaction source, exactly as in [the relay runbook, step 9](https://docs.lumenwipe.com/runbooks/rotate-relay-account.md#steps), using an `old-sponsor` identity piped from the previous secret version. Expected: Horizon answers `404` for `<old>` and the float is back with the operator. The next monitor run stays green: the keys check sees no transaction sourced from `<old>`, and the forward check reads this merge into the operator as the drain, while fee bumps `<old>` paid for raise nothing: the keys check does not judge a retired sponsor as `fee_account`, because the window still holds the ones from before the switch. Until the drain and for the rest of the 24 hours, any transaction the old key sources, and any merge or payment out of `<old>` to another address, is reported as a suspected key compromise.

10. **After 24 hours**: `gh variable delete FEE_ACCOUNT_ADDRESS_<NET>_RETIRED`, disable the previous secret version, and `rm -rf "$XDG_CONFIG_HOME"`. Then check that `/health` still answers `200`: the service binds version `<n>`, not the disabled one.

## Measured times

From the testnet rehearsal on the production service, run together with the [relay account rotation](https://docs.lumenwipe.com/runbooks/rotate-relay-account.md#measured-times), which lists the shared steps:

| Step | Time and result |
| - | - |
| 3, `create-account` with a 100 XLM float | Part of about 10 seconds for both rotations' creates (2026-11-17) |
| 4, pin both secrets in one revision | 23 seconds (2026-11-17) |
| 5, switch the sponsor (secret version 2) | 26 seconds (2026-11-17) |
| 6, sponsored close of a 1 XLM account | Fee bump `52cb1ed3…37d0`, with the new sponsor as `fee_account` (2026-11-17), by the manual check before the script existed |
| 9, drain of the old account | About 6 seconds; Horizon answered `404` afterwards (2026-11-17) |
| 10, `_RETIRED` variable removed, version 1 disabled | Done 2026-11-18 at 15:41 UTC; the service binds version 2 of `FEE_ACCOUNT_SECRET_TESTNET`, and `/health` answered afterwards |

## Confirm the fix

* A sponsored transaction shows `<new>` as its `fee_account` (step 6).
* Horizon shows `<old>` as `404`, and the monitors run green with both addresses for 24 hours.
* To roll back before the drain, bind the previous secret version again. After the drain, rotate forward.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.