Merge bitcoin/bitcoin#34861: wallet: Add importdescriptors interface
2c249dbdf5c9d8c7dd71ac90ea29a8b52ec4b2ba wallet: Add an importDescriptors() interface for the wallet (Pol Espinasa)
3be5f401370ee18dc263149c8a23a33cba9baef5 wallet: add CheckDescriptorRangeBounds (Pol Espinasa)
a9cd985d0a54877ef3ba9b844f725a2d3065f1bb wallet: Move ImportDescriptor and ProcessDescriptorsImport to imports.cpp (Pol Espinasa)
c9650d8f0e2f664b4f4362a42e8dfc7efc82af18 wallet: rename ProcessDescriptorImport to ImportDescriptor and add ProcessDescriptorsImport (Pol Espinasa)
a40ee4ec26590c4e485f5bb0155d90b4438ee590 wallet: rpc: refactor: ProcessDescriptorImport returns ImportDescriptorResult (Pol Espinasa)
48d3d717fb6e3f61acbaf867404e51a1cac77e78 wallet, util: Add HandleWalletErrorCode (Pol Espinasa)
04c73a91d2cc4165b90dc43b8932b128b8e1923f wallet: Add ImportError struct and new WalletError codes (Pol Espinasa)
975215618505e2d62c17cb63ce94ca2a72e79ffc wallet: rpc: refactor: Extract UniValue processing from ProcessDescriptorImport (Pol Espinasa)
f1f61af357275f277c169e895d39699f918ef7aa wallet: Add ImportDescriptorRequest structs (Pol Espinasa)
7375124f4c9a7d998bf6e0f1eed3975f0ea761e3 wallet: refactor: make is_ranged no longer an optional (Pol Espinasa)
90485103c67d2454efa10743b1a2e6d844f74c58 wallet: lower the minimum timestamp to 0 (Pol Espinasa)
380d3ae0deab72c2652b3290bfe00195cca4f8e9 wallet: rpc: Use std::optional in GetImportTimestamp (Pol Espinasa)
Pull request description:
This PR adds an interface for importing descriptors.
The motivation behind this is that currently, importing descriptors is only possible via RPC. Bitcoin Core GUI doesn't use the RPC interface so it cannot offer descriptor import functionality, which is needed to support more complex wallet setups such as multisig.
This PR also adds a refactor by moving the `importdescriptors` logic from the RPC layer into `CWallet::ImportDescriptor`, making it reusable by both the RPC and this new interface.
The main changes are:
- Introduces `CWallet::ImportDescriptor()` containing the core import logic, previously embedded in the RPC `ProcessDescriptorImport` function.
- Introduces `wallet::ImportDescriptorResult`, a new result struct that carries success status, error message, warnings, and a `FailureReason` enum. The RPC layer uses `FailureReason` to map results back to the appropriate JSON-RPC error codes, keeping RPC concerns out of `CWallet`.
- Updates `ProcessDescriptorImport` in `rpc/backup.cpp` to delegate to `CWallet::ImportDescriptor`.
- Adds `interfaces::Wallet::importDescriptors()` as a new interface method, allowing the GUI to import descriptors without going through RPC.
I have a GUI menu here: https://github.com/polespinasa/bitcoin/pull/7 so it can be tested. I will open a PR against the main GUI repo, once this gets merged.
ACKs for top commit:
achow101:
re-ACK 2c249dbdf5c9d8c7dd71ac90ea29a8b52ec4b2ba
w0xlt:
reACK 2c249dbdf5c9d8c7dd71ac90ea29a8b52ec4b2ba
arejula27:
reACK 2c249dbdf5c9d8c7dd71ac90ea29a8b52ec4b2ba
Tree-SHA512: fa6fefc404c1015793cf5da53fe8a4352bbe46865eeb5c65d95afb3fa897667956ed9b912a11163dc7194b10bcb9f6b74211622c846e57908524e910a3c5a2ef A
Ava Chow committed
2bbbeaa663ec1a9d61d1e5f986c71887194926fd