This puts receive and change descriptors directly below each other.
The change would be simpler if UniValue arrays were sortable.
This puts receive and change descriptors directly below each other.
The change would be simpler if UniValue arrays were sortable.
Concept ACK
Just a few days ago while playing around with descriptor wallet stuff I thought that a sorted output order for listdescriptors would be more convenient 👍
Concept ACK
Maybe there could be a well-defined ordering for descriptors (instead of string ordering), but this solution is better than the current code.
ACK https://github.com/bitcoin/bitcoin/pull/25931/commits/4996ae3affa3a3b39c5ec53e74c9e4435b9b871a
Concept ACK
Concept ACK
1783 | @@ -1784,25 +1784,40 @@ RPCHelpMan listdescriptors() 1784 | 1785 | LOCK(wallet->cs_wallet); 1786 | 1787 | - UniValue descriptors(UniValue::VARR); 1788 | const auto active_spk_mans = wallet->GetActiveScriptPubKeyMans(); 1789 | + 1790 | + std::vector<std::tuple<std::string, WalletDescriptor, bool, std::optional<bool>>> wallet_descriptors;
nit: I find tuples a bit hard to grok. Could we just pass a comparator to GetAllScriptPubKeyMans?
@S3RK I refactored the PR to use a struct (with trivial types) instead of a tuple. This should also make it easier for a future refactor to move some of this stuff out of the RPC and into the wallet (e.g. so that the GUI can also display a list of descriptors).
Code review ACK edbd1aa43f940910f31037770e386e4cf48ab92f
1789 | + 1790 | + struct WalletDescInfo { 1791 | + std::string descriptor; 1792 | + uint64_t creation_time; 1793 | + bool active; 1794 | + std::optional<bool> internal;
this field doesn't need to be an optional. It will always have a value.
when a descriptor is not active we can't determine whether it's internal or not
Indeed, this is why IsInternalScriptPubKeyMan returns std::optional<bool>. We list both active and inactive descriptors.
k gotcha, nvm then.
1821 | + descriptor, 1822 | + wallet_descriptor.creation_time, 1823 | + active_spk_mans.count(desc_spk_man) != 0, 1824 | + wallet->IsInternalScriptPubKeyMan(desc_spk_man), 1825 | + is_range ? std::optional(std::make_pair(wallet_descriptor.range_start, wallet_descriptor.range_end)) : std::nullopt, 1826 | + is_range ? wallet_descriptor.next_index : 0
I don't think that this is needed. if descriptor is ranged, next_index should always be 0.
next_index defines the index at which we will derive next address for this descriptor. What should it be always 0?
next_index is initialized to zero (see wallet_util.h) so I dropped the ternary operator.
ACK 50996241f2b0eefeaab4fcd11b9730fa2dc107ae
utACK 50996241
reACK 50996241f2b0eefeaab4fcd11b9730fa2dc107ae
Milestone
24.0