bitcoindevkit / bitcoindevkit/bdk-dart

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

Open
#123 1 comment 0 reactions 1 assignee Claimed by @j-kon View on GitHub
Dominant language
Dart
Stars
13
Forks
20
Avg merge
24m
Merged PRs (30d)
3

Description

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 only `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` uses the selected endpoint for fee estimates, but its blockchain client factory accepts only a `WalletNetwork`.
* `bdk_demo/lib/features/send/send_page.dart` creates the broadcast client from `record.network`.
* `bdk_demo/lib/services/blockchain_service.dart` resolves that network back to `defaultEndpoints`.

## Suggested direction

Pass the resolved `EndpointConfig` (or its client type and URL) into the broadcast client factory instead of resolving the network default again. A focused test should select a non-default endpoint and verify that the same endpoint is supplied when creating the broadcast client.

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.