Repository navigation
Conversation
|
You may find the issue if you inspect the log generated by the |
There was a problem hiding this comment.
getnewaddress is a wallet RPC. If you want this to work when the wallet isn't compiled, you'll need to generate the HD keys in the python test framework.
There was a problem hiding this comment.
Thanks John! Would you mind giving an example of where this is done currently? I looked around in the test_framework and just the functional test dir in general, but I couldn't find any example of generating hd keys without wallet. Or maybe this is a function that doesn't exist in the functional test dir yet and we can write it?
There was a problem hiding this comment.
The RPC has non-wallet descriptor RPCs: https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md#support-for-output-descriptors-in-bitcoin-core
If I had to guess, you are probably looking for deriveaddresses
There was a problem hiding this comment.
I was thinking that the keys would be generated in the python test framework. I just assumed that we'd have some HD key generation code to test BIP32, but it appears I was wrong.
Marco's suggestion to use the deriveaddress seems ok, but I don't think you even need to do that. I think you can just pass the descriptor with keypath in to generatetodescriptor
There was a problem hiding this comment.
I added hdkeypathnonce here to make sure a new key path is used. But I realized that incrementing the counter variable like this won't work, because many test files would call getnewaddress() outside of generate(). These new keys generated out of band also belong to the family of our HD tree, but our counter variable will not be aware of this.
(like feature_segwit.py).
Hence, although we want to make sure each time a new key path is used, it doesn't make sense to use member variable like this. Maybe the best way to check is to compare the new keypath with the existing keypool? Or do you have other suggestions? @jnewbery
Thanks Marco, really helpful! |
6dde62f to
799ac27
Compare
There was a problem hiding this comment.
Once I generate to a new address, many tests that check whether the wallet addr number matches up start failing. I think this is because the getnewaddress is messing up the address count for some tests. But at the same time, we also don't want to generate to deterministic addresses either... I'm not sure what direction I should take here...
TODO: investigate why created keypaths do not increase incrementally/consistently
799ac27 to
86e2b7b
Compare
86e2b7b to
671ae41
Compare
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, 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. |
This improvement was proposed by jnewbery in #19022
We want to rewrite generate() function by using an hd seed to create addresses. This allows the test to have unique but deterministic addresses to which blocks can be generated.
TODO:
Investigate why certain created keypaths do not increase incrementally/consistently:
currently, I am using a counter
keypathnonceto assert every key path generated from my HD seed is unique and increment by one (maybe this was the wrong assumption to start with?).Interestingly, when I ran tests, it seems that one particular key path,
m/0'/0'/105andm/0'/0'/106, are always skipped. Whereas the rest of my hdkeypath increase consistently by one:My assertion error