Skip to content

Descriptors#3908

Merged
benma merged 1 commit intoBitBoxSwiss:masterfrom
benma:descriptors
Apr 10, 2026
Merged

Descriptors#3908
benma merged 1 commit intoBitBoxSwiss:masterfrom
benma:descriptors

Conversation

@benma
Copy link
Copy Markdown
Contributor

@benma benma commented Mar 3, 2026

Also reworded the warning banner for Taproot:

Screenshot_2026-03-12_17-01-13

@benma
Copy link
Copy Markdown
Contributor Author

benma commented Mar 3, 2026

~~Closing this, it has a custom Go descriptor checksum implementation, while #3909 uses the descriptors-go. ~~

Re-opened, for now it seems better to use the port than to pull in a precompiled .wasm binary.

@benma benma closed this Mar 3, 2026
@benma benma reopened this Mar 5, 2026
@benma benma force-pushed the descriptors branch 2 times, most recently from 5742988 to ad11a48 Compare March 12, 2026 16:00
@benma benma marked this pull request as ready for review March 12, 2026 16:02
@benma benma requested a review from Beerosagos March 12, 2026 16:02
@benma
Copy link
Copy Markdown
Contributor Author

benma commented Mar 12, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad11a48996

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}
for _, cfg := range info.SigningConfigurations {
signingConfig := signingConfigurationInfo{}
if cfg.BitcoinSimple != nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Guard nil signing configs before dereferencing

getAccountInfo now unconditionally dereferences each cfg in info.SigningConfigurations, but Ethereum accounts can expose a nil entry before initialization (backend/coins/eth/account.go returns []*signing.Configuration{account.signingConfiguration} while account.signingConfiguration starts nil). In that state, calling /account/{code}/info will hit a nil-pointer panic here and return an API error instead of account info, so this loop should handle cfg == nil explicitly.

Useful? React with 👍 / 👎.

Comment thread frontends/web/src/routes/account/info/signingconfiguration.tsx

// Descriptor returns a descriptor for this configuration in the form
// SCRIPT([fingerprint/path]xpub-or-tpub/<0;1>/*)#checksum.
func (configuration *BitcoinSimple) Descriptor(net *chaincfg.Params) (string, error) {
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.

Why do we need to specify the net? Isn't it embedded in the xpub?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good question! I am not 100% sure if xpubs of testnet accounts were always serialized as tpub... in accounts.json, so this makes sure it is shown in the correct format.

We also explicitly set it for the normal xpub shown in the account info:


originPath := strings.TrimPrefix(configuration.KeyInfo.AbsoluteKeypath.Encode(), "m/")
keyOrigin := hex.EncodeToString(configuration.KeyInfo.RootFingerprint)
if originPath != "" {
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.

Does it make sense to go on without a keypath? Or should we error?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I would say this function should not be concerned with that, it is technically a valid descriptor even with an empty path too. Probably never going to be used like this by the app though, so it's a tossup 🤷‍♂️ any strong preference?

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.

Slight preference for returning an error, since the whole point is to include keypaths info. But no strong opinion.

Comment thread frontends/web/src/locales/en/app.json Outdated
"label": "Account info",
"scriptType": "Script type",
"taproot": "The Taproot extended public key is not shown to protect from accidental misuse, as raw formats for this script type are not widely supported. If you want to view this key, connect your device to wallet software that supports the output descriptor format.",
"taproot": "To import this account into another wallet, make sure it supports descriptors. Copy the <strong>full descriptor</strong>.\n<strong>Do not use only the xpub</strong>, or the wallet may import the account with the wrong script type.",
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.

Is this an issue for taproot only?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was going to say yes, because for the other types, the xpub is shown as ypub or zpub, so unambiguous. But you made me aware that users might attempt to copy only the xpub part inside the descriptor, which would be a big problem actually.

I think I'll show that info for all types, and right above the descriptor to mitigate that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, please check.

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.

I like having the banner also for native segwit, but now hiding the xpub only for taproot looks almost like a bug, imo. Would it be ok to keep the banner and the xpub in both places?

Another small thing: on native segwit the xpub is shown in the 'zpub' format when alone, but in the 'xpub' format inside the descriptor. Is it intended?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I would not show the xpub in Taproot even though it looks inconsistent, as it led to a ton of issues with stuck funds that could not be recovered with a BitBox - which was the reason we removed it in the first place. Better not risk it.

zpub alone and xpub in descriptor is intended, zpub is Electrum format and encodes that it is p2wpkh (adopted by many other wallets), while descriptors are explicit about what the script is and only use xpub/tpub.

@Beerosagos
Copy link
Copy Markdown
Collaborator

One more question: does it really make sense to both port the descriptor checksum code from bitcoin core and also import a new dep only to double check the result in the test? Can't we just use one of them?

@benma
Copy link
Copy Markdown
Contributor Author

benma commented Mar 25, 2026

One more question: does it really make sense to both port the descriptor checksum code from bitcoin core and also import a new dep only to double check the result in the test? Can't we just use one of them?

I had an alternative PR in #3909 that only uses the new dep, but @NickeZ and I discussed a bit the problem of pulling in an unvetted WASM binary for production code, and opted for not pulling it in for now.

If you prefer, I could remove the dep also for the tests, and instead inline a script to generate some test vectors?

@benma benma requested a review from Beerosagos March 25, 2026 21:42
@benma benma force-pushed the descriptors branch 4 times, most recently from e7b00e5 to cc573e8 Compare March 30, 2026 10:42
@Beerosagos
Copy link
Copy Markdown
Collaborator

If you prefer, I could remove the dep also for the tests, and instead inline a script to generate some test vectors?

That would be nice! But I don't know if it's worth the effort. Feel free to keep as is, if you prefer 👍

Copy link
Copy Markdown
Collaborator

@Beerosagos Beerosagos left a comment

Choose a reason for hiding this comment

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

LGTM

Returns the account descriptor that can be imported in third party
wallets that support descriptors.

See https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md.

This is especially important to be able to export/import Taproot
accounts, where the `xpub` alone can easily be confused for a legacy
p2pkh account. The descriptor contains the complete derivation info.
@benma benma merged commit 002c0a2 into BitBoxSwiss:master Apr 10, 2026
17 checks passed
@benma benma deleted the descriptors branch April 10, 2026 07:51
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.

3 participants