Skip to content

bug(demo): broadcast transactions through the selected network endpoint #123

Description

@j-kon

The demo app allows users to choose a different Electrum server for Signet or Testnet. That selection is respected when syncing the wallet and fetching fee estimates, but it is not used when broadcasting a transaction.

The send flow creates its blockchain client using only the wallet network. BlockchainService.createClient() then reads from defaultEndpoints, so a transaction is always broadcast through the default server even when the user selected another one.

Steps to reproduce

  1. Load a Signet or Testnet wallet in the demo app.
  2. Open Change server and select a non-default server.
  3. Sync the wallet and open the Send screen.
  4. Build, confirm, and broadcast a transaction.
  5. Observe that the broadcast client is created from the network's default endpoint rather than the selected endpoint.

Expected behavior

Sync, fee estimation, and transaction broadcast should all use the endpoint selected for the active wallet's network.

Actual behavior

Sync and fee estimation use endpointConfigProvider, while broadcast calls blockchainClientFactoryProvider with record.network. The default factory delegates to BlockchainService.createClient(), which uses defaultEndpoints[network].

Why this matters

If someone changes servers because the default server is unavailable, wallet sync and fee estimates may work through the selected server while broadcasting still fails against the unavailable default. It also means the app does not honor the user's server and privacy choice for the most sensitive network action.

Relevant code

  • bdk_demo/lib/providers/network_endpoint_providers.dart resolves and stores the selected endpoint.
  • bdk_demo/lib/providers/blockchain_providers.dart passes the selected endpoint to wallet sync.
  • bdk_demo/lib/providers/send_providers.dart owns the broadcast client factory and fee-estimate endpoint selection.
  • bdk_demo/lib/features/send/send_page.dart requests a broadcast client for the active wallet network.
  • bdk_demo/lib/services/blockchain_service.dart creates clients from endpoint configuration.

Agreed implementation

Keep BlockchainClientFactory accepting WalletNetwork, resolve endpointConfigProvider(network) inside blockchainClientFactoryProvider, and create the client from that resolved endpoint. Add focused offline coverage for the UI-to-provider network boundary and the provider-to-service endpoint boundary.

Remove the unused backendForNetwork helper in a separate documented commit because it only reflects default endpoints and has no remaining callers.

This should remain separate from the transaction-history work in #102.

Activity

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

Metadata

Metadata

Assignees

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