walletSyncBarVisible function
Whether the wallet tab shows its sync bar (FR-49 S12, C2). HIDDEN only when every one of these holds, so nothing a user must know hides with it:
- the status is a plain, fresh
UpToDateat badge levelok(every qualified reached-tip variant — limited, degraded, unverified, endpoint behind — iscautionand keeps the bar, as do a stale snapshot, a failed start and a host-off policy, via walletBadgeLevel); - the sync loop is running;
- the transport claim cannot go stale while the tab is open (rev.2 R6):
neutral(Tor off / a direct connection — static for the session), orprotectedONLY when the HOST declared it (hostDeclaredTransport). An SDK-derivedprotectedcomes from the cold snapshot, which is not re-read on a mid-session Tor fallback, so it keeps the bar (with its filled shield) until the UI can watch Tor state live.caution,dangerandprogressalways keep the bar. Relim accepted hiding onneutralover "show whenever not protected", which would never hide for a host without Tor.
A Scanning sample with followingTip (the walletTipFollowProvider
rule: the wallet catching up to kWalletTipFollowBlocks new blocks after a
healthy UpToDate, usually one) counts as that UpToDate, judged at the
tip it scans to — else
the bar would slide in and out on every block (the S12 security review's
MEDIUM).
Implementation
bool walletSyncBarVisible({
required SyncStatus status,
required bool stale,
required bool driving,
required bool startFailed,
required bool syncDisabled,
required TransportTone transportTone,
required bool hostDeclaredTransport,
bool followingTip = false,
}) {
final steadyTransport =
transportTone == TransportTone.neutral ||
(transportTone == TransportTone.protected && hostDeclaredTransport);
final settled = switch (status) {
SyncStatus_UpToDate() => status,
SyncStatus_Scanning(:final to) when followingTip => SyncStatus.upToDate(
tip: to,
),
_ => null,
};
final healthy =
settled != null &&
driving &&
walletBadgeLevel(
status: settled,
stale: stale,
startFailed: startFailed,
syncDisabled: syncDisabled,
) ==
WalletBadgeLevel.ok &&
steadyTransport;
return !healthy;
}