Commit f7e88e2
committed
Merge bitcoin/bitcoin#32471: wallet/rpc: fix listdescriptors RPC fails to return descriptors with private key information when wallet contains descriptors missing any key
9c7e477 test: Test listdescs with priv works even with missing priv keys (Novo)
ed945a6 walletrpc: reject listdes with priv key on w-only wallets (Novo)
9e5e982 descriptor: ToPrivateString() pass if at least 1 priv key exists (Novo)
5c4db25 descriptor: refactor ToPrivateString for providers (Novo)
2dc74e3 wallet/migration: use HavePrivateKeys in place of ToPrivateString (Novo)
e842eb9 descriptors: add HavePrivateKeys() (Novo)
Pull request description:
_TLDR:
Currently, `listdescriptors [private=true]` will fail for a non-watch-only wallet if any descriptor has a missing private key(e.g `tr()`, `multi()`, etc.). This PR changes that while making sure `listdescriptors [private=true]` still fails if there no private keys. Closes #32078_
In non-watch-only wallets, it's possible to import descriptors as long as at least one private key is included. It's important that users can still view these descriptors when they need to create a backup—even if some private keys are missing ([#32078 (comment)](bitcoin/bitcoin#32078 (comment))). This change makes it possible to do so.
This change also helps prevent `listdescriptors true` from failing completely, because one descriptor is missing some private keys.
### Notes
- The new behaviour is applied to all descriptors including miniscript descriptors
- `listdescriptors true` still fails for watch-only wallets to preserve existing behaviour bitcoin/bitcoin#24361 (comment)
- Wallet migration logic previously used `Descriptor::ToPrivateString()` to determine which descriptor was watchonly. This means that modifying the `ToPrivateString()` behaviour caused descriptors that were previously recognized as "watchonly" to be "non-watchonly". **In order to keep the scope of this PR limited to the RPC behaviour, this PR uses a different method to determine `watchonly` descriptors for the purpose of wallet migration.** A follow-up PR can be opened to update migration logic to exclude descriptors with some private keys from the `watchonly` migration wallet.
### Relevant PRs
bitcoin/bitcoin#24361
bitcoin/bitcoin#32186
### Testing
Functional tests were added to test the new behaviour
EDIT
**`listdescriptors [private=true]` will still fail when there are no private keys because non-watchonly wallets must have private keys and calling `listdescriptors [private=true]` for watchonly wallet returns an error**
ACKs for top commit:
Sjors:
ACK 9c7e477
achow101:
ACK 9c7e477
w0xlt:
reACK bitcoin/bitcoin@9c7e477 with minor nits
rkrux:
re-ACK 9c7e477
Tree-SHA512: f9b3b2c3e5425a26e158882e39e82e15b7cb13ffbfb6a5fa2868c79526e9b178fcc3cd88d3e2e286f64819d041f687353780bbcf5a355c63a136fb8179698b60File tree
10 files changed
+176
-48
lines changed- src
- script
- test
- fuzz
- wallet
- rpc
- test
- test/functional
10 files changed
+176
-48
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
208 | 212 | | |
209 | 213 | | |
210 | 214 | | |
| |||
260 | 264 | | |
261 | 265 | | |
262 | 266 | | |
263 | | - | |
| 267 | + | |
264 | 268 | | |
265 | | - | |
| 269 | + | |
266 | 270 | | |
267 | 271 | | |
268 | 272 | | |
| |||
329 | 333 | | |
330 | 334 | | |
331 | 335 | | |
332 | | - | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
333 | 340 | | |
334 | 341 | | |
335 | 342 | | |
| |||
492 | 499 | | |
493 | 500 | | |
494 | 501 | | |
495 | | - | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
496 | 506 | | |
497 | 507 | | |
498 | 508 | | |
| |||
710 | 720 | | |
711 | 721 | | |
712 | 722 | | |
713 | | - | |
714 | | - | |
715 | | - | |
716 | 723 | | |
| 724 | + | |
717 | 725 | | |
718 | 726 | | |
719 | 727 | | |
720 | 728 | | |
721 | 729 | | |
722 | 730 | | |
723 | | - | |
724 | 731 | | |
725 | 732 | | |
726 | 733 | | |
| |||
837 | 844 | | |
838 | 845 | | |
839 | 846 | | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
840 | 866 | | |
841 | 867 | | |
842 | 868 | | |
| |||
853 | 879 | | |
854 | 880 | | |
855 | 881 | | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
856 | 886 | | |
857 | 887 | | |
858 | 888 | | |
859 | | - | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
860 | 892 | | |
861 | 893 | | |
862 | | - | |
| 894 | + | |
863 | 895 | | |
864 | 896 | | |
865 | 897 | | |
| |||
868 | 900 | | |
869 | 901 | | |
870 | 902 | | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
871 | 908 | | |
872 | 909 | | |
873 | 910 | | |
| |||
876 | 913 | | |
877 | 914 | | |
878 | 915 | | |
879 | | - | |
| 916 | + | |
880 | 917 | | |
881 | 918 | | |
882 | 919 | | |
| |||
888 | 925 | | |
889 | 926 | | |
890 | 927 | | |
891 | | - | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
892 | 931 | | |
893 | 932 | | |
894 | | - | |
| 933 | + | |
895 | 934 | | |
896 | 935 | | |
897 | 936 | | |
| |||
903 | 942 | | |
904 | 943 | | |
905 | 944 | | |
906 | | - | |
| 945 | + | |
907 | 946 | | |
908 | | - | |
| 947 | + | |
909 | 948 | | |
910 | 949 | | |
911 | 950 | | |
| |||
1396 | 1435 | | |
1397 | 1436 | | |
1398 | 1437 | | |
1399 | | - | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
1400 | 1446 | | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
1401 | 1452 | | |
1402 | 1453 | | |
1403 | 1454 | | |
1404 | 1455 | | |
1405 | 1456 | | |
1406 | 1457 | | |
1407 | 1458 | | |
1408 | | - | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
1409 | 1462 | | |
1410 | 1463 | | |
1411 | 1464 | | |
1412 | 1465 | | |
1413 | 1466 | | |
1414 | 1467 | | |
1415 | 1468 | | |
1416 | | - | |
| 1469 | + | |
1417 | 1470 | | |
1418 | 1471 | | |
1419 | 1472 | | |
| |||
1506 | 1559 | | |
1507 | 1560 | | |
1508 | 1561 | | |
1509 | | - | |
| 1562 | + | |
1510 | 1563 | | |
1511 | 1564 | | |
| 1565 | + | |
1512 | 1566 | | |
1513 | 1567 | | |
1514 | 1568 | | |
1515 | 1569 | | |
1516 | 1570 | | |
1517 | | - | |
| 1571 | + | |
1518 | 1572 | | |
1519 | 1573 | | |
1520 | 1574 | | |
| |||
1571 | 1625 | | |
1572 | 1626 | | |
1573 | 1627 | | |
1574 | | - | |
1575 | | - | |
1576 | | - | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
1577 | 1636 | | |
1578 | | - | |
1579 | 1637 | | |
1580 | 1638 | | |
1581 | 1639 | | |
| |||
2113 | 2171 | | |
2114 | 2172 | | |
2115 | 2173 | | |
2116 | | - | |
| 2174 | + | |
2117 | 2175 | | |
2118 | 2176 | | |
2119 | 2177 | | |
| |||
2510 | 2568 | | |
2511 | 2569 | | |
2512 | 2570 | | |
2513 | | - | |
| 2571 | + | |
2514 | 2572 | | |
2515 | 2573 | | |
2516 | 2574 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
115 | 128 | | |
116 | 129 | | |
117 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
843 | 843 | | |
844 | 844 | | |
845 | 845 | | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
846 | 852 | | |
847 | 853 | | |
848 | 854 | | |
| |||
855 | 861 | | |
856 | 862 | | |
857 | 863 | | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
858 | 870 | | |
859 | 871 | | |
860 | 872 | | |
861 | | - | |
| 873 | + | |
862 | 874 | | |
863 | 875 | | |
864 | 876 | | |
| |||
867 | 879 | | |
868 | 880 | | |
869 | 881 | | |
870 | | - | |
| 882 | + | |
871 | 883 | | |
872 | 884 | | |
873 | 885 | | |
874 | 886 | | |
875 | 887 | | |
876 | | - | |
| 888 | + | |
877 | 889 | | |
878 | 890 | | |
879 | 891 | | |
| |||
894 | 906 | | |
895 | 907 | | |
896 | 908 | | |
897 | | - | |
| 909 | + | |
898 | 910 | | |
899 | 911 | | |
900 | 912 | | |
901 | 913 | | |
902 | | - | |
| 914 | + | |
903 | 915 | | |
904 | 916 | | |
905 | 917 | | |
| |||
925 | 937 | | |
926 | 938 | | |
927 | 939 | | |
928 | | - | |
| 940 | + | |
929 | 941 | | |
930 | 942 | | |
931 | 943 | | |
| |||
935 | 947 | | |
936 | 948 | | |
937 | 949 | | |
938 | | - | |
| 950 | + | |
939 | 951 | | |
940 | 952 | | |
941 | 953 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
246 | 249 | | |
247 | 250 | | |
248 | 251 | | |
| |||
261 | 264 | | |
262 | 265 | | |
263 | 266 | | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
264 | 273 | | |
265 | 274 | | |
266 | 275 | | |
| |||
0 commit comments