Skip to content

feat: scaffold transaction presentation in bdk_demo active wallet flow#62

Open
j-kon wants to merge 3 commits intobitcoindevkit:mainfrom
j-kon:feat/bdk-demo-transaction-scaffold
Open

feat: scaffold transaction presentation in bdk_demo active wallet flow#62
j-kon wants to merge 3 commits intobitcoindevkit:mainfrom
j-kon:feat/bdk-demo-transaction-scaffold

Conversation

@j-kon
Copy link
Copy Markdown
Contributor

@j-kon j-kon commented Mar 23, 2026

Summary

Adds a transaction detail flow to the reference wallet scaffold.

What changed

  • enabled navigation from transaction list to a transaction detail page
  • added TransactionDetailPage to display:
    • full txid
    • amount
    • status
    • block height
    • timestamp
  • introduced WalletService.loadTransactionByTxid
  • made transaction rows tappable using Material/InkWell
  • refactored widget tests with FakeWalletService
  • added tests for:
    • navigation to detail page
    • correct transaction rendering
    • handling missing transactions gracefully

Notes

  • uses placeholder transaction data
  • structured for future real wallet/BDK integration

@reez
Copy link
Copy Markdown
Collaborator

reez commented Mar 23, 2026

@Johnosezele cc

@reez
Copy link
Copy Markdown
Collaborator

reez commented Mar 24, 2026

Nice improvement to the demo flow and the widget coverage is solid.

I found one correctness issue before approval: TransactionDetailPage caches its future in initState, but go_router keys matched pages by the route pattern, so changing /transactions/:txid can reuse the same State and leave the screen showing the old transaction. Once that lifecycle case is handled, this is looking pretty good to merge.

@j-kon
Copy link
Copy Markdown
Contributor Author

j-kon commented Mar 24, 2026

Nice improvement to the demo flow and the widget coverage is solid.

I found one correctness issue before approval: TransactionDetailPage caches its future in initState, but go_router keys matched pages by the route pattern, so changing /transactions/:txid can reuse the same State and leave the screen showing the old transaction. Once that lifecycle case is handled, this is looking pretty good to merge.

Good catch, that makes sense.

I’ll update the page to handle route changes properly instead of caching in initState.

@j-kon
Copy link
Copy Markdown
Contributor Author

j-kon commented Mar 24, 2026

Good catch on that — makes sense.

I’ve fixed it by refreshing the cached future in didUpdateWidget whenever the txid changes, so the page no longer shows stale transaction data when the route is reused.

Also added a widget test to cover this exact case (same page instance, different txid).

Everything’s passing on my end. Happy to adjust if you prefer a different approach.

CC @reez

Copy link
Copy Markdown
Contributor

@Johnosezele Johnosezele left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on! Great changes in the UI side of things.

I recognize this as a scaffold pr but I think there's some mixup from the ground up

You're not fetching transaction details from CanonicalTx of bdk.dart where sent/received come from wallet.sentAndReceived().

For your changes on the wallet_service.dart file, you are mostly return hardcoded placeholder data, you're not making use of our bdk.dart bindings api, I can't see any of the related methods, can you take a look at this commit. By extension this has a huge impact on wallet_providers.dart

For the test section of your PR, We'd need to structure /bdk_demo/test because as our test suite grows things may begin to look tightly coupled, part of what I did in the /test section of this commit which is still draft.

@reez pls can you hold off on merging this just yet, there seem to be alot of parallel implementation conflict as this is a scaffold pr, it would need to be rebased due to lots of conflicting changes with [this](https://github.com/bitcoindevkit/bdk-dart/pull/61)

# BDK-Dart Wallet (Flutter)

The _BDK-Dart Wallet_ is a wallet built as a reference app for the [bitcoindevkit](https://github.com/bitcoindevkit) on Flutter using [bdk-dart](https://github.com/bitcoindevkit/bdk-dart). This repository is not intended to produce a production-ready wallet, the app only works on Signet, Testnet 3, and Regtest.
The _BDK-Dart Wallet_ is a Flutter reference app for [bitcoindevkit](https://github.com/bitcoindevkit) using [bdk-dart](https://github.com/bitcoindevkit/bdk-dart). It is intentionally a demo and scaffold, not a production-ready wallet, and currently targets Signet, Testnet 3, and Regtest.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see some change in description here that may not be related to this pr, is this intentional?

The demo app is built with the following goals in mind:
1. Be a reference application for the `bdk_dart` API on Flutter (iOS & Android).
2. Showcase the core features of the bitcoindevkit library: wallet creation, recovery, Esplora/Electrum sync, send, receive, and transaction history.
2. Sketch the wallet creation, recovery, sync, send, receive, and transaction-history flows the app can grow into over time.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here as my comment above, if you can maybe add readme update as a separate commit.

Comment on lines +21 to +30
class _TransactionDetailPageState extends ConsumerState<TransactionDetailPage> {
late final Future<TxDetails?> _transactionFuture;

@override
void initState() {
super.initState();
_transactionFuture = ref
.read(walletServiceProvider)
.loadTransactionByTxid(widget.txid);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_transactionFuture is cached in initState as late final. If go_router reuses the same state object with a different txid (which happens when navigating between /transactions/:txid1 and /transactions/:txid2), the page will show stale data.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you consider moving shared helper widgets (_InfoCard, _LoadingCard, _DetailRow, _StatusChip) to features/shared/widgets/ since similar widgets are duplicated in transaction_detail_page.dart too.

_StatusChip and _DetailRow are defined almost identically in both active_wallets_page.dart and transaction_detail_page.dart. Can you extract them to a shared location.

Comment on lines +26 to +27
String get shortTxid => txid.length > 10
? '${txid.substring(0, 6)}...${txid.substring(txid.length - 4)}'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make shortTxid delegate to Formatters.abbreviateTxid(txid) or remove one, they are two impl of same logic.

.read(walletServiceProvider)
.loadTransactionByTxid(widget.txid);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider adding test verifying that navigating from one transaction to another correctly refreshes the detail page.

return;
}

await Future<void>.delayed(Duration.zero);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could this be removed? Is there a specific reason for it?

@j-kon
Copy link
Copy Markdown
Contributor Author

j-kon commented Mar 25, 2026

Thanks a lot for the detailed review — this really helps.

I see what you mean about the mixup with using placeholder data instead of wiring through the bdk.dart APIs, and also the structure concerns around the demo/tests.

I’ll take a step back and align this properly with the existing architecture, rework the service layer to use CanonicalTx / wallet APIs, and clean up the structure as suggested.

Also noted on the README and shared widgets — I’ll split those changes out and refactor accordingly.

Appreciate the guidance here 🙏

@reez
Copy link
Copy Markdown
Collaborator

reez commented Apr 7, 2026

merged #61 so can rebase this branch

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.

3 participants