Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warnings for non-active addresses in receive tab and address book #723

Closed
wants to merge 8 commits into from

Conversation

pinheadmz
Copy link
Contributor

@pinheadmz pinheadmz commented Mar 24, 2023

Closes bitcoin/bitcoin#3314
Built off of bitcoin/bitcoin#27216 (== first two commits of this PR, required core updates)

This PR adds a "warnings" column in the receive coins dialog (recent requests table) and the address book receive page. Hovering over the ⚠️ if present shows a tooltip with a list of warnings. We also add a "warnings" field in the receive request dialog (shown after double-clicking an address in the first table) with the same message.

The warnings shown can be anything implemented in new methods GetWarnings() but for now the only message we show there is:

This address should not be used. It was derived from an inactive seed, was imported, or may have been stored unencrypted.

Example screenshots:

1. Create new unencrypted wallet, get new receive address

1

2. Encrypt wallet

Notice how the first address is immediately flagged.

2

3. Get new receive address after encrypting wallet

New address is not flagged, it is active and safe to use.

3

@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 24, 2023

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

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept NACK luke-jr
Concept ACK RandyMcMillan, pablomartin4btc

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

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.

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

Quick GitHub review, will swing back and build/test.

A couple thoughts:

  • GetWarnings is already the name of a method in src/warnings; perhaps use a slightly different name.
  • Watch out for missing brackets in conditionals as mentioned in the developer notes; we require brackets with conditionals over one line due to CVE-2014-1266 (the Apple "goto fail" vulnerability, see also https://dwheeler.com/essays/apple-goto-fail).
  • Consider notating pure/getter-like or need-to-check-returned-value methods with [[nodiscard]]. As written recently here in the repo by martinus, a [[nodiscard]] attribute is most useful in two cases:
    • if a function has no effects beyond returning a certain result, i.e. is pure. If the result is not used, the call is certainly useless.
    • if the return value must be checked, e.g. for a C-like interface that returns error codes instead of throwing.

src/qt/addresstablemodel.cpp Outdated Show resolved Hide resolved
src/qt/addresstablemodel.cpp Outdated Show resolved Hide resolved
src/qt/addresstablemodel.cpp Outdated Show resolved Hide resolved
src/qt/addresstablemodel.h Outdated Show resolved Hide resolved
src/qt/receivecoinsdialog.cpp Outdated Show resolved Hide resolved
src/qt/walletmodel.cpp Outdated Show resolved Hide resolved
src/wallet/scriptpubkeyman.cpp Outdated Show resolved Hide resolved
src/wallet/wallet.cpp Outdated Show resolved Hide resolved
src/interfaces/wallet.h Outdated Show resolved Hide resolved
src/qt/recentrequeststablemodel.cpp Outdated Show resolved Hide resolved
@pinheadmz
Copy link
Contributor Author

Thanks for all the style notes @jonatack I addressed all your comments including adding a new struct for ReceiveRequest and renaming/qualifying the new method to [[nodiscard]] GetAddressWarnings(). Also addresed your nit in bitcoin/bitcoin#27216 and rebased both PRs on master.

@pinheadmz
Copy link
Contributor Author

I also moved the warnings column to the right, after date. I think we could just remove the title "warnings" and that column would narrow down to 1 character ...?

Screen Shot 2023-04-05 at 1 43 25 PM

@pinheadmz
Copy link
Contributor Author

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

Thanks D-bot! rebased.

This new method returns true if the given CScript key is derived
from the SPKM. For Legacy that means checking the hd_seed_id in the
key's metadata.

Also patches PKDescriptor to return associated public keys in
MakeScripts()
This connects SPKM.IsKeyActive() up to the wallet level.
@RandyMcMillan
Copy link
Contributor

Concept ACK

Tool tip and dialog field can be expanded in the future.
For now the first warning we show is if the address was
derived from a non-active seed or descriptor.
See bitcoin/bitcoin#3314
Tool tip can be expanded in the future.
For now the first warning we show is if the address was
derived from a non-active seed or descriptor.
See bitcoin/bitcoin#3314
@pinheadmz
Copy link
Contributor Author

Concept ACK

Thanks Randy! I just rebased on master to fix merge conflict. If you'd like to see this move forward, you can help my reviewing the parent Bitcoin Core PR: bitcoin/bitcoin#27216 🙏 ❤️

@DrahtBot
Copy link
Contributor

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

@luke-jr
Copy link
Member

luke-jr commented Jul 27, 2023

Concept NACK, there's no reason such an address shouldn't be used.

Closes bitcoin/bitcoin#3314

Except those categories are entirely unrelated to whether it's "active" or not.

@hebasto
Copy link
Member

hebasto commented Sep 22, 2023

Built off of bitcoin/bitcoin#27216 (== first two commits of this PR, required core updates)

While the base PR is still under reviewing, maybe convert this one to a draft?

@pinheadmz pinheadmz marked this pull request as draft September 22, 2023 18:20
Copy link
Contributor

@pablomartin4btc pablomartin4btc left a comment

Choose a reason for hiding this comment

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

Concept ACK

I'd prefer your suggestion of removing the title of the column or even removing the column completely and put the warning icon next to the date-time in the Date column as proposed by @jonasschnelli.

@pinheadmz
Copy link
Contributor Author

closing for now, #27216 needs better approach

@pinheadmz pinheadmz closed this Oct 12, 2023
@bitcoin-core bitcoin-core locked and limited conversation to collaborators Oct 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exposed / Compromised (must sweep) / Used / Imported (?) flags on addresses
7 participants