Skip to content

Conversation

@kallewoof
Copy link
Contributor

This allows a user to derive the addresses for some privkey without first having to derive the descriptor checksum.

Alternative to #24161.

@kallewoof kallewoof force-pushed the 202201-deriveaddr-nochecksum branch from 12300e9 to 48e9935 Compare January 26, 2022 06:37
Copy link
Contributor

@shaavan shaavan left a comment

Choose a reason for hiding this comment

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

Concept NACK

The purpose of checksum is to ensure the integrity of data and ensure that the data has not been wrongly entered or tampered with.

  • Say you use a misspelled private key and used it to generate an address. Any bitcoin received on that address would potentially be unrecoverable and hence burned, which is a potentially very devastating situation.

Though I understand this feature can be helpful for someone regularly transacting with the same key, and hence is familiar with the risk and how to ensure the integrity of the key. Still, the potential risk involved makes this feature not worth the risk.

@kallewoof
Copy link
Contributor Author

kallewoof commented Jan 26, 2022

The purpose of checksum is to ensure the integrity of data and ensure that the data has not been wrongly entered or tampered with.

The descriptor checksum, yes. The WIF format (private key) already has a built-in checksum.

See the alternative, where the descriptor checksum is derived using getdescriptorinfo first, before being passed to deriveaddresses. The scenario is identical, but it requires an extra step due to the checksum requirement.

  • Say you use a misspelled private key and used it to generate an address. Any bitcoin received on that address would potentially be unrecoverable and hence burned, which is a potentially very devastating situation.

It would fail. The WIF format includes a checksum. Besides, a WIF privkey that had a typo and still passed the WIF checksum would be a valid private key, and all derived addresses would thus be valid recipients for whoever held that private key.

@shaavan
Copy link
Contributor

shaavan commented Jan 26, 2022

It would fail. The WIF format includes a checksum.

I checked it, and it seems like it is correct.

I took the private key present in the example to derive addresses on this PR. It worked correctly as expected.
Screenshot from 2022-01-26 17-06-00

However, when I made the following change to the private key to simulate a typo:
(The tenth digit has been changed from 8 -> 2)

- cPsQTSmMZ8e3AEUWGjS73f5R364yJxH6RxcgnwbHjbKbFPUP2Dtu
+ cPsQTSmMZ2e3AEUWGjS73f5R364yJxH6RxcgnwbHjbKbFPUP2Dtu

The expression failed, showing that the private key was invalid.

Screenshot from 2022-01-26 17-08-11

I have retracted my NACK from the last review. Let me do some further reviewing before forming a decision on this PR.

I was curious about one thing, though. I went to some forums and saw WIF had been around for a long time now. Why was this redundant 2-step behavior of deriveaddresses was not addressed earlier?

@kallewoof
Copy link
Contributor Author

I was curious about one thing, though. I went to some forums and saw WIF had been around for a long time now. Why was this redundant 2-step behavior of deriveaddresses was not addressed earlier?

I believe deriveaddresses is fairly new, and the "find all addresses" use case, while useful, was probably not high priority.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 26, 2022

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #26039 (rpc: Run type check against RPCArgs (1/2) by MarcoFalke)
  • #25366 (util, rpc: Add parameter to deriveaddresses to display address information by w0xlt)
  • #24161 (rpc/doc: describe using combo(privkey) to get checksum and then list … by kallewoof)
  • #23549 (Add scanblocks RPC call (attempt 2) by jamesob)
  • #22838 (descriptors: Be able to specify change and receiving in a single descriptor string 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.

@Sjors
Copy link
Member

Sjors commented Jan 27, 2022

Concept ACK

@kallewoof kallewoof force-pushed the 202201-deriveaddr-nochecksum branch from 48e9935 to 8d3c91d Compare January 28, 2022 01:17
Copy link
Member

@Sjors Sjors left a comment

Choose a reason for hiding this comment

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

utACK 8d3c91d04931c9a2ad44ca04175944c617fe149e

Note that there are several things we typically put in a descriptor that already have a checksum, namely the xpriv and xpub. The main scenario where it doesn't make sense to use a descriptor checksum, is when you have to generate the descriptor manually. That's clearly the case if you import a WIF from some older software or a paper backup. But there may be watch-only scenario's too, as many wallet software supports the export of a single xpub. That's why I removed the emphasis on "private key" in the help text below.

@kallewoof kallewoof force-pushed the 202201-deriveaddr-nochecksum branch from 8d3c91d to e34c8e1 Compare January 28, 2022 09:12
@Sjors
Copy link
Member

Sjors commented Jan 28, 2022

re-utACK e34c8e1b63628986d496b5f7bb29addac50e459a

@kallewoof kallewoof force-pushed the 202201-deriveaddr-nochecksum branch 2 times, most recently from 4068e78 to eea9178 Compare January 31, 2022 05:50
Copy link
Contributor

@shaavan shaavan 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

Changes since my last review:

  • require_checksum has been moved from a positional argument to an option. This is done according to the reasoning given by @luke-jr in the above comment, with which I agree.
  • Slight rewording of the require_checksum help message. I prefer the new wordings as it better explains the working if the checksum is provided.

I agree with the idea of keeping the checksum as an optional part for deriving address than as a mandatory part. Since the WIF already has an in-built checksum, it doesn't necessarily need the redundant checksum part.
These changes allow the user to remove the extra step of getting the checksum before deriving the address. This PR also preserves the old behavior if a user prefers to take the traditional approach of deriving addresses.

I was NOT able to test the working of this RPC successfully. I used the string given in the example to test deriveaddresses, but it failed with the following error.

error: Error parsing JSON: {require_checksum:

Screenshot:

Screenshot from 2022-01-31 14-28-34

@Sjors
Copy link
Member

Sjors commented Jan 31, 2022

@shaavan the JSON object needs to be wrapped with single quotes: '{....}'. This is what makes option objects a bit annoying to use.

@kallewoof
Copy link
Contributor Author

Alternatively you can do "{\"require_checksum\": false}".

@shaavan
Copy link
Contributor

shaavan commented Jan 31, 2022

Both of these methods worked correctly:

Screenshot from 2022-01-31 16-51-42

@kallewoof
I think the help message should be updated to indicate one of these methods:

  • '{"require_checksum": false}'
  • "{\"require_checksum\": false}"

@Sjors

This is what makes option objects a bit annoying to use.

Do we have any alternatives to the options object? Or some way to bypass this annoying behavior?

@kallewoof
Copy link
Contributor Author

kallewoof commented Jan 31, 2022

@shaavan
Good point, I've updated the help text to use single quotes.

Do we have any alternatives to the options object? Or some way to bypass this annoying behavior?

Ultimately having an options object rather than stacking on new parameters as we go turns out to be a generally better and more easy to use approach. I think you'll get used to it eventually. :)

@kallewoof kallewoof force-pushed the 202201-deriveaddr-nochecksum branch from eea9178 to 1375e9f Compare January 31, 2022 11:43
@Sjors
Copy link
Member

Sjors commented Jan 31, 2022

Do we have any alternatives to the options object? Or some way to bypass this annoying behavior?

There's #15448

@kallewoof kallewoof force-pushed the 202201-deriveaddr-nochecksum branch from 1375e9f to 5a9587c Compare February 1, 2022 06:33
Copy link
Contributor

@shaavan shaavan left a comment

Choose a reason for hiding this comment

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

ACK 5a9587c5701a4df51c11cea075128ca6e6898681

Changes since my last review:

  • Updated RPC help message example. The example command now works correctly.
  • Rebased over master.

I was able to compile the updated PR on Ubuntu 20.04 successfully. The example is working perfectly as well.

Screenshot:
Screenshot from 2022-02-01 17-23-42

@Sjors

There's #15448

Let me take a look at it.

@kallewoof kallewoof force-pushed the 202201-deriveaddr-nochecksum branch from 5a9587c to 04dfe24 Compare February 4, 2022 05:42
@kallewoof
Copy link
Contributor Author

"checked" → "verified".

@kallewoof kallewoof force-pushed the 202201-deriveaddr-nochecksum branch from 29b896b to 1345e8d Compare February 7, 2022 11:10
@achow101 achow101 requested a review from Sjors March 11, 2022 16:58
@Sjors
Copy link
Member

Sjors commented Mar 16, 2022

re-utACK 1345e8d817acd316b71f23315f0996580253ade3

This allows a user to derive the addresses for some privkey without first having to derive the descriptor checksum.
@kallewoof kallewoof force-pushed the 202201-deriveaddr-nochecksum branch from 1345e8d to 97a69e2 Compare May 7, 2022 14:38
@Sjors
Copy link
Member

Sjors commented May 10, 2022

tACK 97a69e2

CI failures seem spurious.

Might be worth adding a test.

Maybe @achow101 can bless this PR too?

@kallewoof
Copy link
Contributor Author

CI failures seem spurious.

Thanks, didn't realize there were failures. Re-ran → passed.

Copy link
Contributor

@shaavan shaavan left a comment

Choose a reason for hiding this comment

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

reACK 97a69e2

Changes since my last review:

  • “checked” → “verified”. In the context of checksum, “verify” seems like a better choice of words.
  • “all addresses” → “the PKH address”, as well as used a pkh() example instead of combo(). I think that is the right approach as this encourages the user to specify which type of address they would like to derive.

luke-jr added a commit to luke-jr/bitcoin that referenced this pull request May 21, 2022
This allows a user to derive the addresses for some privkey without first having to derive the descriptor checksum.

Github-Pull: bitcoin#24162
Rebased-From: 97a69e2
Copy link
Contributor

@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

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

Code Review ACK 97a69e2

Perhaps require_checksum could be a parameter by itself instead of being the only item in options.

@kallewoof
Copy link
Contributor Author

Thanks for the review!

Perhaps require_checksum could be a parameter by itself instead of being the only item in options.

The idea is that any new parameters in the future will also go into options. That turns out to be easier when you e.g. want to deprecate a parameter (see e.g. the first argument to getbalance which had to be converted into a 'dummy' argument, to avoid having to change the indices of arguments).

@DrahtBot
Copy link
Contributor

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

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

@DrahtBot
Copy link
Contributor

There hasn't been much activity lately and the patch still needs rebase. What is the status here?

  • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
  • Is it no longer relevant? ➡️ Please close.
  • Did the author lose interest or time to work on this? ➡️ Please close it and mark it 'Up for grabs' with the label, so that it can be picked up in the future.

1 similar comment
@DrahtBot
Copy link
Contributor

There hasn't been much activity lately and the patch still needs rebase. What is the status here?

  • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
  • Is it no longer relevant? ➡️ Please close.
  • Did the author lose interest or time to work on this? ➡️ Please close it and mark it 'Up for grabs' with the label, so that it can be picked up in the future.

@kallewoof kallewoof closed this Apr 11, 2023
@kallewoof kallewoof deleted the 202201-deriveaddr-nochecksum branch April 11, 2023 04:43
luke-jr pushed a commit to luke-jr/bitcoin that referenced this pull request Aug 16, 2023
This allows a user to derive the addresses for some privkey without first having to derive the descriptor checksum.

Github-Pull: bitcoin#24162
Rebased-From: 97a69e2
Retropex pushed a commit to Retropex/bitcoin that referenced this pull request Mar 28, 2024
This allows a user to derive the addresses for some privkey without first having to derive the descriptor checksum.

Github-Pull: bitcoin#24162
Rebased-From: 97a69e2
@bitcoin bitcoin locked and limited conversation to collaborators Apr 10, 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.

7 participants