mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-06 13:09:43 +01:00
descriptor: ToPrivateString() pass if at least 1 priv key exists
- Refactor Descriptor::ToPrivateString() to allow descriptors with missing private keys to be printed. Useful in descriptors with multiple keys e.g tr() etc. - The existing behaviour of listdescriptors is preserved as much as possible, if no private keys are availablle ToPrivateString will return false
This commit is contained in:
@@ -124,10 +124,14 @@ struct ParserContext {
|
||||
return a < b;
|
||||
}
|
||||
|
||||
std::optional<std::string> ToString(const Key& key) const
|
||||
std::optional<std::string> ToString(const Key& key, bool& has_priv_key) const
|
||||
{
|
||||
has_priv_key = false;
|
||||
auto it = TEST_DATA.dummy_key_idx_map.find(key);
|
||||
if (it == TEST_DATA.dummy_key_idx_map.end()) return {};
|
||||
if (it == TEST_DATA.dummy_key_idx_map.end()) {
|
||||
return HexStr(key);
|
||||
}
|
||||
has_priv_key = true;
|
||||
uint8_t idx = it->second;
|
||||
return HexStr(std::span{&idx, 1});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user