Skip to content

wallet: migrate tx reader to db.Store#1202

Draft
yyforyongyu wants to merge 12 commits intoimpl-tx-writer-storefrom
impl-tx-reader-store
Draft

wallet: migrate tx reader to db.Store#1202
yyforyongyu wants to merge 12 commits intoimpl-tx-writer-storefrom
impl-tx-reader-store

Conversation

@yyforyongyu
Copy link
Copy Markdown
Collaborator

Summary

  • add db-native tx detail queries and store methods for reader use
  • implement tx detail reads for SQL backends and the kvdb adapter
  • migrate wallet.GetTx and wallet.ListTxns to store-backed detail reads while preserving the public TxDetail API
  • move the legacy fetchTxDetails helper into wallet/txdetails_legacy.go so PSBT compatibility can keep using it without leaving legacy DB access in wallet/tx_reader.go

Testing

  • GOWORK=off go test ./wallet/internal/db/kvdb ./wallet -run 'TestGetTxDetail|TestGetTxSuccess|TestGetTxNotFound|TestBuildTxDetail|TestListTxnsSuccess'
  • GOWORK=off go test ./wallet/internal/db/... ./wallet
  • GOWORK=off go test ./... in wtxmgr
  • GOWORK=off go test ./... in waddrmgr
  • GOWORK=off make lint-check

Benchmarks

  • reader-path benchmark conclusion improves overall latency with negligible memory cost
  • sec/op geomean: -7.08%
  • B/op geomean: +0.35%
  • allocs/op geomean: +0.29%

@yyforyongyu yyforyongyu force-pushed the impl-tx-writer-store branch from cff5271 to a35e9f8 Compare March 30, 2026 13:22
@yyforyongyu yyforyongyu force-pushed the impl-tx-reader-store branch from 72b3c4b to fdf6435 Compare March 30, 2026 13:23
@yyforyongyu yyforyongyu force-pushed the impl-tx-writer-store branch from a35e9f8 to 61240bd Compare March 30, 2026 14:01
@yyforyongyu yyforyongyu force-pushed the impl-tx-reader-store branch from fdf6435 to 850ec52 Compare March 30, 2026 14:01
@saubyk saubyk added this to lnd v0.22 Mar 30, 2026
@saubyk saubyk moved this from Backlog to In progress in lnd v0.22 Mar 30, 2026
@yyforyongyu yyforyongyu force-pushed the impl-tx-reader-store branch from 850ec52 to 6f767cb Compare March 30, 2026 18:49
Add normalized owned-input and owned-output detail queries for
SQLite and Postgres, then regenerate sqlc so the transaction
reader work can build on a stable query shape.

Keep the existing summary APIs unchanged and defer the richer
read-model wiring to the follow-up commits.
Adapt the legacy wtxmgr transaction lookup into the db-native
summary model.

This lets the wallet reader use a fast path without depending
on detail reads.
Adapt the legacy range iterator into the db-native transaction
summary API.

Preserve the existing kvdb range semantics so the wallet reader
can use store.ListTxns for its fast path.
@yyforyongyu yyforyongyu force-pushed the impl-tx-writer-store branch from 61240bd to 921f6d3 Compare March 30, 2026 18:57
@yyforyongyu yyforyongyu force-pushed the impl-tx-reader-store branch from 6f767cb to 1efb8cf Compare March 30, 2026 18:57
Change the TxReader surface to use query structs on the
existing GetTx and ListTxns methods.

Keep the implementation on the legacy detailed reader path
until the summary and store-backed migrations land in later
commits.
Use the new query-based GetTx API to serve summary reads from
db.Store.GetTx while leaving the detailed path on the legacy
reader for now.

This lands the lightweight single-transaction fast path before
the store-backed detailed path arrives.
Introduce the db-native transaction detail types and add the
GetTxDetail method to the transaction store surface.

Implement the SQL-backed single-transaction detail read, teach
the kvdb adapter to provide the same shape, and keep the mock
store aligned with the expanded interface.
Use the query-based GetTx API to load detailed transaction
views from db.Store.GetTxDetail.

This removes the remaining legacy GetTx read path while keeping
the range reader on its older implementation for now.
Add db-native ranged transaction detail queries and store
methods so the query-based tx reader can fetch detailed history
without the legacy range builder.

Keep the kvdb adapter and wallet test mocks aligned with the
expanded store surface.
Use the query-based ListTxns API to serve summary history reads
from db.Store.ListTxns while preserving the legacy detailed
range reader.

This adds the wallet-side range normalization needed for the
lightweight history path.
Use the query-based ListTxns API to load detailed history from
db.Store.ListTxDetails.

This removes the remaining legacy ListTxns read path while
leaving the helper cleanup for the final follow-up commits.
Move the legacy fetchTxDetails helper out of tx_reader.go so
PSBT compatibility can keep using it without leaving walletdb
imports in the store-backed tx-reader implementation.

This is a compatibility-only file move with no behavior changes
for existing helper callers.
@yyforyongyu yyforyongyu force-pushed the impl-tx-reader-store branch from 1efb8cf to edf986b Compare March 30, 2026 19:20
Drop the dead production builder path from tx_reader.go now
that the query-based GetTx and ListTxns flows both use
db.Store-backed transaction shapes.

Keep fetchTxDetails in the legacy helper file so non-reader
callers still have a compatibility path.
@yyforyongyu yyforyongyu force-pushed the impl-tx-reader-store branch from af32521 to d2477fd Compare March 30, 2026 20:02
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.

2 participants