Skip to content

feat(labels): add BIP-329 wallet labels - #371

Open
Musab1258 wants to merge 4 commits into
bitcoindevkit:masterfrom
Musab1258:feat/bip329-label-commands
Open

Musab1258 wants to merge 4 commits into
bitcoindevkit:masterfrom
Musab1258:feat/bip329-label-commands

Conversation

@Musab1258

@Musab1258 Musab1258 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds BIP-329 wallet labels to bdk-cli, using the standalone bdk-labels crate as suggested by @notmandatory in PR #266. Fixes #184 . Supersedes #266, which I'll close very soon, as it no longer applies after the refactor.

  • label: attach a label to a transaction, a UTXO, or an address, with exactly one of --txid, --utxo, --address, and --text.
  • import_labels <file> with --strategy keep-existing|overwrite (default keep-existing), and export_labels <file>.
  • transactions, unspent and unused_address show a label field, left out when there is none.
  • Labels are stored in a BIP-329 JSONL file at <datadir>/<wallet>/labels.jsonl, owner-only, independent of the sqlite/redb wallet database.

Labels are loaded only by the commands that use them, never in OfflineOperations, which only gains wallet_name (mirroring OnlineOperations).

Notes to the reviewers

This answers the five points in @vadim-anfv's review of PR #266:

  1. — placeholder: gone. Unlabeled items have no label field, so a real — label is distinguishable (a_dash_label_is_told_apart_from_no_label).
  2. spendable: labelling a UTXO never changes it, and a coin frozen elsewhere stays frozen on a rename (labelling_a_utxo_keeps_it_spendable_or_frozen_as_it_was). It is stored and exported but not tied to lock_utxo;.
  3. Write-only address labels: unused_address shows the address label (unused_address_shows_its_label).
  4. REPL: labels can be set and shown in the REPL (labels_can_be_set_in_the_repl, labels_are_shown_in_the_repl).
  5. Corrupt labels.jsonl breaking every command: balance never reads the file. Display commands warn and carry on. label, import_labels and export_labels fail naming the file.

Other behavior worth a look:

  • Addresses are checked with require_network, not parse_address.
  • A transaction or UTXO must be known to the wallet, and the error says to sync first.
  • A bad import file imports nothing (a_bad_import_file_changes_nothing).

Testing:

  • Manually tested on regtest against a real bitcoind with the rpc backend: funded a wallet, synced, and labelled a transaction and a UTXO. transactions and unspent showed the labels (also in the REPL), lock_utxo left the label untouched, and renaming a coin with spendable:false kept it false.
  • All tests passed when I ran just pre-push
  • The display tests write transactions into a persisted wallet database instead of syncing, so they need no node.

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

@codecov

codecov Bot commented Oct 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.64179% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.05%. Comparing base (d2317d2) to head (bd6792a).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/handlers/offline.rs 96.07% 4 Missing ⚠️
src/utils/labels.rs 97.03% 4 Missing ⚠️
src/main.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #371      +/-   ##
==========================================
+ Coverage   59.08%   61.05%   +1.97%     
==========================================
  Files          25       26       +1     
  Lines        4646     4894     +248     
==========================================
+ Hits         2745     2988     +243     
- Misses       1901     1906       +5     
Flag Coverage Δ
rust 61.05% <96.64%> (+1.97%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

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

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Add BIP-329 wallet label support

1 participant