mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
Store explicit positions for session macaroon caveats and permissions in the SQL schema and read them back in position order. Also remove the migration-time sorting workaround in session comparison, so migration validation now checks the actual persisted order instead of masking it. This is needed because session caveat order is not just presentation data. LiT adds caveats to the baked macaroon in slice order, and the macaroon library updates the signature hash chain for each added caveat. Reordering caveats can therefore change the resulting macaroon bytes and signature. The previous schema split caveats and permissions into child tables without any position column, and the SQL reads had no ORDER BY. The KV store preserves slice order, but SQL had no explicit way to reproduce that order after migration or on later reads. The migration code’s old sorting step was only making validation deterministic; it did not preserve the original recipe order. Permissions are canonicalized by lnd when baking, so their order is less semantically important for the final macaroon. They still get positions here so the stored recipe remains faithful to the original session data and both child tables behave consistently. Why it was needed: - caveats needed explicit order preservation because they are appended and signed in order. - The old SQL schema did not store order, and the read queries did not request one. - Adding position makes the SQL representation faithful to the KV/TLV recipe instead of relying on incidental row order. - Adding it to permissions too keeps the stored recipe lossless and consistent, even though lnd. canonicalizes permissions before baking. NOTE: This commit explicitly edits the previous migration instead of adding a new one. This is ok as SQL dbs are not yet supported in production, so there are no live deployments to worry about. |
||
|---|---|---|
| .. | ||
| migsets | ||
| sqlc | ||
| sqlcmig6 | ||
| tombstone | ||
| interfaces.go | ||
| log.go | ||
| migrations.go | ||
| postgres.go | ||
| postgres_fixture.go | ||
| schemas.go | ||
| sqlerrors.go | ||
| sqlite.go | ||