Import watch only pubkeys to the keypool if private keys are disabled#14075
Import watch only pubkeys to the keypool if private keys are disabled#14075meshcollider merged 5 commits intobitcoin:masterfrom
Conversation
56ab4be to
d7d9ac9
Compare
There was a problem hiding this comment.
Commit "Fetch keys from keypool when private keys are disabled"
Could move test to a different commit?
There was a problem hiding this comment.
Commit "Fetch keys from keypool when private keys are disabled"
Use named argument disable_private_keys=True?
src/wallet/rpcdump.cpp
Outdated
There was a problem hiding this comment.
Commit "Add option to importmulti add an imported pubkey to the keypool"
Default false.
src/wallet/rpcdump.cpp
Outdated
There was a problem hiding this comment.
Commit "Add option to importmulti add an imported pubkey to the keypool"
... can be ...
src/qt/walletmodel.cpp
Outdated
There was a problem hiding this comment.
This function should be renamed or called into from a new one.
WalletModel::KeypoolEmptyAndPrivkeysDisabled or something obnoxiously explicit.
src/wallet/rpcwallet.cpp
Outdated
There was a problem hiding this comment.
Might be time to make a TryToTopUpKeyPool function for when we will continue regardless. We do this in a number of places in the PR and probably elsewhere.
There was a problem hiding this comment.
TopUpKeypool actually already has this check in it so it won't do anything when the disable private keys flag is set. This is just an extra belt and suspenders check.
d7d9ac9 to
5f2a499
Compare
|
Rebased. The first commit is still from #14019 |
5f2a499 to
85b6075
Compare
src/wallet/wallet.cpp
Outdated
There was a problem hiding this comment.
mu-nit: add commit for KeypoolCountInternalKeys
There was a problem hiding this comment.
I think that's unnecssary.
|
|
50cff8c to
acb05a1
Compare
|
Concept ACK. Lightly tested via your combined branch 3fa968e: I was able to import a bunch of receive and change keys. I was also able to receive coins on a For some reason when I composed the transaction it picked change address with index 1 instead of with index 0. Is that an existing rule? What I also found confusing, though I don't know if that's this PR, or the other two or just existing weirdness, is how |
Maybe your import command was weird? It should be adding them in the order of the import command so you should be getting them in that order too. |
acb05a1 to
5022a35
Compare
|
What's a good way to inspect the wallet / keypool? |
|
@Sjors You can use dumpwallet |
|
@achow101 I'll try with |
|
I will rework this to not require #14019 as soon as I have time (in a few days) |
|
Good news: I'm wrong, and I'm the one who wrote the logic originally :( Test and I'm happy. |
a6e2c33 to
0f9f035
Compare
There was a problem hiding this comment.
./test/functional/wallet_importmulti.py:730:35: F821 undefined name 'xpub'
|
@instagibbs keys from a ranged descriptor are imported in order. Feel free to replace this test: # Test importing of a ranged descriptor without keys, check order
self.log.info("Should import the ranged descriptor with specified range as solvable")
self.test_importmulti({"desc": desc,
"timestamp": "now",
"range": {"end": 9}},
success=True,
warnings=["Some private keys are missing, outputs will be considered watchonly. If this is intentional, specify the watchonly flag."])
# Check the first two addresses:
for address in addresses:
test_address(self.nodes[1],
key.p2sh_p2wpkh_addr,
solvable=True)
# Check keys were imported in the correct order:
for i in range(10):
address = self.nodes[1].getnewaddress()
assert_equal(self.nodes[1].getaddressinfo(address)["hdkeypath"], "m/0'/0'/%s'" % i) |
0f9f035 to
32fd3bb
Compare
|
Test fix only change. reACK 32fd3bb |
32fd3bb to
38fbc10
Compare
|
re-ACK 38fbc10 Ordering test fixed, at least locally. |
|
utACK a6e2c3331023d11112f8e9d176aa823d84b3f5ce (only adds a test since my last ACK) |
|
utACK 38fbc10 |
Introduces AddKeypoolPubkey in order to add a pubkey to the keypool
When private keys are disabled, still fetch keys from the keypool if the keypool has keys. Those keys come from importing them and adding them to the keypool.
Adds a new option to importmulti where the pubkeys specified in the import object can be added to the keypool. This only works if the wallet has private keys disabled.
38fbc10 to
037e695
Compare
Do public key imports in the order that they are specified in the import or in the descriptor range.
037e695 to
f4b00b7
Compare
|
LGTM f4b00b7 |
|
Post merge utACK f4b00b7 |
…ption a607c9a [Doc] importmulti: add missing description of keypool option (David A. Harding) Pull request description: Option was added in #14075 but not documented there. CC: @achow101 Tree-SHA512: dcb6421fa1be3d733d7a00c1b57ffd591fe76c02d1c479e729089c118bec52f53bd7ebdb5454b3b1c7603ab189e91682a688b673a7f6b04fa8610c4249711217
Summary: * Add a method to add a pubkey to the keypool Introduces AddKeypoolPubkey in order to add a pubkey to the keypool * Fetch keys from keypool when private keys are disabled When private keys are disabled, still fetch keys from the keypool if the keypool has keys. Those keys come from importing them and adding them to the keypool. * Add option to importmulti add an imported pubkey to the keypool Adds a new option to importmulti where the pubkeys specified in the import object can be added to the keypool. This only works if the wallet has private keys disabled. * Test pubkey import to keypool * Import public keys in order Do public key imports in the order that they are specified in the import or in the descriptor range. This is a backport of Core [[bitcoin/bitcoin#14075 | PR14075]] Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D6366
If the wallet has private keys disabled, allow importing public keys into the keypool. A
keypooloption has been added toimportmultiin order to signal that the keys should be added to the keypool.