Skip to content

platform-wallet: token balance sync hides failed balance reads from callers #5771

Open

Description

@Claudius-Maginificent

TL;DR

When reading an identity's token balances fails, the wallet library hides the failure. Apps then show "no balance" or a zero balance for tokens nobody actually checked.

User story

As a wallet user, I want my app to tell me when it could not check a token balance, so that I never take "no balance" or "0" for a confirmed result.

Scenario

Steps to reproduce

  1. Register an identity's tokens for balance sync in platform-wallet.
  2. Make TokenAmount::fetch_many fail for one or every batch (network error, DAPI timeout).
  3. Call sync_now and read the token balances.

Actual behavior

sync_now returns () as if the pass succeeded. A token whose batch failed keeps its previous cached value, or its zero-valued registration placeholder when no value was ever fetched. The caller cannot tell a checked balance from an unchecked one.

Expected behavior

The caller learns which tokens were checked successfully and which reads failed, so it can show an unknown or error state instead of a confirmed absence or zero.

Detailed discussion

packages/rs-platform-wallet/src/manager/identity_sync.rs, sync_identity: on Err from TokenAmount::fetch_many, the batch is logged at warn and skipped ("leaving cache untouched for this batch"). If every batch fails, the function returns early. Neither case reaches the caller. The behavior is on v5.1-dev and on the revision Dash Evo Tool pins (575d961).

Partial failure is worse than total failure: when one batch succeeds and another fails, apply_fresh_balances runs, and the failed batch's tokens keep zero-valued registration placeholders. Readers of the cache then treat those zeros as known balances.

Suggested direction: return a structured per-token (or per-batch) outcome from the sync pass (Checked(Option<TokenAmount>) / Failed(error)), or record the read status next to each cached balance. Consumers such as Dash Evo Tool (dashpay/dash-evo-tool#1160) can then keep a token's state unknown when its read failed.

🤖 Co-authored by Claudius the Magnificent AI Agent

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions