Repository navigation
Conversation
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Olorunshogo
left a comment
There was a problem hiding this comment.
Concept ACK. Nice work fixing all five points from #266.
I tested bd6792a on regtest (Core v32.1.0, rpc backend). Labelling works, labels show up in transactions, unspent, unused_address and the REPL, and the checks for wrong txids and addresses work well. The labels file is owner-only, and a corrupt file doesn't break balance. fmt, clippy and the tests all pass.
I left two inline comments on import. Files with unknown types (like spscan in the BIP's own test vectors) fail completely. And with --strategy overwrite, a record that leaves out spendable or label wipes the existing value, so a frozen coin can become spendable again or lose its label.
This also needs a rebase. It conflicts with master in six files, including src/utils/types.rs, which #396 removed.
Happy to test again after the rebase.
| bitcoin-payment-instructions = { version = "0.7.0", optional = true} | ||
|
|
||
| async-hwi = { version = "0.0.35", features = ["specter", "coldcard", "ledger", "jade", "bitbox", "service"], optional = true} | ||
| bdk-labels = "0.2.2" |
There was a problem hiding this comment.
Should this be behind a labels feature, like message_signer and dns_payment? Also, there's an extra blank line added above async-hwi.
| An exported file replaces any file already at that path, and is only readable by its owner. When an imported label is for something that already has a label, `--strategy keep-existing` (the default) keeps the wallet's label and `--strategy overwrite` replaces it. A file that cannot be read in full is rejected, and nothing is imported from it. Labels for things the wallet does not know about are kept, so a file from another wallet can be imported before the wallet has synced. | ||
|
|
||
| > [!NOTE] | ||
| > BIP-329 output labels have a `spendable` flag, which other wallets use to mark a coin as frozen. `bdk-cli` stores and exports the flag, and labelling a UTXO never changes it, but importing `spendable: false` does not lock the coin in `bdk-cli`. To stop a UTXO from being spent, use the `lock_utxo` command. |
There was a problem hiding this comment.
"labelling a UTXO never changes it" is true for label, but import_labels --strategy overwrite can still change spendable (see my comment on offline.rs). Might need updating once that's fixed.
| }; | ||
| // The whole file is read before any label is merged, so a bad file imports nothing. | ||
| labelled | ||
| .import_labels(BufReader::new(file), self.strategy.into()) |
There was a problem hiding this comment.
Two things I hit when importing:
- If the file has a type that isn't one of the six known ones, the whole import fails. The BIP's own test vectors include
spscan, and importing them givesunknown variant 'spscan'. The BIP says unknown types should just be skipped. - With
--strategy overwrite, leaving a field out wipes the existing value. An output record withoutspendablemakes a frozen coin spendable again (it defaults totrue), and one withoutlabeldeletes the label. The BIP says left-out fields shouldn't change anything.
Since bdk-labels is your crate, it might be easier to fix both there.
Description
Adds BIP-329 wallet labels to
bdk-cli, using the standalonebdk-labelscrate 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(defaultkeep-existing), andexport_labels <file>.transactions,unspentandunused_addressshow alabelfield, left out when there is none.<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 gainswallet_name(mirroringOnlineOperations).Notes to the reviewers
This answers the five points in @vadim-anfv's review of PR #266:
—placeholder: gone. Unlabeled items have nolabelfield, so a real—label is distinguishable (a_dash_label_is_told_apart_from_no_label).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 tolock_utxo;.unused_addressshows the address label (unused_address_shows_its_label).labels_can_be_set_in_the_repl,labels_are_shown_in_the_repl).labels.jsonlbreaking every command:balancenever reads the file. Display commands warn and carry on.label,import_labelsandexport_labelsfail naming the file.Other behavior worth a look:
require_network, notparse_address.a_bad_import_file_changes_nothing).Testing:
bitcoindwith therpcbackend: funded a wallet, synced, and labelled a transaction and a UTXO.transactionsandunspentshowed the labels (also in the REPL),lock_utxoleft the label untouched, and renaming a coin withspendable:falsekept itfalse.just pre-pushChecklists
All Submissions:
cargo fmtandcargo clippybefore committingNew Features: