feat(spv): verify Merkle proofs progressively, gate spendability on it
Balance/history now render as soon as tx downloads finish instead of blocking on every historical Merkle proof, critical for mobile where proof-checking can take much longer than the download itself. Proofs continue to be checked in the background and each tx's Verified flag catches up progressively; header ranges are now fetched in batches (blockchain.block.headers) instead of one call per header to keep this fast over high-latency links. Coin selection (UtxoSpendability.IsSpendable) refuses to spend a UTXO until its Merkle proof is actually checked, regardless of confirmation count, so a server that fabricates a confirmed balance can get it displayed early but never spent before the forgery is caught. The disk cache only ever persists the fully-verified end state of a sync. UI surfaces the new PendingVerificationSats/SpendableSats split with a "verifying..." badge, and the sync save now runs off the UI thread to avoid freezing on slower hardware.
This commit is contained in:
@@ -37,4 +37,12 @@ public static class WalletStore
|
||||
File.WriteAllText(tmp, content);
|
||||
File.Move(tmp, path, overwrite: true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Same as <see cref="Save"/> but with the JSON serialization and disk write off the
|
||||
/// calling thread — for callers on a UI thread saving a large cache (thousands of cached
|
||||
/// transactions/headers), where the synchronous version would block the UI.
|
||||
/// </summary>
|
||||
public static Task SaveAsync(WalletDocument doc, string path, string? password = null) =>
|
||||
Task.Run(() => Save(doc, path, password));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user