scanPercent function

int scanPercent(
  1. double fraction
)

0..1 SCAN fraction → a whole percent that NEVER reads 100 before sync is actually done: round would show "Scanning 100%" at 0.995+ while the wallet is provably not up-to-date (the distinct UpToDate arm is the only honest 100%) — a money-honesty trap (a user trusts a partial balance as final). Floor, and cap at 99 while scanning.

Implementation

int scanPercent(double fraction) {
  final f = fraction.isFinite ? fraction.clamp(0.0, 1.0) : 0.0;
  final p = (f * 100).floor();
  return p >= 100 ? 99 : p;
}