Skip to content

Conversation

@achow101
Copy link
Member

@achow101 achow101 commented Aug 2, 2019

Because it's nigh impossible to figure out what is wrong with a descriptor otherwise.

@fanquake fanquake added the Wallet label Aug 2, 2019
@sipa
Copy link
Member

sipa commented Aug 2, 2019

Descriptors are hard to parse, they should be hard to write also.

Eh, I mean, big concept ACK.

@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 3, 2019

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #16570 (Make descriptor tests deterministic by davereikher)
  • #15590 (Descriptor: add GetAddressType() and IsSegWit() by Sjors)

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.

@jb55
Copy link
Contributor

jb55 commented Aug 3, 2019 via email

1 similar comment
@Sjors
Copy link
Member

Sjors commented Aug 3, 2019

Concept ACK

Copy link
Contributor

@promag promag 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, nice to have a detailed error.

@hugohn
Copy link
Contributor

hugohn commented Aug 5, 2019

Concept ACK.

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.

ACK dae2590

This introduces a fun little trick if you're too lazy to call getdescriptorinfo to obtain the checkum: you can instead set the checksum to 00000000.

$ bitcoin-cli importmulti '[{"desc": "sh(wpkh(03fff97bd5755eeea420453a14355235d382f6472f8568a18b2f057a1460297556))#00000000", "timestamp": "now"}]'
[
  {
    "success": false,
    "error": {
      "code": -5,
      "message": "Descriptor is invalid, Provided checksum '00000000' does not match computed checksum 'qkrrc7je'"
    }
  }
]

Copy link
Member

Choose a reason for hiding this comment

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

nit: make descriptor errors start with lower case?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nah.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with @Sjors, is there a reason to not do so? I was going to suggest to drop "Descriptor is invalid, " prefix.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've just removed the prefixes.

Copy link
Member

Choose a reason for hiding this comment

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

They're back

Copy link
Member Author

Choose a reason for hiding this comment

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

They're back

No??

@achow101 achow101 force-pushed the descriptor-errors branch from dae2590 to 0d55f50 Compare August 6, 2019 19:38
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: expected_error could be const ref?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

I think I've bookmarked all errors without a test - not saying you should add them here, I'm happy to improve in a follow up.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with @Sjors, is there a reason to not do so? I was going to suggest to drop "Descriptor is invalid, " prefix.

@achow101 achow101 force-pushed the descriptor-errors branch from 0d55f50 to a1b4795 Compare August 8, 2019 20:17
@achow101
Copy link
Member Author

achow101 commented Aug 8, 2019

I've added more tests and also cleaned up a few typos in error messages.

@Sjors
Copy link
Member

Sjors commented Aug 9, 2019

reACK a1b47955838f1151fc1904d0ff3bc7751b9fa7ca

@jb55
Copy link
Contributor

jb55 commented Aug 10, 2019

Code Review ACK a1b47955838f1151fc1904d0ff3bc7751b9fa7ca

Copy link
Member

@instagibbs instagibbs left a comment

Choose a reason for hiding this comment

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

tACK

the errors I encountered during initial usage of descriptors are all caught here, and enough information to quickly figure out what I did wrong.

f.e.

getdescriptorinfo "multi(1, 03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd,04a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd5b8dec5235a0fa8722476c7709c02559e3aa73aa03918ba2d492eea75abea235)"
error code: -5
error message:
key ' 03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd' is not valid

^ space after comma

Copy link
Member

Choose a reason for hiding this comment

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

where would this case be hit previously?

Copy link
Member Author

Choose a reason for hiding this comment

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

It would fail below at the extkey decoding stuff.

Copy link
Member

Choose a reason for hiding this comment

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

where would this case be hit previously?

Copy link
Member Author

Choose a reason for hiding this comment

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

It would just get to the end of the function and hit return nullptr.

Copy link
Member

Choose a reason for hiding this comment

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

nit: I'd prefer it also checks for !Func explicitly, since there are a number of combinations, and a generic error is preferable to a specific error that's an implementation mistake.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think it can check that there is no function.

@Sjors
Copy link
Member

Sjors commented Aug 14, 2019

If you need to make any changes, I suggest rebasing due to #14934 to be on the safe side. It still compiles and tests pass for me when I do that rebase locally though.

@DrahtBot
Copy link
Contributor

Needs rebase

@meshcollider
Copy link
Contributor

Sorry about the rebase again due to #15986

Once this is rebased I'll review and merge

Some failure conditions implicitly fail by failing some other check.
But the error messages are more helpful if they say explicitly what
actually caused the failure, so add those as failure conditions and
errors.
@achow101
Copy link
Member Author

Rebased

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.

Only the first commit changed in this rebase, but you lost a few of your recent fixes in the process.

Copy link
Member

Choose a reason for hiding this comment

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

They're back

@achow101
Copy link
Member Author

Only the first commit changed in this rebase, but you lost a few of your recent fixes in the process.

No??? Are you sure you're looking at the right commits? The latest diff includes everything that was commented on earlier.

@Sjors
Copy link
Member

Sjors commented Aug 17, 2019

Ah wait, I see these changes happen in 625534d.

ACK 787c9ec

Copy link
Contributor

@meshcollider meshcollider 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 787c9ec

This is a nice change, one tiny nit but it is pretty insignificant so I'll merge this tomorrow if you don't have time to fix it now

if (origin_split.size() == 1) return ParsePubkeyInner(origin_split[0], permit_uncompressed, out, error);
if (origin_split[0].size() < 1 || origin_split[0][0] != '[') {
error = strprintf("Key origin expected but not found, got '%s' instead", std::string(origin_split[0].begin(), origin_split[0].end()));
error = strprintf("Key origin start '[ character expected but not found, got '%c' instead", origin_split[0][0]);
Copy link
Contributor

Choose a reason for hiding this comment

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

mismatched ' (also in the corresponding test case)

meshcollider added a commit that referenced this pull request Aug 18, 2019
787c9ec Additional tests for other failure cases (Andrew Chow)
6e1ae58 Check error messages in descriptor tests (Andrew Chow)
625534d Give more errors for specific failure conditions (Andrew Chow)
c325f61 Return an error from descriptor Parse that gives more information about what failed (Andrew Chow)

Pull request description:

  Because it's nigh impossible to figure out what is wrong with a descriptor otherwise.

ACKs for top commit:
  Sjors:
    ACK 787c9ec
  meshcollider:
    Code review ACK 787c9ec

Tree-SHA512: 07c5deff127fd65507b96df2e4608b4f918e0cbd20b3b45b9ab5a05c2985a6efa9832079cf1e7f504305bfbb861019e93b96cc1574dd63b2ff0756b5928ece20
@meshcollider meshcollider merged commit 787c9ec into bitcoin:master Aug 18, 2019
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 19, 2019
…ptors

787c9ec Additional tests for other failure cases (Andrew Chow)
6e1ae58 Check error messages in descriptor tests (Andrew Chow)
625534d Give more errors for specific failure conditions (Andrew Chow)
c325f61 Return an error from descriptor Parse that gives more information about what failed (Andrew Chow)

Pull request description:

  Because it's nigh impossible to figure out what is wrong with a descriptor otherwise.

ACKs for top commit:
  Sjors:
    ACK 787c9ec
  meshcollider:
    Code review ACK 787c9ec

Tree-SHA512: 07c5deff127fd65507b96df2e4608b4f918e0cbd20b3b45b9ab5a05c2985a6efa9832079cf1e7f504305bfbb861019e93b96cc1574dd63b2ff0756b5928ece20
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jul 1, 2020
… more information about what failed

Summary:
bitcoin/bitcoin@c325f61

---

Depends on D6641

Partial backport of Core [[bitcoin/bitcoin#16542 | PR16542]]

Test Plan:
  ninja check
  ninja
  test_runner.py wallet_importmulti

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6642
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jul 1, 2020
Summary:
Some failure conditions implicitly fail by failing some other check.
But the error messages are more helpful if they say explicitly what
actually caused the failure, so add those as failure conditions and
errors.

bitcoin/bitcoin@625534d

---

Depends on D6642

Partial backport of Core [[bitcoin/bitcoin#16542 | PR16542]]

Test Plan:
  ninja check-all

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6643
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jul 1, 2020
Summary:
bitcoin/bitcoin@6e1ae58

---

Depends on D6643

Partial backport of Core [[bitcoin/bitcoin#16542 | PR16542]]

Test Plan:
  ninja check

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6648
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jul 1, 2020
Summary:
bitcoin/bitcoin@787c9ec

---

Depends on D6648

Concludes backport of Core [[bitcoin/bitcoin#16542 | PR16542]]

Test Plan:
  ninja check

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6649
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
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.