Skip to content

Promote integration to master: Friglet Deslop (SNB-661) - #79

Merged
setavenger merged 114 commits into
masterfrom
integration
Oct 30, 2026
Merged

setavenger merged 114 commits into
masterfrom
integration

Conversation

@setavenger

Copy link
Copy Markdown
Owner

Brings master up to integration. Everything in it is the Friglet Deslop cleanup (SNB-661): dead code and complexity removed from friglet, friglet-ipc, friglet-tray, blindbit-cli and the parts of blindbit-lib friglet uses.

The integration tree is identical to friglet-deslop-live-test-2, the combined branch the testkit A/B run (T0/T1/T2, mutations) was done on. 65 files, +2,524/−4,059.

Open PR #18 (BIP-352 K_max on the live receive path) conflicts with #75 once this lands; the resolution is described in #75.

setavenger and others added 30 commits October 3, 2026 08:35
blindbit-lib depended on silentpayments, prost-types and (through the
serde feature) base64 without using any of them. silentpayments alone
pulled 8 packages into the build, among them a second libsecp256k1 C
build and a git fetch. Cargo.lock goes from 635 to 627 packages.

Also remove manifest lines that repeat Cargo's defaults or are
commented out: blindbit-lib's [[example]] blocks (auto-discovered from
examples/), blindbit-cli's [[bin]] block, friglet's empty [features]
table, the serde feature and package key on friglet's bdk_sp (friglet
only uses SilentPaymentCode; blindbit-lib enables bdk_sp/serde anyway),
and a commented-out [profile.release] in the workspace manifest.

No code changes; the build targets and features cargo metadata reports
are the same apart from base64 leaving blindbit-lib's serde feature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove public items nothing calls, in this workspace or in the other
repos that use blindbit-lib (blindbit-node-apps, testkit, the talk
benchmark):

- broadcast_tx: its only caller, friglet's Electrum broadcast, uses
  friglet's own relay since #26.
- Scanner::from_config, get_last_scanned_block_height_rescan,
  staged_mut, take_staged and the commented-out get_outputs.
- watch_chain: friglet calls watch_chain_until; its doc moves there.
- BlockIdentifierDisplay (only .0.block_height was read), OwnedOutput
  (never built), ProbableMatch::new, _match_short_pubkey_bytes and the
  commented-out ScannerConfig Default. electrum_index becomes a private
  module; its items stay re-exported.
- The spent-outpoint and probabilistic-match channels and the code that
  only fed them. They had no subscribers and never sent anything: the
  sends were guarded by Sender::is_empty(), which means "no queued
  value", so they were always skipped. The malformed-hash branch that
  guarded them cannot run: check_block_identifier rejects such a block
  before scan_short_block_data sees it. The "possible spend of owned
  output" log line stays.
- save_to_file's back-fill of keys and max_label_num: stage holds them
  from construction on and only take_staged could clear them. A test
  run with assertions in place of the back-fill passed every workspace
  test.
- P2P: TimeoutParams setters the handshake never reads (it only uses
  the ping interval; the socket timeouts are set directly), history
  notes about deleted code, and a retry doc that predates the
  witness-stripped and bad-block retries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three lifecycle e2e tests wrote a shell script to a temp dir and then ran
it as the "daemon binary". The test harness runs tests on parallel
threads of one process, so another test's spawn could fork while the
script was still open for writing; the forked child holds that write
handle until it execs, and running the script in that window fails with
"Text file busy" (ETXTBSY, os error 26).

The scripts are now committed as executable fixtures under
friglet-tray/tests/fixtures/ and located via CARGO_MANIFEST_DIR, so
nothing is written while the tests run. The long-running fixture uses
`exec sleep 30`, so killing the spawned child no longer leaves a stray
sleep behind for 30 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Electrum server built the same things in several places. One copy
of each now:

- notification(): the JSON-RPC notification line (was written out four
  times); sp_subscription(): the SP subscription object and its
  notification, shared by the push task and the subscribe handler.
- invalid_param(): the -32602 answer for a missing or mistyped first
  parameter (block.header, scripthash.subscribe/get_history,
  transaction.get); the messages are unchanged.
- save_header_sidecar(): the header-sidecar write after a backfill and
  after a reorg.
- Peer::header_by_hash() takes one hash (its only caller passed a
  one-element slice) and returns only a header with that hash, so the
  two re-checks of the same hash in ChainSource::header and
  backfill_header go.
- relay: connect_settled() (connect + settle, the 2 s literal is now
  p2p::SETTLE_WAIT, also used by ChainSource::fee_filter),
  Candidate::wire_tx() and Signals::announce() replace two or three
  copies each.
- index_unconfirmed_tx: two match arms that both did nothing are one
  condition.
- Two tests build their request with call() like the others.

The bytes on the wire are unchanged: a scripted session of 52 requests
and 8 push batches gives byte-identical output before and after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scanner::new and from_changeset each wrote out the whole struct; both
now hand their staged changeset to one private constructor,
from_stage, which derives the rest (checkpoints with genesis, owned
outputs, remembered hashes, Electrum index) from it.

- "New indexer, labels 0..=max, then apply_changeset" was written in
  from_changeset and in the reorg rollback; it is restored_indexer now,
  with the reason the labels must come first.
- The genesis checkpoint hash was built in three places; genesis_hash().
- new() merged add_label(0..=max) into the stage a second time after
  initial_changeset() already carried those labels (label_lookup is a
  set, so the merge changed nothing); dropped.
- The remembered-hash lookup in reorg.rs is one helper.
- Scanner.last_scanned_block_height_rescan was only restored, lowered on
  rollback and copied into every save. The stage already holds the same
  value, so the field goes; the ChangeSet field and the state format
  stay as they are.

A probe (not committed) dumped stage, saved file and full scanner
state for fresh scanners, a test-produced wallet, the old-format
fixture, restores and rollbacks of each, before and after this change:
all 42 outputs identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
release.yml pinned TAURI_CLI_VERSION 2.11.5, but Cargo.lock moved the
tauri crate to 2.12.1 in 8bf4c40, against the workflow's own rule to
keep the two equal. tauri 2.12.1 was released from the same commit
(30da1fd in tauri-apps/tauri) as tauri-cli and @tauri-apps/cli 2.12.1,
together with tauri-utils 2.10.1 and tauri-build 2.7.1, which are also
the versions in Cargo.lock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test and clippy job installed libayatana-appindicator3-dev,
librsvg2-dev, libssl-dev and patchelf, but nothing in the test build
uses them: Cargo.lock has no openssl or rsvg crates,
libappindicator-sys loads the library at run time (libloading, no build
script linking it), and patchelf is only used for AppImage bundles.
release.yml keeps its list: tauri build bundles appindicator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…NB-667)

Nothing here changes what the tray does:

- Tauri commands set_config and set_scan_key: registered, but the UI
  has saved settings through apply_settings since 8bf4c40 and never
  invokes them. The SetConfig / SetScanKey protocol requests stay
  (wire compatibility with separately installed daemons).
- lifecycle: decide/Action (used only by its own test), attach_or_spawn
  (no callers) and QuitAction/quit_action (an enum around one bool;
  perform_quit now tests the bool).
- show_settings_window / show_wallet_window were copies differing only
  in the tab: one show_window_tab(app, tab). The
  FRIGLET_TRAY_SHOW_ON_START parse is a pure function of the value, so
  its test no longer sets the process environment (the unsafe set_var's
  safety comment was false: tests run in parallel).
- get_config and send_with_note share one daemon_request helper
  (connect, request, map errors); the poller and the poll_once test
  helper share record_poll.
- ErrorBook::event returned "should be logged", which its only caller
  ignored; it returns nothing now. Doc links point at the constants
  that exist (STALL_GRACE_SECS, UNREACHABLE_GRACE_SECS).
- fake-daemon example: uses friglet_ipc's NETWORKS and one scan-key
  check instead of copies.
- UI: CSS rules already covered by `[hidden] { display: none
  !important; }`, a `.hint code` rule that matches nothing, and an
  unused id="recent-errors".
- tauri.conf.json: the bundle.linux.deb.depends block. The Tauri CLI
  adds libwebkit2gtk-4.1-0 and the appindicator package itself (with
  tauri's tray-icon feature on) and does not de-duplicate, so the .deb
  listed both packages twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`features = []` on the tauri-build build dependency is Cargo's default;
the plain version requirement means the same. Cargo.lock is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- lib.rs tests: spawn_fake_daemon / spawn_fake_daemon_owned were a
  second fake next to spawn_stoppable_fake_daemon, differing only in
  canned GetStatus fields no test reads. Their four users never send
  Shutdown or check the pid, so they now use the one fake.
- lifecycle_e2e: attaches_when_daemon_already_running is covered by
  attach_carries_daemons_self_reported_ownership, which attaches the
  same way (the locator panics if consulted) and also checks the
  carried ownership.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The scan loop's two arms (no match / matched block) each advanced
  the scanned height, recorded the block hash and notified Electrum;
  that now happens once after the optional matched-block step, in the
  same order as before. The periodic checkpoint still runs only for
  blocks without a match (a matched block is saved earlier).
- The oracle's display-order block hash is decoded once:
  check_block_identifier returns it (via health.rs's
  indexed_block_hash, the same length and all-zero rules), and the P2P
  fetch uses it instead of decoding the bytes again.
  block_hash_from_oracle goes.
- The balance over the sparse checkpoints is one helper, balance_at,
  used for the per-block "balance" log, the "balance after scan" log
  and the owned-output tests (which had a third copy).
- The matched block's scan_progress write is dropped; the progress
  notification right after it writes the same value.
- The debug loop that logged every graph transaction after each
  matched block is dropped.
- apply_matched_block computed every transaction's txid once per
  matched txid; it now builds a txid map and hashes each transaction
  once.
- OracleStreams only delegated to the oracle client: the client now
  implements BlockStreamSource itself (it already implemented
  OracleProbe). An identity match in probabilistic_match goes.
- Stale TODOs and comments (notifications that no longer exist, a
  config-constructor TODO the talk benchmark rules out, Electrum index
  docs that missed the restore and broadcast writers).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(SNB-664)

Leftovers from the live scanner swap and from earlier refactors:

- ControlCtx keeps the Electrum index and the label addresses directly;
  the std Mutex around each was never written after the live
  rebuild-and-swap went away (#29). The Start comment that still
  described the swap is fixed.
- One-line wrappers around friglet-ipc are gone (default_config_path,
  default_key_file, write_config_file, write_key_file, replace_scan_key);
  apply() writes the key it already parsed instead of having
  replace_scan_key parse it again.
- pick_tip was `oracle.or(electrum)`; inlined, with its test.
- control's unix_now duplicated pending::now_secs.
- The key file's "first non-empty line" is read by one helper.
- ResolvedConfig no longer copies oracle_url, max_label_num, http_addr
  and electrum_addr out of `raw`.
- main no longer sets sp_start_height a second time right after
  rebuild_electrum_index_from_graph set it.
- control::run takes the ControlCtx instead of a generic handler; its
  only other user was get_status_roundtrip_over_control_socket, which
  repeated friglet-ipc's roundtrip test and every serve_ctx test.
- supervisor: stop_during_a_download_pauses_at_once repeated the
  cooperative-cancel tests and left a 30 s thread behind.
- fake_peer: the single-field Seen struct is a Vec.
- Stale comments: types.rs, the --oracle-url default, electrum::run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fake daemons in the lib tests and the lifecycle e2e tests bound
their socket inside the task they spawned, so every test slept a fixed
100 ms after starting one and hoped the bind had happened by then. The
helpers now bind (friglet_ipc::listen) before spawning the accept loop
and return with the socket up, and the eleven sleeps are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
friglet-ipc items only its own module uses are private now:
write_message, read_message, SpDescriptor::scan_pubkey,
descriptor_checksum, the log-file constants and RotatingLog::with_limit.
No other crate in the workspace uses them, and neither does friglet-ui
(it uses Request/Response/StatusInfo, Client, listen, accept,
read_config_toml and DaemonConfig).

Comments: no frigletctl tool exists; state_file documents the per-wallet
file name; OkWithNote's example is what the daemon sends today;
oracle_connected describes the background poll, not a cache TTL. The
default oracle_url uses the same constant as hosted_oracle_url("bitcoin")
instead of repeating the URL. The roundtrip test sets scan_health twice;
blindbit-cli has four comments that restate the next line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o (SNB-682)

The console log goes to stdout (tracing-subscriber's default writer),
but whether it is coloured was decided by looking at stderr. Run from a
terminal with stdout redirected (`friglet > out.log`), the file got ANSI
escapes. The layer now checks stdout and names stdout as its writer, so
the two cannot drift apart again; the comments that said stderr say
stdout.

Nothing changes when both streams go to the same place: a terminal still
gets colour, and a tray-spawned daemon (both piped) still gets none.

New test (Linux, needs util-linux `script` for a pseudo-terminal; skips
without it): with stdout redirected to a file and stderr on the
terminal, the file has no escapes. It fails on the old code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…SNB-666)

The test wallet's keys, the Tokio runner, the never-connecting oracle
client, state-file paths, TempState and the scanner constructors were
defined again in five to six test modules. They now live in
scanner/test_support.rs:

- oracle_client() uses the caller's runtime when there is one and a
  process-wide one otherwise, so it serves both the async tests and the
  synchronous owned-output and BIP-352 tests. All tests now point at
  127.0.0.1:1, where nothing listens (two modules used [::1]:50051 and
  127.0.0.1:8333).
- state_file(tag) returns a path no other call returns, so modules
  can no longer collide on a tag (reorg and owned-output tests both
  used "restart").
- scanner(tag), scanner_at(path, max_label_num) and restore_from(path)
  replace stream_safety's scanner, reorg's wallet/restart,
  owned_outputs' scanner/restore, witness' restart and state_file's
  new_scanner/client. bip352_vectors keeps its own constructor (vector
  keys, mainnet) on the shared client and paths.

Also:
- a_fetched_block_keeps_its_witnesses is dropped: the next test fetches
  the same kind of block whole on its second connection and compares
  the whole block, witnesses included.
- p2p_tests' Node has three constructors instead of four, and the
  witness-stripping loop is one helper (stripped) used by the fake node
  and the witness tests.
- The stale allow(dead_code) on the vectors' `sending` field goes (the
  field is read).
- The pre-owned-outputs restore test restores the file it just saved
  instead of a re-serialised copy, so it leaves no file behind.

Test count: 254 -> 253 passed (the one duplicate removed), 1 ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…681)

The daemon listens on FRIGLET_CONTROL_SOCKET, else the config file's
control_socket, else the platform default (its env layer is merged over
the file). The tray only looked at the env variable and the default, so
with control_socket set in config.toml it never reached the daemon: it
went into first-run setup mode when nothing answered at the default
path, or spawned a daemon, waited 30 s for a socket that came up
elsewhere, killed it and kept restarting it.

setup::control_socket_path resolves the path in the daemon's order from
the default config file, and the tray uses it at startup. A daemon the
tray spawns already reads the same config file and inherits the tray's
environment, so nothing is passed to it, and nothing new is written to
the user's config.toml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
write_key_file(.., overwrite = true) truncated scan.key and then wrote
it. A crash between the two left an empty key file, and the daemon would
not start until the key was entered again. It now writes
`<name>.tmp` in the same directory (0600 from creation, enforced again
for a leftover temp file), syncs it and renames it over the key file,
like write_config_toml. The file format ("<hex>\n") and the 0600 mode
are unchanged; creating a new key (overwrite = false) still fails when
the file exists.

New test: a reader thread rereads the key while it is replaced 200
times and must only ever see the old or the new key. On the old code it
sees an empty file (failed 13 of 13 runs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(SNB-685)

apply() took apply_lock first and then looked up a new wallet's
birthday at the oracle (up to 15 s) and resolved the P2P host name
(blocking DNS) while holding it, so a Stop or Start sent during an
ApplySettings with start_at_tip waited for both.

Both lookups now run in prepare(), before the lock. Under the lock
apply() still reads the current settings, compares, persists and
requests the restart, so a settings change still never interleaves with
Start/Stop or another apply. A SetScanKey (no config of its own) whose
settings snapshot was replaced by another apply while it waited for the
lock prepares again from the newer settings, as if the two had run one
after the other.

Tests: Stop and Start answer within a second while an apply waits on an
oracle that never answers (the old code timed out after 2 s); a
SetScanKey that waited behind another apply keeps that apply's settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…an" (SNB-687)

The end-of-range "balance after scan" line computed the balance with the
last block matched in that range as the chain tip, and with genesis when
no block in the range paid the wallet. bdk_chain cannot place an anchor
above the tip it is given, so it counted every output as pending: the
line logged confirmed=0 and the whole balance as trusted_pending. That
is every range while the daemon follows the tip, as a rule.

The balance is now counted up to the highest checkpoint. When the range
matched a block above every earlier checkpoint (any forward scan), that
block is the highest checkpoint, so the logged values are the same as
before. The message and field names are unchanged; friglet-ui matches
the line by its text.

balance_after_scan_counts_earlier_outputs_as_confirmed scans a paying
block, then a block that pays nobody, and checks the fields of both
lines. Before the fix the second line read confirmed="0 BTC",
trusted_pending="0.00011800 BTC".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-688)

bitcoin-p2p reads each message with read_exact, so a read timeout part
way through the block throws away the bytes read so far. A node that
sent half a block and went quiet therefore looked like one that sent
nothing: at the deadline the fetch reported NoAnswer, with advice that
the node is probably pruned, and NoAnswer is not tried again in that
round.

The fetch now sends a ping right after getdata. A node handles a peer's
messages in order, so it answers the ping once it has sent the block or
decided not to. At the deadline, a pong means the node does not serve
the block (NoAnswer, as before). No pong means the node went quiet, so
the attempt fails as a broken connection, which is tried again on a
fresh one. The wait itself is unchanged.

Tests: a_transfer_that_stalls_mid_block_is_retried_on_a_fresh_connection
and a_transfer_that_keeps_stalling_is_not_reported_as_a_missing_block
use the fake node's StallMidBlock. Before the fix both ended after one
attempt with NoAnswer and "the node sent nothing for 303 ms ... It is
probably pruned below this height". The fake node's Ignore now answers
pings, as Bitcoin Core does while ignoring a request for a block it
does not have.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A block fetched only because an owned output may be spent carries no
matched txids. The txid filter still hashed every transaction of it
(about 2 ms per block); the code before #52 did nothing there. Skip
the filter when there are no matched txids.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…NB-666)

Brings #52's spend-only fix (skip the txid filter when no txid
matched) into this stacked branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- owned_outputs_labels_and_spends_survive_restart builds its scanner on
  the state file it saves, restores and removes. state_file() returns a
  new path on every call, so the second call gave the scanner a
  different file than the one the test checks.
- default_scanner in the BIP-352 vectors points its P2P peer at
  127.0.0.1:1 like every other test (it is never contacted).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nfirmed (SNB-687)

Picks up #57's review nits and #52's follow-up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…688)

Picks up #57's review nits and #52's follow-up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Correct what the docs say about integration as it is now; no code changes.

- README: blindbit-cli needs --end-height, takes only ip:port for the P2P
  node, keeps its state in ./scanner_state.json by default and has
  --log-level; friglet's --log-level is documented; console logs go to
  stdout, not stderr; the tray build needs no appindicator/rsvg packages.
- HTTP /height and /subscribe do not answer while scanning is enabled,
  so status checks use the control socket's GetStatus or an Electrum
  server.version call instead of curl /height. The HTTP docs stay.
- Docker: the scanner state is not in /data by default (SNB-635); the docs
  and the Dockerfile comment say so and give the workaround, an absolute
  state_file under /data.
- AGENTS.md: Rust >= 1.90 (Tauri crates declare it; let-chains need 1.88),
  the packages a build actually needs vs. release bundling, blindbit-lib
  has tests, the Settings tab saves with ApplySettings, GetStatus reads a
  background poller, the default state file is per wallet, an HTTP bind
  failure panics. Past-fix narrative and repeated sections removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…env (SNB-681)

Only the first lookup in control_socket_path goes through the injected
env; the final fallback, friglet_ipc::default_socket_path, reads the
real FRIGLET_CONTROL_SOCKET again. Say so in the doc comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s (SNB-682)

"cannot write the log file; logging to stderr only" was missed in the
first commit: the console log is written to stdout. No tray or friglet-ui
code matches this text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review: when a SetScanKey's settings snapshot had been replaced by
another apply while it waited for the lock, it prepared again (oracle
birthday lookup, blocking DNS) while holding apply_lock, so Start/Stop
could still wait behind the network in that case, and the field doc was
not true.

apply() now drops the lock, prepares again from the new settings and
takes the lock again to check; it persists only once the settings it
prepared from are the ones under the lock. Comparing and persisting
still happen under the lock only, so Start/Stop never see a half-applied
change and two applies never mix their writes.

New test: settings replaced (by a config whose preparation waits on an
oracle that never answers) while a SetScanKey waited for the lock; Stop
and Start still answer within a second, nothing is persisted. With the
re-prepare under the lock, Stop timed out after 2 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
setavenger and others added 27 commits October 11, 2026 20:14
…(SNB-664)

Leftovers from the live scanner swap and from earlier refactors:

- ControlCtx keeps the Electrum index and the label addresses directly;
  the std Mutex around each was never written after the live
  rebuild-and-swap went away (#29). The Start comment that still
  described the swap is fixed.
- One-line wrappers around friglet-ipc are gone (default_config_path,
  default_key_file, write_config_file, write_key_file, replace_scan_key);
  apply() writes the key it already parsed instead of having
  replace_scan_key parse it again.
- pick_tip was `oracle.or(electrum)`; inlined, with its test.
- control's unix_now duplicated pending::now_secs.
- The key file's "first non-empty line" is read by one helper.
- ResolvedConfig no longer copies oracle_url, max_label_num, http_addr
  and electrum_addr out of `raw`.
- main no longer sets sp_start_height a second time right after
  rebuild_electrum_index_from_graph set it.
- control::run takes the ControlCtx instead of a generic handler; its
  only other user was get_status_roundtrip_over_control_socket, which
  repeated friglet-ipc's roundtrip test and every serve_ctx test.
- supervisor: stop_during_a_download_pauses_at_once repeated the
  cooperative-cancel tests and left a 30 s thread behind.
- fake_peer: the single-field Seen struct is a Vec.
- Stale comments: types.rs, the --oracle-url default, electrum::run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o (SNB-682)

The console log goes to stdout (tracing-subscriber's default writer),
but whether it is coloured was decided by looking at stderr. Run from a
terminal with stdout redirected (`friglet > out.log`), the file got ANSI
escapes. The layer now checks stdout and names stdout as its writer, so
the two cannot drift apart again; the comments that said stderr say
stdout.

Nothing changes when both streams go to the same place: a terminal still
gets colour, and a tray-spawned daemon (both piped) still gets none.

New test (Linux, needs util-linux `script` for a pseudo-terminal; skips
without it): with stdout redirected to a file and stderr on the
terminal, the file has no escapes. It fails on the old code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s (SNB-682)

"cannot write the log file; logging to stderr only" was missed in the
first commit: the console log is written to stdout. No tray or friglet-ui
code matches this text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(SNB-685)

apply() took apply_lock first and then looked up a new wallet's
birthday at the oracle (up to 15 s) and resolved the P2P host name
(blocking DNS) while holding it, so a Stop or Start sent during an
ApplySettings with start_at_tip waited for both.

Both lookups now run in prepare(), before the lock. Under the lock
apply() still reads the current settings, compares, persists and
requests the restart, so a settings change still never interleaves with
Start/Stop or another apply. A SetScanKey (no config of its own) whose
settings snapshot was replaced by another apply while it waited for the
lock prepares again from the newer settings, as if the two had run one
after the other.

Tests: Stop and Start answer within a second while an apply waits on an
oracle that never answers (the old code timed out after 2 s); a
SetScanKey that waited behind another apply keeps that apply's settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review: when a SetScanKey's settings snapshot had been replaced by
another apply while it waited for the lock, it prepared again (oracle
birthday lookup, blocking DNS) while holding apply_lock, so Start/Stop
could still wait behind the network in that case, and the field doc was
not true.

apply() now drops the lock, prepares again from the new settings and
takes the lock again to check; it persists only once the settings it
prepared from are the ones under the lock. Comparing and persisting
still happen under the lock only, so Start/Stop never see a half-applied
change and two applies never mix their writes.

New test: settings replaced (by a config whose preparation waits on an
oracle that never answers) while a SetScanKey waited for the lock; Stop
and Start still answer within a second, nothing is persisted. With the
re-prepare under the lock, Stop timed out after 2 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Initialize outputs_found from the restored scanner instead of parsing the
state JSON again. Legacy state files rebuild their owned-output records
on restore, so the startup status now reports the wallet's actual count.

Keep coverage for absent, invalid and bare-key legacy state files. The
regression test reports 0 instead of 2 with the old counter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use the legacy fixture's wallet keys and abort the runtime-owned oracle
listener after restore, avoiding process-lifetime server threads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move full settings validation, including the system DNS lookup, to a
blocking worker with a ten-second response deadline. The worker owns a
private config copy, so a late result cannot persist settings or restart
the daemon after the request times out.

Keep birthday lookup and both prepare paths outside apply_lock. Verify
responsiveness on a single async worker and timeout handling independently
of real DNS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Friglet cleanup 4/6: simplify daemon settings paths (SNB-661)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…NB-667)

Nothing here changes what the tray does:

- Tauri commands set_config and set_scan_key: registered, but the UI
  has saved settings through apply_settings since 8bf4c40 and never
  invokes them. The SetConfig / SetScanKey protocol requests stay
  (wire compatibility with separately installed daemons).
- lifecycle: decide/Action (used only by its own test), attach_or_spawn
  (no callers) and QuitAction/quit_action (an enum around one bool;
  perform_quit now tests the bool).
- show_settings_window / show_wallet_window were copies differing only
  in the tab: one show_window_tab(app, tab). The
  FRIGLET_TRAY_SHOW_ON_START parse is a pure function of the value, so
  its test no longer sets the process environment (the unsafe set_var's
  safety comment was false: tests run in parallel).
- get_config and send_with_note share one daemon_request helper
  (connect, request, map errors); the poller and the poll_once test
  helper share record_poll.
- ErrorBook::event returned "should be logged", which its only caller
  ignored; it returns nothing now. Doc links point at the constants
  that exist (STALL_GRACE_SECS, UNREACHABLE_GRACE_SECS).
- fake-daemon example: uses friglet_ipc's NETWORKS and one scan-key
  check instead of copies.
- UI: CSS rules already covered by `[hidden] { display: none
  !important; }`, a `.hint code` rule that matches nothing, and an
  unused id="recent-errors".
- tauri.conf.json: the bundle.linux.deb.depends block. The Tauri CLI
  adds libwebkit2gtk-4.1-0 and the appindicator package itself (with
  tauri's tray-icon feature on) and does not de-duplicate, so the .deb
  listed both packages twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- lib.rs tests: spawn_fake_daemon / spawn_fake_daemon_owned were a
  second fake next to spawn_stoppable_fake_daemon, differing only in
  canned GetStatus fields no test reads. Their four users never send
  Shutdown or check the pid, so they now use the one fake.
- lifecycle_e2e: attaches_when_daemon_already_running is covered by
  attach_carries_daemons_self_reported_ownership, which attaches the
  same way (the locator panics if consulted) and also checks the
  carried ownership.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fake daemons in the lib tests and the lifecycle e2e tests bound
their socket inside the task they spawned, so every test slept a fixed
100 ms after starting one and hoped the bind had happened by then. The
helpers now bind (friglet_ipc::listen) before spawning the accept loop
and return with the socket up, and the eleven sleeps are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…681)

The daemon listens on FRIGLET_CONTROL_SOCKET, else the config file's
control_socket, else the platform default (its env layer is merged over
the file). The tray only looked at the env variable and the default, so
with control_socket set in config.toml it never reached the daemon: it
went into first-run setup mode when nothing answered at the default
path, or spawned a daemon, waited 30 s for a socket that came up
elsewhere, killed it and kept restarting it.

setup::control_socket_path resolves the path in the daemon's order from
the default config file, and the tray uses it at startup. A daemon the
tray spawns already reads the same config file and inherits the tray's
environment, so nothing is passed to it, and nothing new is written to
the user's config.toml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…env (SNB-681)

Only the first lookup in control_socket_path goes through the injected
env; the final fallback, friglet_ipc::default_socket_path, reads the
real FRIGLET_CONTROL_SOCKET again. Say so in the doc comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Friglet cleanup 5/6: simplify tray lifecycle and setup (SNB-661)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Correct what the docs say about integration as it is now; no code changes.

- README: blindbit-cli needs --end-height, takes only ip:port for the P2P
  node, keeps its state in ./scanner_state.json by default and has
  --log-level; friglet's --log-level is documented; console logs go to
  stdout, not stderr; the tray build needs no appindicator/rsvg packages.
- HTTP /height and /subscribe do not answer while scanning is enabled,
  so status checks use the control socket's GetStatus or an Electrum
  server.version call instead of curl /height. The HTTP docs stay.
- Docker: the scanner state is not in /data by default (SNB-635); the docs
  and the Dockerfile comment say so and give the workaround, an absolute
  state_file under /data.
- AGENTS.md: Rust >= 1.90 (Tauri crates declare it; let-chains need 1.88),
  the packages a build actually needs vs. release bundling, blindbit-lib
  has tests, the Settings tab saves with ApplySettings, GetStatus reads a
  background poller, the default state file is per wallet, an HTTP bind
  failure panics. Past-fix narrative and repeated sections removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use the Linux data-directory socket when XDG_RUNTIME_DIR is unset,
and prefer the explicit environment override. Document the fallback
paths and how to use a configured socket override.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Align the runtime, socket, test-fixture, and package dependency documentation with the full grouped stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Friglet cleanup 6/6: align docs with the combined stack (SNB-661)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tray appended a "rebuild it" hint when a spawned daemon exited with a
clap usage dump, the signature of a friglet build from before July 2026
that still required the `scan` subcommand. No release or tag was ever
published with that CLI, so only a developer's own stale local build could
hit it. The daemon's captured output is still shown in the reason, as for
any other immediate exit.

Removes the hint, its e2e test and the stale-binary fixture script.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
integration now holds the deslop stack #67-#72, whose commits GitHub's
stacked merge rebased to new IDs. Its tree is identical to 08bf11d, which
this branch already contains, so this branch's tree is kept unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in integration (the merged deslop stack #67-#72) via snb-668-remove-http-api.
No code change: this branch's tree stays the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ndex

Brings in integration (the merged deslop stack #67-#72) via snb-662-remove-full-receive-path.
No code change: this branch's tree stays the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
friglet: remove the HTTP API (SNB-668)
blindbit-lib: remove the unused full-transaction receive path (SNB-662)
blindbit-lib, friglet: share the Electrum-index and oracle-hash code (SNB-671)
friglet-tray: drop the outdated daemon binary rebuild hint (SNB-677)
@setavenger
setavenger merged commit e497d8a into master Oct 30, 2026
6 checks passed
@setavenger
setavenger deleted the integration branch October 30, 2026 06:46
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.

1 participant