Skip to content

wallet, rpc: Implements set key label functionality - #36126

Draft
polespinasa wants to merge 11 commits into
bitcoin:masterfrom
polespinasa:2026-08-28-setkeylabel
Draft

polespinasa wants to merge 11 commits into
bitcoin:masterfrom
polespinasa:2026-08-28-setkeylabel

Conversation

@polespinasa

Copy link
Copy Markdown
Member

Part of #35645

Adds a key label record to the wallet database so master keys can be identified by a label.
Also adds three new RPC calls, setkeylabel, getkeylabel and listkeylabels which allow to set, read and list all key labels for master keys.
Also adds four new interfaces so the GUI can consume those functionality too and list in, for example, a multisig setup labels associated to the keys. See https://gist.github.com/pseudoramdom/4e14d21a93323217cfe016885285b9aa for a visual example.

@DrahtBot

DrahtBot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/36126.

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
Concept NACK achow101, rkrux
Concept ACK jeanpablojp, Eunovo
Approach ACK vicjuma

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #35998 (wallet: Handle or explicitly ignore WalletBatch write failures by achow101)
  • #33034 (wallet: Store transactions in a separate sqlite table by achow101)
  • #32895 (wallet: Prepare for future upgrades by recording versions of last client to open and decrypt by achow101)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@DrahtBot

Copy link
Copy Markdown
Contributor

🚧 At least one of the CI tasks failed.
Task iwyu: https://github.com/bitcoin/bitcoin/actions/runs/33377440526/job/99441988368
LLM reason (✨ experimental): CI failed because IWYU detected missing/incorrect includes (failure generated from the IWYU check).

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

@polespinasa
polespinasa force-pushed the 2026-08-28-setkeylabel branch 4 times, most recently from 5b3c147 to 0009793 Compare August 31, 2026 12:18
Comment thread src/wallet/rpc/addresses.cpp Resolved

@jeanpablojp jeanpablojp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Concept ACK

The RPCs call CWallet directly, so the four new interfaces::Wallet methods end up with no caller and no test. The mining RPCs go through interfaces::Mining. Worth the same here?

Built the ten commits and ran the new test.

Comment thread src/wallet/rpc/addresses.cpp Resolved
Comment thread src/wallet/wallet.cpp Resolved
Comment thread src/wallet/interfaces.cpp Resolved
Comment thread src/wallet/rpc/addresses.cpp Resolved
Comment thread test/functional/wallet_keylabels.py Resolved
Comment thread src/wallet/wallet.cpp Resolved
@polespinasa

polespinasa commented Aug 31, 2026 •

Copy link
Copy Markdown
Member Author

The RPCs call CWallet directly, so the four new interfaces::Wallet methods end up with no caller and no test. The mining RPCs go through interfaces::Mining. Worth the same here?

No, for the wallet we decided in the past to not mix the RPC and the interfaces.
See previous discussions in #34861 (comment) and #35436 (comment) (+ responses below).

@polespinasa
polespinasa force-pushed the 2026-08-28-setkeylabel branch 2 times, most recently from 415119f to 2f54fda Compare August 31, 2026 18:31
@polespinasa
polespinasa force-pushed the 2026-08-28-setkeylabel branch 3 times, most recently from ca3422f to 2c6734f Compare August 31, 2026 20:25
@polespinasa
polespinasa force-pushed the 2026-08-28-setkeylabel branch 2 times, most recently from 84bb3d9 to 64e1fc6 Compare August 31, 2026 20:52
Comment thread doc/release-notes-36126.md Resolved
@polespinasa
polespinasa force-pushed the 2026-08-28-setkeylabel branch 2 times, most recently from 3cca6a1 to 8b47c46 Compare September 1, 2026 08:58

@vicjuma vicjuma left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approach ACK

}
ret.pushKV("labels", std::move(labels));

// Per-key labels keyed by master fingerprint for every key corresponding to this address.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Regarding multisigs and cosigners, the getaddressinfo returns all the keys for multiple key addresses in the key_labels returned json field

Image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested the added RPCs, functioning as expected.

Image

@polespinasa

Copy link
Copy Markdown
Member Author

Force pushed to address some nits and also re:

I also think the new per-key label should be added to the output of gethdkeys

Done :)

@DrahtBot DrahtBot removed the CI failed label Sep 4, 2026
@achow101

achow101 commented Sep 7, 2026

Copy link
Copy Markdown
Member

NACK

Unless there was some discussion that I missed, this is not at all what we discussed for key labeling.

The key labeling that was discussed is for the GUI only to show friendly names for keys during the multisig setup. Once the setup is complete, the labels would not be shown again, and hence do not need to be stored in the wallet.

Also, DO NOT USE FINGERPRINTS, THEY ARE COLLIDABLE.

@davidgumberg

Copy link
Copy Markdown
Contributor

Shouldn't the key labels be persisted so that at signing time the user can see what keys have and haven't signed? I don't see a good reason to not persist key labels when it seems useful for UX.

@rkrux

rkrux commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Concept ~0 (tending towards NACK)

Maybe there's some benefit in showing labels in the GUI but I don't see much benefit in providing RPCs for setting or viewing key labels (both separately and within the context of address(es) RPCs). An organic use case would be the user creating a multi-sig wallet (2-2 or 2-3 or 3-5) and not be importing descriptors separately in that wallet later, so all the addresses of the wallet would involve the keys used to create the wallet.

I think we should keep it very simple while implementing a guided multi-sig flow and not make the user go through many steps.

@polespinasa

Copy link
Copy Markdown
Member Author

I don't see much benefit in providing RPCs for setting or viewing key labels (both separately and within the context of address(es) RPCs)

If we are finally adding some type of key labels, then there should be a way of adding, removing and viewing them using the RPC interface. Because if not, then we are adding something invisible for anyone not using the GUI.

I think we should keep it very simple while implementing a guided multi-sig flow and not make the user go through many steps.

I agree in that, but I don't think this makes the user go through many steps. The RPC is not an interface thought or designed for a user itself but for other applications to consume, normally users should stick to the GUI (if a good one is provided). That is why this PR also adds an interface for the GUI to consume, the GUI should take care of make all this process-easy.

I think the debate is more about the concept and if we actually want to store key labels, or not. Are they useful to identify multisig participants, see who is missing to sign, who already signed, etc (#36126 (comment)). Or if that is unnecessary information that the users can handle outside the wallet itself (#36126 (comment)).

@rkrux

rkrux commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

A more immediate need is for the end-users to have a guided multi-sig flow in the GUI that's easy to follow. Otherwise there already are (though a bit convoluted) ways for the end-users to setup multi-sig in the wallet. Adding key labels may be beneficial for the end-users using the GUI, I don't see why we need to prioritise for applications (RPCs) right now.

Adding the key label is an additional step in a workflow that the GUI doesn't even have right now. That's why my preference to keep things straightforward and get a working multi-sig GUI flow first.

It is not mandatory to have multiple people participating in the multi-sig. It is not mandatory to have different signing devices as well in the multi-sig. An end user can just want to have multiple keys created by the core wallet to be participating in the multi-sig wallet and they might not want to have to label each key. And in this scenario, they might not care which keys have signed as long as there are enough signatures.

There's a cost to maintaining features over time, and I would rather us not to have to bear the cost of something that might not be used as much. And hence, my reluctance to add this functionality at this stage.

@polespinasa

Copy link
Copy Markdown
Member Author

I don't see why we need to prioritise for applications (RPCs) right now.

This PR is not prioritizing RPCs, it is adding an interface for the GUI. At the same time it adds the RPC interface to also consume that functionality as I don't see the reason to have multiple PRs for it.

Adding the key label is an additional step in a workflow that the GUI doesn't even have right now. That's why my preference to keep things straightforward and get a working multi-sig GUI flow first.

Didn't understand that from your first message, I agree, this is not a must to allow multisig with the GUI.

As said, we should first discuss about if this should be added in the first place as seems that there isn't a consensus regarding the #35645 proposal. I though there was and that's why I opened this PR. IMHO it is a useful feature (it's something I've had before in other wallets and appreciated having, see p.e. Sparrow Wallet) and worth the, in my opinion, not to much burden to maintain.

But at the same time, the PR is not in a rush to get merged, so, for me, it is ok to stay open for a while while prioritizing other multisig PRs.

Will mark as draft for now until we decide if we want to include labels or not.

@polespinasa
polespinasa marked this pull request as draft September 10, 2026 12:14
Introduce a new `keylabel` wallet database record that maps a master key
fingerprint to an arbitrary label string. This is the persistence layer
for per-key labels, stored separately from the per-address name records.

Add WalletBatch::WriteKeyLabel/EraseKeyLabel, mirroring other Write/Erase functions.
The record is keyed by the fingerprint so that a single label covers every
address derived from the same root across all descriptor types.
Add CWallet::m_key_labels, a map from master key fingerprint to label that
mirrors the new `keylabel` DB records. Per-key labels augment, do not
replace, the per-address labels in m_address_book and never affect the
change/receive heuristic in CAddressBookData::IsChange().

Adds accesors for adding and removing key labels.
Also adds DecodeKeyFingerprnt helper function that will be used
for multiple RPC introduced in future commits.
@DrahtBot

DrahtBot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants