Feat: Add bip329 wallet labels#266
Open
Musab1258 wants to merge 5 commits intobitcoindevkit:masterfrom
Open
Conversation
- Loads the \'Labels\' state from \'<wallet>.labels.jsonl\' after \'load_wallet_config\'. - Updates \'handle_offline_wallet_subcommand\' to accept mutable label state. - Exports and saves the in-memory labels to disk before the command return.
- Injects label lookups into the `unspent` and `transactions` match arms. - Updates the `--pretty` table formatting to include a new 'Label' column (using an em dash for missing labels). - Appends the label string to the standard JSON output
- Introduces the `Label` variant to `OfflineWalletSubCommand` with strict `clap` conflict rules. - Adds a `parse_txid` helper to utils.rs. - Implements an `add_or_add_update_label` helper in `handlers.rs` to mutate the in-memory label state in place.
Author
|
Hi @tvpeter, I am done with this. You can check it out when you are free. I will start working on the follow-up PR to add import and export of label files. |
- Introduces `ImportLabels` and `ExportLabels` variants to `OfflineWalletSubCommand` for CLI parsing. - Implements label merging from external JSONL files using `try_from_file` and `add_or_update_label`. - Enables backing up the current label state to a user-specified path using `export_to_file`.
Author
|
Hi @tvpeter, I eventually decided to add the import and export of BIP-329 JSONL files' implementation here when, after I was done with the implementation, I saw that it was something that could fit into this PR without bloating it. So, instead of creating a second PR and having reviewers go through the stress of reviewing two PRs that can probably fit into one, I decided to make it one PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds BIP-329 wallet label support to
bdk-cli, to fix #184. It uses the[bip329]crate to manage label data, persists it in a separatelabels.jsonlfile within the wallet's data directory (e.g.~/.bdk-bitcoin/<wallet_name>/labels.jsonl), and keeps it decoupled from the wallet's SQLite/redb database. It also exports and imports label files.This PR includes the following functionality:
labeloffline subcommand to attach a human-readable label to either a transaction ID, address, or UTXO (outpoint).unspentandtransactionscommands now include aLabelcolumn in both--prettytable output and standard JSON output, showing the stored label or an em dash if none exists.import_labelssubcommand merges labels from an external BIP-329 JSONL file into the wallet's current label state. If a label for the same item already exists, it is overwritten by the imported one.export_labelssubcommand writes the wallet's current label state to a user-specified BIP-329 JSONL file, suitable for backup or use in other BIP-329 compliant wallets.Notes to the reviewers
labels.jsonlfile rather than inside the wallet database. This keeps the label format portable and interoperable with other BIP-329 compliant wallets.Labelimport frombip329is aliased asBipLabelinhandlers.rsto avoid a name clash with theOfflineWalletSubCommand::Labelvariant brought into scope viause crate::commands::OfflineWalletSubCommand::*.import_labelscommand uses the existingadd_or_update_labelhelper to merge incoming labels one at a time, new label references are inserted, and existing label references are overwritten by the imported value.export_labelscommand writes to a user-specified path, which is independent of the wallet's internallabels.jsonlfile. The internal file is always managed automatically by the save-on-exit mechanism, so the two files remain separate.Changelog notice
Added
labelsubcommand toOfflineWalletSubCommandfor tagging transactions, addresses, and UTXOs with human-readable labels.import_labelssubcommand to merge labels from an external BIP-329 JSONL file into the wallet's current label state.export_labelssubcommand to back up the wallet's current label state to a user-specified BIP-329 JSONL file.labels.jsonlfile in the wallet data directory.Labelcolumn inunspentandtransactionsoutput (both--prettyand JSON).parse_txidhelper inutils.rs.bip329 = "0.4.0"dependency inCargo.toml.Checklists
All Submissions:
cargo fmtandcargo clippybefore committingNew Features:
CHANGELOG.mdBugfixes: