Skip to content

Commit

Permalink
fix(wallet): LoadError::MissingDescriptor includes the missing Keyc…
Browse files Browse the repository at this point in the history
…hainKind
  • Loading branch information
ValuedMammal committed Jun 5, 2024
1 parent 412dee1 commit 8bc3d35
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions crates/wallet/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ pub enum LoadError {
/// Data loaded from persistence is missing genesis hash.
MissingGenesis,
/// Data loaded from persistence is missing descriptor.
MissingDescriptor,
MissingDescriptor(KeychainKind),
}

impl fmt::Display for LoadError {
Expand All @@ -255,7 +255,9 @@ impl fmt::Display for LoadError {
}
LoadError::MissingNetwork => write!(f, "loaded data is missing network type"),
LoadError::MissingGenesis => write!(f, "loaded data is missing genesis hash"),
LoadError::MissingDescriptor => write!(f, "loaded data is missing descriptor"),
LoadError::MissingDescriptor(k) => {
write!(f, "loaded data is missing descriptor for keychain {k:?}")
}
}
}
}
Expand Down Expand Up @@ -517,14 +519,14 @@ impl Wallet {
.indexer
.keychains_added
.get(&KeychainKind::External)
.ok_or(LoadError::MissingDescriptor)?
.ok_or(LoadError::MissingDescriptor(KeychainKind::External))?
.clone();
let change_descriptor = changeset
.indexed_tx_graph
.indexer
.keychains_added
.get(&KeychainKind::Internal)
.ok_or(LoadError::MissingDescriptor)?
.ok_or(LoadError::MissingDescriptor(KeychainKind::Internal))?
.clone();

let (signers, change_signers) =
Expand Down Expand Up @@ -596,10 +598,12 @@ impl Wallet {
expected: genesis_hash,
got: None,
},
LoadError::MissingDescriptor => NewOrLoadError::LoadedDescriptorDoesNotMatch {
got: None,
keychain: KeychainKind::External,
},
LoadError::MissingDescriptor(keychain) => {
NewOrLoadError::LoadedDescriptorDoesNotMatch {
got: None,
keychain,
}
}
})?;
if wallet.network != network {
return Err(NewOrLoadError::LoadedNetworkDoesNotMatch {
Expand Down

0 comments on commit 8bc3d35

Please sign in to comment.