Skip to content

feat: basic auth on regtest calls - #201

Merged
ovitrif merged 2 commits into
masterfrom
feat/regtest-auth
Nov 11, 2026
Merged

ovitrif merged 2 commits into
masterfrom
feat/regtest-auth

Conversation

@ovitrif

@ovitrif ovitrif commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Staging Blocktank's /regtest/* routes now require HTTP basic auth, so the apps' Settings > Blocktank Regtest actions (deposit, mine, pay, close channel) get 401 on staging regtest builds.

This PR:

  • adds an optional auth (user:password) as the last parameter of regtest_mine, regtest_deposit, regtest_pay, regtest_get_payment and regtest_close_channel; it defaults to nil / null in the bindings, so existing callers still compile
  • sends these five requests from bitkit-core itself, with basic auth when auth is set; the credentials go only to the regtest routes
  • returns Blocktank regtest API returned 401 Unauthorized: regtest auth is missing or was rejected on a 401
  • points the Blocktank tests at api.stag0.blocktank.to, the staging host the apps use; api.stag.blocktank.to no longer resolves

rust-blocktank-client 0.0.16 can't send auth on these routes. synonymdev/rust-blocktank-client#14 adds it; once 0.0.17 is published, the regtest calls can move back to the client.

Tests

Against staging (api.stag0.blocktank.to):

  • test_regtest_mine and test_regtest_deposit pass with BLOCKTANK_REGTEST_AUTH set
  • without it, both fail with the 401 error above

The order and CJIT tests in blocktank::tests still fail against staging with Not found on order creation, as before this PR.

@ovitrif ovitrif self-assigned this Nov 10, 2026
@ovitrif
ovitrif requested review from a team, ben-kaufman and coreyphillips and removed request for a team November 10, 2026 23:36
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 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-10T23:55:20.421297Z 505c88d 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.

@ovitrif

ovitrif commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator Author

Resolved: bitkit-core now sends the regtest requests itself, so it stays on rust-blocktank-client 0.0.16 from crates.io.

@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.

2 findings (1 P0, 1 P2). Adds an optional user:password basic auth to the five regtest_* exports, defaulted to nil in the bindings, and moves the Blocktank tests to api.stag0.blocktank.to. Reviewed 505c88d, full tier.

What I checked, and 3 candidates I ruled out

Read in full: the diff of src/lib.rs, src/modules/blocktank/api.rs, src/modules/blocktank/tests.rs, Cargo.toml, Cargo.lock, bindings/ios/bitkitcore.swift, bindings/ios/bitkitcoreFFI.h
Call sites traced: every caller of the five BlocktankDB::regtest_* methods (only src/lib.rs and tests.rs), all updated
Not built here: the review is from the code and from CI. with_regtest_auth and the 401 message live in the pinned rust-blocktank-client commit, which I could not read, so that half is unverified.
CI: red on 6 jobs. Android Bindgen, iOS Bindgen, Cargo manifests, paykit-route-tests and wake-tests all stop at fetching rust-blocktank-client (finding 1); usdt-tests stops at cargo fmt --check (finding 2).

Ruled out

  • Source break for existing callers: #[uniffi::export(default(auth = None))] gives Swift auth: String? = nil, so Swift call sites compile unchanged. The Kotlin bindings are not checked in, so their default is not visible in this diff; uniffi 0.29 generates it from the same attribute.
  • Auth leaking to non-regtest routes: regtest_client() clones self.client per call and only the five regtest methods use it, so the stored client never carries the credential.
  • Stale Swift checksums: the five uniffi_bitkitcore_checksum_func_regtest_* constants changed together with the signatures.

Merge confidence: 1/5, the crate does not build in CI because the pinned dependency cannot be fetched.

Comment thread Cargo.toml Resolved
Comment thread src/lib.rs Resolved

@coreyphillips coreyphillips 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.

Two independent reviews, nothing blocking a merge.

worth doing, does not block

  • Regtest errors expose passwords embedded in the base URL (src/modules/blocktank/api.rs:252)
  • Base URL query strings swallow the regtest path (src/modules/blocktank/api.rs:232-235)

nits

  • README signatures for the regtest functions omit the new auth parameter (README.md:354-383). README.md:354-383 and src/modules/blocktank/README.md:99-120 still list the five regtest functions without auth: Option<String>. Neither README says the staging regtest routes now need user:password basic auth.

Comment thread src/modules/blocktank/api.rs Resolved
Comment thread src/modules/blocktank/api.rs Resolved
@ovitrif

ovitrif commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

Merged: approved by @coreyphillips, review threads answered and resolved, required checks green (Android Bindgen still running, not required). His two non-blocking points are fixed in #203.

@ovitrif
ovitrif merged commit 3443a0c into master Nov 11, 2026
7 checks passed
@ovitrif
ovitrif deleted the feat/regtest-auth branch November 11, 2026 00:35
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.

3 participants