| 15 | |
| 16 | namespace wallet { |
| 17 | util::Expected<std::vector<WalletDescInfo>, std::string> ExportDescriptors(const CWallet& wallet, bool export_private) |
| 18 | { |
| 19 | AssertLockHeld(wallet.cs_wallet); |
| 20 | std::vector<WalletDescInfo> wallet_descriptors; |
| 21 | for (const auto& spk_man : wallet.GetAllScriptPubKeyMans()) { |
| 22 | const auto desc_spk_man = dynamic_cast<DescriptorScriptPubKeyMan*>(spk_man); |
| 23 | if (!desc_spk_man) { |
| 24 | return util::Unexpected{"Unexpected ScriptPubKey manager type."}; |
| 25 | } |
| 26 | LOCK(desc_spk_man->cs_desc_man); |
| 27 | const auto& wallet_descriptor = desc_spk_man->GetWalletDescriptor(); |
| 28 | std::string descriptor; |
| 29 | if (!Assume(desc_spk_man->GetDescriptorString(descriptor, export_private))) { |
| 30 | return util::Unexpected{"Can't get descriptor string."}; |
| 31 | } |
| 32 | const bool is_range = wallet_descriptor.descriptor->IsRange(); |
| 33 | wallet_descriptors.emplace_back( |
| 34 | descriptor, |
| 35 | wallet_descriptor.creation_time, |
| 36 | wallet.IsActiveScriptPubKeyMan(*desc_spk_man), |
| 37 | wallet.IsInternalScriptPubKeyMan(desc_spk_man), |
| 38 | is_range ? std::optional(std::make_pair(wallet_descriptor.range_start, wallet_descriptor.range_end)) : std::nullopt, |
| 39 | wallet_descriptor.next_index |
| 40 | ); |
| 41 | } |
| 42 | return wallet_descriptors; |
| 43 | } |
| 44 | |
| 45 | util::Result<std::string> ExportWatchOnlyWallet(const CWallet& wallet, const fs::path& destination, WalletContext& context) |
| 46 | { |
no test coverage detected