Skip to content

Commit 13054bd

Browse files
committed
rust: add error for script pubkey not found
1 parent 13a543a commit 13054bd

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

subprojects/gdk_rust/gdk_electrum/src/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub enum Error {
3434
WalletNotInitialized,
3535
MissingMasterBlindingKey,
3636
TxNotFound(String),
37+
ScriptPubkeyNotFound,
3738
AddrParse(String),
3839
InvalidElectrumUrl(String),
3940
Bitcoin(bitcoin::util::Error),
@@ -108,6 +109,7 @@ impl Display for Error {
108109
Error::InvalidElectrumUrl(url) => write!(f, "Invalid Electrum URL: {}", url),
109110
Error::PsetAndTxMismatch => write!(f, "PSET and Tx mismatch"),
110111
Error::TxNotFound(txid) => write!(f, "Transaction not found ({})", txid),
112+
Error::ScriptPubkeyNotFound => write!(f, "Scriptpubkey not found"),
111113
}
112114
}
113115
}

subprojects/gdk_rust/gdk_electrum/src/store.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,7 @@ impl RawAccountCache {
480480
}
481481

482482
pub fn get_path(&self, script_pubkey: &BEScript) -> Result<&DerivationPath, Error> {
483-
self.paths
484-
.get(script_pubkey)
485-
.ok_or_else(|| Error::Generic("can't find derivation path".into()))
483+
self.paths.get(script_pubkey).ok_or_else(|| Error::ScriptPubkeyNotFound)
486484
}
487485
}
488486

0 commit comments

Comments
 (0)