Sjors
commented at 4:40 pm on November 18, 2021:
member
Builds on top of #25907 and one commit from #22341.
First this PR introduces a descriptor wallet RPC addhdseed. Similar to its legacy wallet counterpart sethdseed it either generates a fresh random seed, for use on a blank wallet, or the user can provide a WIF. Unlike sethdseed this RPC call does not add keys / fill the keypool.
This allows a user to create a blank wallet (createwallet), provide it with a seed (addhdseed) and then craft custom descriptors. (An alternative approach would to add a nodescriptors argument to createwallet, but this RPC seems useful anyway)
An example use case of this is setting up a multisig between Core and a hardware wallet. After adding the seed to an otherwise empty wallet, the user would call getxpub m/87'/0'/0'. They would then combine this xpub and origin info with the one from their hardware wallet (e.g. using hwi --fingerprint .... getxpub m/87'/0'/0' and craft a descriptor like wsh(sorted_multi(2, [...../87'/0'/0']our_xpub, [..../87'/0'/0']their_xpub)), and import that. The resulting wallet will be able to sign its part of the transaction.
The second part of this PR enables to ability descriptors, such as in the multisig example above, in such a way that any fingerprint + xpub that is covered by our hd seed(s) can be signed for.
Sjors force-pushed
on Nov 18, 2021
DrahtBot added the label
Build system
on Nov 18, 2021
DrahtBot added the label
Descriptors
on Nov 18, 2021
DrahtBot added the label
RPC/REST/ZMQ
on Nov 18, 2021
DrahtBot added the label
Wallet
on Nov 18, 2021
Sjors force-pushed
on Nov 18, 2021
DrahtBot
commented at 11:20 pm on November 18, 2021:
contributor
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviews
See the guideline for information on the review process.
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.
Rspigler
commented at 8:15 pm on November 25, 2021:
contributor
Concept ACK! Thanks for continuing this work
fanquake removed the label
Build system
on Dec 10, 2021
DrahtBot added the label
Needs rebase
on Dec 13, 2021
Rspigler
commented at 3:08 pm on December 22, 2021:
contributor
Sjors
commented at 2:41 am on December 23, 2021:
member
@Rspigler in your examples the descriptors you importing are missing a derivation rule after the xpub, e.g. xpub.../0/* and they’re missing a checksum (add a wrong one and it will tell you the right answers, e.g. #00000000). Also the > seems out of place.
Btw, you could try running the Trezor or ColdCard emulator, it’ll work with HWI.
Rspigler
commented at 6:53 pm on December 26, 2021:
contributor
But still received Error: Error parsing JSON error code.
(The first descriptor is different because I re-compiled on Node 1)
Sjors
commented at 1:47 pm on December 28, 2021:
member
That’s still the wrong format. The final /0/* needs to be after the xpub. And “now” is missing quotes, whereas true should not be in quotes, which is probably what triggers the JSON parsing error. (I know it’s tedious). You probably also want to set internal to false if you want to generate receive addresses (true is used for change addresses)
Sjors force-pushed
on Dec 30, 2021
DrahtBot removed the label
Needs rebase
on Dec 30, 2021
Rspigler
commented at 1:19 am on January 7, 2022:
contributor
Thanks for being patient with me.
Still getting errors but will continue to work on this myself rather than crowd the PR.
DrahtBot added the label
Needs rebase
on Jan 11, 2022
in
src/wallet/scriptpubkeyman.cpp:2082
in
96913f90e5outdated
1751- // Calculate the new range_end
1752- int32_t new_range_end = std::max(m_wallet_descriptor.next_index + (int32_t)target_size, m_wallet_descriptor.range_end);
1753+ {
1754+ LOCK2(cs_desc_man, m_keyman.cs_keyman);
1755+ // Calculate the new range_end
1756+ int32_t new_range_end = std::max(m_wallet_descriptor.next_index + (int32_t)target_size, m_wallet_descriptor.range_end);
Received this error while compiling, but can still run:
CXX wallet/libbitcoin_wallet_a-keyman.o
In file included from ./script/signingprovider.h:11,
from ./wallet/crypter.h:10,
from wallet/keyman.cpp:8:
./script/keyorigin.h: In member function βstd::optional<std::pair<CExtPubKey, KeyOriginInfo> > KeyManager::GetExtPubKey(std::vector) constβ:
./script/keyorigin.h:11:8: warning: βoriginβ may be used uninitialized in this function [-Wmaybe-uninitialized]
11 | struct KeyOriginInfo
| ^~~~~~~~~~~~~
wallet/keyman.cpp:88:19: note: βoriginβ was declared here
88 | KeyOriginInfo origin;
| ^~~~~~
CXX wallet/libbitcoin_wallet_a-load.o
make check passes, but a large number of functional tests fail.
example_test.py | β Failed | 3 s
feature_bip68_sequence.py | β Failed | 26 s
feature_coinstatsindex.py –descriptors | β Failed | 5 s
feature_dbcrash.py | β Failed | 3385 s
feature_fee_estimation.py | β Failed | 1 s
feature_maxuploadtarget.py | β Failed | 85 s
feature_notifications.py | β Failed | 14 s
feature_nulldummy.py –descriptors | β Failed | 1 s
feature_pruning.py | β Failed | 200 s
feature_rbf.py –descriptors | β Failed | 4 s
feature_segwit.py –descriptors | β Failed | 37 s
feature_taproot.py | β Failed | 176 s
interface_bitcoin_cli.py –descriptors | β Failed | 3 s
interface_rest.py | β Failed | 6 s
interface_zmq.py | β Failed | 2 s
mempool_accept.py | β Failed | 10 s
mempool_package_onemore.py | β Failed | 2 s
mempool_packages.py | β Failed | 7 s
mempool_persist.py | β Failed | 8 s
mempool_unbroadcast.py | β Failed | 3 s
mempool_updatefromblock.py | β Failed | 37 s
mining_basic.py | β Failed | 2 s
mining_prioritisetransaction.py | β Failed | 4 s
p2p_compactblocks.py | β Failed | 19 s
p2p_segwit.py | β Failed | 118 s
rpc_createmultisig.py –descriptors | β Failed | 10 s
rpc_fundrawtransaction.py –descriptors | β Failed | 28 s
rpc_invalid_address_message.py | β Failed | 1 s
rpc_psbt.py –descriptors | β Failed | 32 s
rpc_rawtransaction.py –descriptors | β Failed | 10 s
rpc_scantxoutset.py | β Failed | 1 s
rpc_signrawtransaction.py –descriptors | β Failed | 5 s
tool_wallet.py –descriptors | β Failed | 3 s
wallet_abandonconflict.py –descriptors | β Failed | 11 s
wallet_address_types.py –descriptors | β Failed | 19 s
wallet_avoidreuse.py –descriptors | β Failed | 2 s
wallet_backup.py –descriptors | β Failed | 39 s
wallet_balance.py –descriptors | β Failed | 19 s
wallet_basic.py –descriptors | β Failed | 3 s
wallet_bumpfee.py –descriptors | β Failed | 46 s
wallet_coinbase_category.py –descriptors | β Failed | 1 s
wallet_create_tx.py –descriptors | β Failed | 2 s
wallet_createwallet.py –descriptors | β Failed | 4 s
wallet_createwallet.py –usecli | β Failed | 5 s
wallet_descriptor.py –descriptors | β Failed | 5 s
wallet_encryption.py –descriptors | β Failed | 5 s
wallet_fallbackfee.py –descriptors | β Failed | 1 s
wallet_getxpub.py | β Failed | 2 s
wallet_groups.py –descriptors | β Failed | 87 s
wallet_hd.py –descriptors | β Failed | 4 s
wallet_importdescriptors.py –descriptors | β Failed | 27 s
wallet_importprunedfunds.py –descriptors | β Failed | 2 s
wallet_keypool.py –descriptors | β Failed | 4 s
wallet_keypool_topup.py –descriptors | β Failed | 3 s
wallet_labels.py –descriptors | β Failed | 2 s
wallet_listdescriptors.py –descriptors | β Failed | 1 s
wallet_listreceivedby.py –descriptors | β Failed | 18 s
wallet_listsinceblock.py –descriptors | β Failed | 23 s
wallet_listtransactions.py –descriptors | β Failed | 22 s
wallet_multisig_descriptor_psbt.py | β Failed | 4 s
wallet_multiwallet.py –descriptors | β Failed | 1 s
wallet_multiwallet.py –usecli | β Failed | 1 s
wallet_orphanedreward.py | β Failed | 5 s
wallet_reorgsrestore.py | β Failed | 4 s
wallet_resendwallettransactions.py –descriptors | β Failed | 1 s
wallet_send.py –descriptors | β Failed | 16 s
wallet_signer.py –descriptors | β Failed | 4 s
wallet_signmessagewithaddress.py | β Failed | 1 s
wallet_taproot.py | β Failed | 12 s
wallet_transactiontime_rescan.py –descriptors | β Failed | 9 s
wallet_txn_clone.py | β Failed | 4 s
wallet_txn_clone.py –mineblock | β Failed | 4 s
wallet_txn_clone.py –segwit | β Failed | 3 s
wallet_txn_doublespend.py –descriptors | β Failed | 2 s
wallet_txn_doublespend.py –mineblock | β Failed | 4 s
Error when opening bitcoin-qt:
QVariant::load: unknown user type with name BitcoinUnits::Unit.
[
{
“success”: false,
“error”: {
“code”: -5,
“message”: “A function is needed within P2WSH”
}
},
{
“success”: false,
“error”: {
“code”: -5,
“message”: “Expected 8 character checksum, not 10 characters”
}
}
]
Hm, weird, for some reason the import/checksum works for the ‘first descriptor’ in the combined, but not the second. Even though we have already calculated it. Let’s try calculating the second, with the first a part of the calculation?
Sjors
commented at 12:06 pm on September 28, 2022:
member
Rebased fe5db8d077a4cc35912a083501654bd931529097 on top of #25907. This uses a hardcoded xpriv, so don’t bother testing just yet (and ignore the broken test case).
The approach now is that when calling importdescriptors is that if it finds missing private keys, it will try to derive them from the seed (using the new keyman.GetActiveHDKey() method). Will implement this derivation later using some stuff from #22341.
I’m not a huge fan of using string manipulation in the RPC code like this though.
Sjors force-pushed
on Sep 28, 2022
DrahtBot removed the label
Needs rebase
on Sep 28, 2022
Sjors force-pushed
on Sep 28, 2022
Sjors
commented at 3:28 pm on September 28, 2022:
member
It now works for the simplest case. Still need to clean up the part where I inject the master key xpub into the descriptor (hopefully that fixes the test too). I’d rather manipulate the Descriptor object directly than to manipulate strings and then re-parse.
Sjors force-pushed
on Sep 28, 2022
DrahtBot added the label
Needs rebase
on Oct 13, 2022
moveonly: move WalletStorage to separate file18054704cf
walletdb: Add HDKey records312245433d
walletdb: Add WriteKeyManKey and WriteCryptedKeyManKey
These functions write new key records for keys handled by a KeyManager
3fa66d009a
walletdb: Allow duplicate descriptor keys
If a descriptor (crypted) key is being written and one already exists,
make sure that the one being written and the one already on disk
match each other.
632b29608f
descspkm: Track CKeyIDs of our keys
When DescriptorScriptPubKeyMan no longer manages its keys, it still
needs to know the IDs of its keys.
ebec893ce1
wallet: Add KeyManager classdb6efef098
descspkm: Add KeyManager to DescriptorScriptPubKeyMan and use for keys60a499b5dd
descspkm: Encrypt with KeyManager instead of direct map access1e99ebda77
descspkm: Use KeyManager::LoadKey and LoadCryptedKey when loading9b44055c4f
descspkm: Replace GetKeys with KeyManager::GetKeysd04dd5becf
descspkm: Replace HavePrivateKeys with KeyManager::HavePrivateKeys()d4c78ace5a
keyman: Make some members private38e099bd2b
wallet: Have KeyManager in CWallet rather than DescriptorScriptPubKeyManfc89a37d81
walletdb: Refactor deserialaization of keys with checksums
This will become shared later.
b21982f390
walletdb: Load keys into KeyManager directly8436d2ff55
wallet: Add flag for using KeyManager
KeyManager will be a backwards compatible background upgrade to
descriptor wallets. A flag indicating that the upgrade has occurred is
added so that the upgrade (not yet implemented) will only happen once.
6e5fbd56a4
wallet: Use KeyManager to generate master keyb0adf464c2
descriptor: Be able to get the pubkeys involved in a descriptor4ca53084e7
walletdb: Implement upgrading a wallet to use KeyManagerf7fbd0a5fd
descspkm: Remove unneeded key loading
Key management will be done entirely by KeyManager, so
DescriptorScriptPubKeyMan does not need key loading functions.
aee80e5a0d
rpc: Add getxpub commandc9af030cd6
wallet: Refactor function for single DescSPKM setup
We will need access to a function that sets up a singular
DescriptorSPKM, so refactor this out of the multiple DescriptorSPKM
setup function.
e8d2afdffc
wallet, descspkm: Move GetID into WalletDescriptor60afd5b51a
wallet, descspkm: Refactor wallet descriptor generation to static funcb27e5d6ac8
walletdb: Allow overwriting keyman active hd key322db472e8
wallet: Re-enable sethdseed for descriptors wallets
Descriptor wallets store an HD master key that is used for new
automatically generated descriptors. sethdseed is an existing RPC that
can be repurposed to allow the users to set that HD key whenever they
want.
Also fixes the whitespace of sethdseed. Best to review this with
--ignore-all-space
wallet: Test for descriptor wallet sethdseed and createwalletdescriptorb2c3deea89
wallet: GetExtPubKey()cfb3af5e10
wallet: match xpub in imported descriptor to existing seed7841583080
Sjors force-pushed
on Nov 29, 2022
DrahtBot removed the label
Needs rebase
on Nov 29, 2022
DrahtBot added the label
Needs rebase
on Dec 5, 2022
DrahtBot
commented at 10:51 pm on December 5, 2022:
contributor
π This pull request conflicts with the target branch and needs rebase.
DrahtBot
commented at 0:57 am on March 5, 2023:
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.
DrahtBot
commented at 1:19 am on June 3, 2023:
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.
Sjors
commented at 2:15 pm on August 1, 2023:
member
This is very out of date and it’s not on my priority list at the moment. Happy to review if someone else takes it over.
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2024-12-03 15:12 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me