Skip to content

Conversation

@Dmenec
Copy link

@Dmenec Dmenec commented Dec 11, 2025

Description

Fixes #1933, remove the usage of Debug on Display implemetations mentioned in #1881 (comment)

Changelog notice

  • Replaced Debug usage with Display messages for InsertDescriptorError, CalculateFeeError and StoreError.
  • InvalidMagicBytes now displays expected and actual bytes in hexadecimal instead of using Debug.
  • Added a new short_descriptor function to shorten descriptors for concise error output.
  • Added detailed SyncRequest Display for Esplora and Electrum examples.

Checklists

All Submissions:

  • I have signed all my commits
  • I followed the contribution guidelines
  • I ran just check, just fmt and just test before committing

Replace Debug-based formatting with user-friendly Display messages.

Add helper to shorten descriptors for concise error output.
Limited to 3 max shown items and added a suffix when there are additional entries.
@ValuedMammal ValuedMammal moved this to In Progress in BDK Chain Dec 12, 2025
@ValuedMammal ValuedMammal added this to the Chain 0.24.0 milestone Dec 12, 2025
@Dmenec Dmenec force-pushed the fix/no-debug-on-display-impls branch from 492114b to b73016e Compare December 14, 2025 14:57
@qatkk
Copy link

qatkk commented Dec 21, 2025

Concept ACK — this approach looks good, thanks for the changes. I ran the tests locally and they all passed.

While trying to recreate the initial issue’s scenario (#1933), I found that bdk_wallet master still references the older API names (list_canonical_txsfilter_chain_unspentsfilter_chain_txoutsfrom_genesis_hash), whereas this PR’s bdk_chain exposes the newer canonicalization API (canonical_iter) and LocalChain::from_genesis. As a result, building bdk_wallet against this PR failed. Is there any branch in bdk_wallet that already adopts the new APIs, so I can test against them?

I have a few small suggestions below. Most of these are nits, but since this PR is already addressing the area, I thought it’d be reasonable to mention them here:

  • It might be nice to add a CI to prevent using Debug for Display in future changes.

  • In the short_descriptor function, it could be useful to show the last 8 characters of the descriptor so the full checksum is visible.

  • A small note on InvalidMagicBytes: it might be helpful to also show any difference between the length of expected and received byte.

Copy link
Member

@evanlinjin evanlinjin left a comment

Choose a reason for hiding this comment

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

Quality work.

Just a couple requested changes:

  • Commit messages should contain a scope (as mentioned in the conventional commits spec). The scope should be the name of the package affected: core, chain, example, etc.
  • Commits that break the API should be marked with !.

And a nit:

  • Error messages should be somewhat consistent. I personally don't think we should suggest actions in the message, just state what the error is.

write!(
f,
"attempt to re-assign descriptor {descriptor:?} already assigned to {existing:?}"
"Descriptor '{}' is already in use by keychain '{}'. Please use a different descriptor.",
Copy link
Member

Choose a reason for hiding this comment

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

Nit

Suggested change
"Descriptor '{}' is already in use by keychain '{}'. Please use a different descriptor.",
"descriptor '{}' is already in use by another keychain '{}'",

write!(
f,
"attempt to re-assign keychain {keychain:?} already assigned to {existing:?}"
"Keychain '{}' is already associated with descriptor '{}'. Please choose a different keychain.",
Copy link
Member

Choose a reason for hiding this comment

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

Nit

Suggested change
"Keychain '{}' is already associated with descriptor '{}'. Please choose a different keychain.",
"keychain '{}' is already associated with another descriptor '{}'",


#[cfg(feature = "std")]
impl<K: core::fmt::Debug> std::error::Error for InsertDescriptorError<K> {}
impl<K: core::fmt::Display + core::fmt::Debug> std::error::Error for InsertDescriptorError<K> {}
Copy link
Member

Choose a reason for hiding this comment

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

Technically this is a breaking change, so it should be reflected in the commit message (!).

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

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Display implementations should not expose Debug output

4 participants