Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,19 @@ impl From<FromHexError> for Error {
Error::DecodeHex(e)
}
}

/// Extension methods for the client error type.
impl Error {
/// Returns `true` if this is a "not found" error returned by `bitcoind`.
///
/// `bitcoind` returns error code `-5` (`RPC_INVALID_ADDRESS_OR_KEY`)
/// whenever a requested block hash, transaction ID, address, or similar object
/// does not exist on the node.
pub fn is_not_found_error(&self) -> bool {
if let Error::JsonRpc(jsonrpc::Error::Rpc(rpc_err)) = self {
rpc_err.code == -5
} else {
false
}
}
}
Loading