Skip to content

feat: read the breez api key from the keychain - #1897

Merged
ovitrif merged 2 commits into
masterfrom
feat/keychain-breez-key
Nov 12, 2026
Merged

ovitrif merged 2 commits into
masterfrom
feat/keychain-breez-key

Conversation

@ovitrif

@ovitrif ovitrif commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Twin: synonymdev/bitkit-ios#1317

Local builds can read BREEZ_API_KEY from the macOS keychain, so developers need no plain copy of the key in local.properties.

Description

  • app/build.gradle.kts: localProp(key) falls back to the macOS keychain item named like the key, read with /usr/bin/security through providers.exec, after the environment variable, the Gradle property and local.properties. Without /usr/bin/security (Linux CI) or without the item it returns nothing, so CI and existing setups resolve the key as before.
  • README.md: documents where Gradle reads the Breez API key from and the command that stores it in the keychain.

Out of Scope

  • .github/workflows: CI keeps passing the key from repository secrets as an environment variable.
  • Other build secrets: only keys read through localProp get the fallback; no other key is stored in the keychain by this PR.
  • app/build.gradle.kts: warning on an unreadable keychain item and limiting the fallback to BREEZ_API_KEY, tracked in chore: warn on an unreadable keychain key #1906 (thread, thread).

Design

N/A — no UI changes.

Preview

N/A

QA Notes

Setup

macOS, with the key stored once: security add-generic-password -U -a "$USER" -s BREEZ_API_KEY -w, and no BREEZ_API_KEY in the environment, Gradle properties or local.properties.

Journeys

N/A — no user-visible behaviour change.

Manual Tests

  • 1. ./gradlew :app:generateMainnetDebugBuildConfig → the generated mainnet BuildConfig has a non-empty BREEZ_API_KEY — build-time config, not drivable on a device

Automated Checks

  • ran just compile, just test, just lint

Evidence

    1. passed on macOS: with BREEZ_API_KEY unset in the environment, the generated mainnet debug BuildConfig held the full-length key, also on a configuration-cache rerun.
  • just compile, just test and just lint passed.

Gaps

  • Linux CI path: covered by this PR's CI run, where /usr/bin/security is absent and the key comes from the environment as before.

Models used

  • Planning/scoping: claude-opus-5-5 (reasoning: Not exposed)
  • Implementation: claude-opus-5-5 (reasoning: Not exposed)
  • Review: Not performed

Metadata note: the session tools report the model but not its reasoning setting.

@ovitrif ovitrif self-assigned this Nov 12, 2026
@ovitrif
ovitrif requested review from a team and removed request for a team November 12, 2026 17:08
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T17:09:04.016444Z 0b0e066 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Adds macOS keychain lookup as the last fallback for values read through localProp.

  • Gradle can read build properties from the macOS keychain.

Reviews (1) · Last reviewed commit: "feat: read the breez api key from the ke..." · Reviewed by Greptile

@github-actions

Copy link
Copy Markdown
Contributor

Regtest APK

Built from 0b0e066 (run).

Download bitkit-dev-debug universal APK (expires in 30 days).

@talosmachina talosmachina left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings. localProp falls back to the macOS keychain item named like the key, after the environment, Gradle properties and local.properties. Reviewed 0b0e066, light tier.

What I checked, and 4 candidates I ruled out

Read in full: keychainProp and localProp in app/build.gradle.kts and every localProp call site, README.md
Not built: on the Bitkit track an auto review does not run Gradle on the branch, so this is reasoned from the code and from CI
CI: build-local and Greptile green; build-and-test, lint, compose-ui and the e2e jobs still pending when I read it

Ruled out

  • Linux CI: /usr/bin/security is not executable there, so keychainProp returns an empty provider before providers.exec is set up.
  • Failing lookup fails the build: isIgnoreExitValue = true and the empty-output filter turn a missing item into an absent value, so .orElse("") still applies.
  • Configuration cache: the read goes through providers.exec, which Gradle records as a configuration input, so the cache stays valid; the author's rerun on a cache hit agrees.
  • Keychain read when another source has the key: orElse is lazy, so security runs only when the three earlier sources are all empty.

Merge confidence: 4/5, CI not finished and the change has no test (it is build configuration).

Reviewer model: claude-opus-5-5
Reasoning effort: Not exposed

Metadata note: the review session reports the model but not its reasoning setting.

@ovitrif
ovitrif requested review from coreyphillips, jvsena42 and piotr-iohk and removed request for ben-kaufman and pwltr November 12, 2026 18:52

@coreyphillips coreyphillips left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two independent reviews, nothing blocking a merge.

worth doing, does not block

  • Unreadable keychain item is treated the same as a missing one (app/build.gradle.kts:62-65)

nits

  • Keychain fallback spawns a process for every unset localProp key (app/build.gradle.kts:68-73)

Comment thread app/build.gradle.kts Resolved
Comment thread app/build.gradle.kts Resolved

@jvsena42 jvsena42 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings at 0b0e066. Reviewed as a credential-handling change.

What I checked
  • localProp order (environment, Gradle property, local.properties, keychain) matches the README; orElse is lazy, so security runs only when the earlier sources are absent.
  • Every localProp key now also queries the keychain (USDT_*, ESPLORA_URL, TREZOR_BRIDGE*, the debug-only E2E keys). A value appears only for a generic-password item with that exact service name and the user's account, so nothing is picked up by accident.
  • No leak: the security argv holds no secret and its stderr is captured, not printed.
  • Linux CI and release are unchanged: /usr/bin/security is absent, and release.yml:73 still guards the env var.
  • Edge cases looked at and not raised: a blank BREEZ_API_KEY= line in local.properties blocks the keychain fallback (no template ships one, so it takes a deliberate blank); the build output still holds the key in plain text, which the README wording glosses over but the code comment states correctly.
  • iOS twin synonymdev/bitkit-ios#1317 reviewed in the same pass, also clean.

Device gate: no device check needed — build configuration only, no journeys; perf: build-time only, a missing-item security lookup measured at ~10 ms, ≤12 per variant on macOS.
Skipped — covered by CI at 0b0e066: build-and-test, lint, detekt, compose-ui, e2e (all green).

Reviewer model: claude-opus-5-5 (coordinator), claude-fable-5-2 (primary review)
Reasoning effort: Not exposed

@piotr-iohk piotr-iohk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA review

Scope: Full review of the complete PR diff against merge base 35265252, at 0b0e066.

No new actionable code findings.

localProp reads the macOS keychain only after the environment, Gradle properties, and local.properties. With /usr/bin/security absent, the fallback stays empty and the build continues. CI and lint succeeded on this revision. The release workflow still rejects an empty BREEZ_API_KEY before Gradle.

Compared with bitkit-ios#1317 at 568b0be: iOS Release builds fail when that keychain item is missing or unreadable, while this Android change keeps the documented local result (the app builds and Spark stays off). The existing note still matches the code: a stored key that security cannot read is treated as absent.

Device testing: not performed. This is build configuration only; no journey applies.

Validation: a Gradle 9.9.0 probe of this provider chain, with configuration cache reused, resolved an absent security binary to an empty key and a default URL; a non-zero providers.exec with isIgnoreExitValue still produced a value; a later command stdout was visible on the following run when the provider was a task input. /usr/bin/security was not executed in this environment.

Suggested additional test cases

  • macOS. No BREEZ_API_KEY in the environment, Gradle properties, local.properties, or the keychain. Run ./gradlew :app:generateMainnetDebugBuildConfig. The build succeeds and the generated mainnet debug BuildConfig.BREEZ_API_KEY is empty.
  • macOS. Set BREEZ_API_KEY in the environment to a sentinel and store a different value in the keychain item. Run the same task. BuildConfig.BREEZ_API_KEY is the sentinel.

Reviewer model: grok-4.7
Reasoning effort: high

@ovitrif

ovitrif commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

Merged: approved by @coreyphillips and @jvsena42, checks green; both non-blocking points are answered in their threads and tracked in #1906.

@ovitrif
ovitrif merged commit f7ad821 into master Nov 12, 2026
24 checks passed
@ovitrif
ovitrif deleted the feat/keychain-breez-key branch November 12, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants