Skip to content

feat: add wallet-scoped activity tag reads (#136) - #141

Merged
coreyphillips merged 4 commits into
masterfrom
issue-136
Aug 28, 2026
Merged

feat: add wallet-scoped activity tag reads (#136)#141
coreyphillips merged 4 commits into
masterfrom
issue-136

Conversation

@coreyphillips

Copy link
Copy Markdown
Collaborator

Closes #136

Add get_activities_tags(wallet_id) and get_pre_activity_metadata_list(wallet_id), wallet-scoped reads of the tag-backup tables where None returns every scope.

The two tag-backup readers, get_all_activities_tags() and get_all_pre_activity_metadata(), take no wallet id, and the only scoped tag getter is get_tags(wallet_id, activity_id) for a single activity. An app that wants one wallet's tags has to fetch every scope and filter client-side, which makes a one-line app-side .filter { it.walletId == ... } the whole backup-scoping policy for records that go to a remote backup server. Dropping that line is invisible in review and silently widens what leaves the device.

What changed

  • ActivityDb::get_activities_tags(Option<&str>) in src/modules/activity/implementation.rs builds the same tag query with an optional WHERE wallet_id = ?1; get_all_activities_tags() now just calls it with None.
  • ActivityDb::get_pre_activity_metadata_list(Option<&str>) does the same for pre_activity_metadata; get_all_pre_activity_metadata() delegates to it with None.
  • Both scoped readers run the wallet id through the existing normalize_wallet_id, so a blank or whitespace-only scope is a typed error rather than a silent full-table read.
  • New UniFFI exports get_activities_tags(wallet_id: Option<String>) and get_pre_activity_metadata_list(wallet_id: Option<String>) in src/lib.rs. The existing unscoped exports are untouched, so no caller breaks.
  • README, module README and CHANGELOG document the new calls.

How to test

  • cargo test modules::activity, 193 pass, including the four new tests.
  • test_get_activities_tags_wallet_scoped and test_get_pre_activity_metadata_list_wallet_scoped each store one record under the default scope and one under a trezor:{64-hex} scope, then assert each scope returns only its own record, that None matches the legacy unscoped getter, and that an unknown scope returns empty.
  • test_get_activities_tags_rejects_blank_wallet_id and test_get_pre_activity_metadata_list_rejects_blank_wallet_id cover the whitespace-scope error.
  • cargo clippy --all-targets and cargo fmt --check are clean for the touched code.

Notes

Naming: the issue asks for get_activities_tags, which I used verbatim. The metadata equivalent could not drop all_ the same way because get_pre_activity_metadata(wallet_id, search_key, search_by_address) already exists and UniFFI function names are global, hence get_pre_activity_metadata_list. I added new functions rather than changing the existing signatures, so bitkit-android and bitkit-ios keep compiling; the acceptance criterion that unscoped behaviour stays available is met by both the old calls and by passing None. Generated bindings under bindings/ are not regenerated here. This repo does that in separate chore: regenerate bindings commits at release time via build.sh -r, and it needs the iOS/Android cross-compile toolchain, so the new functions are not yet visible to Swift/Kotlin/Python until that step runs. cargo test (full suite) has 11 pre-existing failures, all in modules::blocktank, from api.stag.blocktank.to being unreachable in this environment. They are unrelated to this change; the other 497 pass.

get_all_activities_tags() and get_all_pre_activity_metadata() take no wallet
id, so an app backing up a single wallet scope had to fetch every scope and
filter client-side. That filter is the app's entire backup-scoping policy and
is easy to drop in review, which silently changes which records leave the
device.

Add get_activities_tags(wallet_id) and get_pre_activity_metadata_list(wallet_id),
where None returns every scope. The unscoped getters are unchanged and delegate
to the new ones.
@coreyphillips

Copy link
Copy Markdown
Collaborator Author

Once approved I'll bump the version and rebuild the bindings.

@coreyphillips
coreyphillips requested a review from ovitrif August 27, 2026 17:26
Comment thread src/lib.rs
Exercise the exported get_activities_tags and get_pre_activity_metadata_list
through init_db and the global database, asserting Some(wallet_id) and None
semantics for both, so a wrapper that dropped wallet_id would fail the test.

@ovitrif ovitrif left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

utACK

@ovitrif

ovitrif commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Once approved I'll bump the version and rebuild the bindings.

Can you please rebase /bump version on top of #145 changes if @ben-kaufman can confirm it's ready for merge? so then we save a bit of bindings regen time 🙏🏻

@ben-kaufman

Copy link
Copy Markdown
Collaborator

Yes looks ready

@ovitrif

ovitrif commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Thanks @ben-kaufman 🙏🏻 , so now it should be easier, just merge with master and bump to 0.5.12 + re-bindgen cc @coreyphillips 🫡

@ovitrif
ovitrif self-requested a review August 28, 2026 18:03
Resolve conflicts:

- Version files (Cargo.toml, Cargo.lock, Package.swift, gradle.properties,
  setup.py): keep 0.5.12 from this branch, which is ahead of master's 0.5.11.
- CHANGELOG.md: adopt master's released version sections and keep only the
  wallet-scoped tag/metadata entry under Unreleased. The R8 consumer keep
  rules entry was dropped from Unreleased because master already released it
  as 0.5.9 and 0.5.11.
- Binary bindings (Android .so, iOS xcframework, Python dylib): regenerated
  from the merged source with ./build.sh all rather than picking a side, so
  they carry both the wallet-scoped getters and the watcher receive address
  changes. Package.swift checksum updated to match the new xcframework.
@coreyphillips
coreyphillips merged commit 5028865 into master Aug 28, 2026
@coreyphillips
coreyphillips deleted the issue-136 branch August 28, 2026 18:20
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.

feat: add wallet-scoped activity tag reads

3 participants