Skip to content

fix(demo): use selected endpoint for transaction broadcast - #126

Open
j-kon wants to merge 1 commit into
bitcoindevkit:mainfrom
j-kon:fix/demo-selected-broadcast-endpoint
Open

fix(demo): use selected endpoint for transaction broadcast#126
j-kon wants to merge 1 commit into
bitcoindevkit:mainfrom
j-kon:fix/demo-selected-broadcast-endpoint

Conversation

@j-kon

@j-kon j-kon commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • create broadcast clients from the resolved EndpointConfig
  • keep the existing network-based client helper for callers that want defaults
  • cover the selected-endpoint path in the service and Send page tests

Why

Wallet sync and fee estimates already honor the server selected in the demo app, but transaction broadcast created a new client from defaultEndpoints. This meant switching away from an unavailable default server could restore sync while sends still tried the unavailable server.

The send flow now resolves the active network's selected endpoint and passes that exact configuration to the broadcast client factory.

Validation

  • dart format --output=none --set-exit-if-changed bdk_demo/lib bdk_demo/test
  • dart analyze --fatal-infos --fatal-warnings lib test example
  • flutter analyze
  • dart test
  • flutter test

The repository-wide format command was also checked. Local Dart 3.12.2 flags the unchanged generated lib/bdk.dart, while all changed demo files are clean; CI uses Dart 3.10.0.

Closes #123

@j-kon
j-kon marked this pull request as ready for review August 11, 2026 22:38
@j-kon

j-kon commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Hi @Johnosezele, this is ready for review when you have a chance. It implements the selected broadcast endpoint fix discussed in #123.

@Shamsudeen12

Copy link
Copy Markdown

Not blocking, just something I noticed while reading through: backendForNetwork still resolves from defaultEndpoints, so it answers "what backend does this network use by default" rather than "what backend is the user actually connected to." Right now, it doesn't matter since it's only called from tests, and every endpoint option within a network happens to be the same client type anyway. But if we ever add a mixed list for a network, say an Esplora option alongside the Electrum ones on testnet, it would quietly report the wrong backend for anyone without a default endpoint. Might be worth a follow-up to either route it through the resolved endpoint config like the rest of this PR does, or just remove it since nothing in the app uses it.

@Ugarba202

Copy link
Copy Markdown
Contributor

tACK f91ca62 on Linux. tested locally across send_page_test.dart and blockchain_service_test.dart everything is green and static analysis is clean. verified that broadcasting now resolves through endpointConfigProvider and passes the active EndpointConfig directly to the client factory.
Also agree with @Shamsudeen12 that backendForNetwork can be cleaned up or refactored to backendForEndpoint in a quick follow-up, but the core fix here for #123 is clean.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants