gui: implement Daemon.update_deriv_indexes()

This commit is contained in:
pythcoiner 2025-03-08 12:55:57 +01:00
parent 39f71d3de8
commit 6988fa40c9
No known key found for this signature in database
GPG Key ID: C1048AEEDF303B88
6 changed files with 41 additions and 0 deletions

View File

@ -53,6 +53,7 @@ impl std::fmt::Display for Error {
write!(f, "[{:?}] {}", code, e)
}
DaemonError::CoinSelectionError => write!(f, "{}", e),
DaemonError::NotImplemented => write!(f, "{}", e),
},
Self::Unexpected(e) => write!(f, "Unexpected error: {}", e),
Self::HardwareWallet(e) => write!(f, "error: {}\nPlease check if the device is still connected and unlocked with the correct firmware open for the current network and no other application is accessing the device.", e),

View File

@ -41,6 +41,9 @@ impl From<&Error> for WarningMessage {
DaemonError::CoinSelectionError => {
WarningMessage("Error when selecting coins for spend".to_string())
}
DaemonError::NotImplemented => {
WarningMessage("Feature not implemented for this backend".to_string())
}
},
Error::Unexpected(_) => WarningMessage("Unknown error".to_string()),
Error::HardwareWallet(_) => WarningMessage("Hardware wallet error".to_string()),

View File

@ -83,6 +83,14 @@ impl<C: Client + Send + Sync + Debug> Daemon for Lianad<C> {
self.call("getnewaddress", Option::<Request>::None)
}
async fn update_deriv_indexes(
&self,
receive: Option<u32>,
change: Option<u32>,
) -> Result<(), DaemonError> {
self.call("updatederivationindexes", Some(vec![receive, change]))
}
async fn list_coins(
&self,
statuses: &[CoinStatus],

View File

@ -98,6 +98,19 @@ impl Daemon for EmbeddedDaemon {
self.command(|daemon| Ok(daemon.get_new_address())).await
}
async fn update_deriv_indexes(
&self,
receive: Option<u32>,
change: Option<u32>,
) -> Result<(), DaemonError> {
self.command(|daemon| {
daemon
.update_deriv_indexes(receive, change)
.map_err(|e| DaemonError::Unexpected(e.to_string()))
})
.await
}
async fn list_coins(
&self,
statuses: &[CoinStatus],

View File

@ -43,6 +43,8 @@ pub enum DaemonError {
ClientNotSupported,
/// Error when selecting coins for spend.
CoinSelectionError,
/// Not implemented feature
NotImplemented,
}
impl std::fmt::Display for DaemonError {
@ -57,6 +59,7 @@ impl std::fmt::Display for DaemonError {
Self::Start(e) => write!(f, "Daemon did not start: {}", e),
Self::ClientNotSupported => write!(f, "Daemon communication is not supported"),
Self::CoinSelectionError => write!(f, "Coin selection error"),
Self::NotImplemented => write!(f, "This feature is not implemented for this backend"),
}
}
}
@ -82,6 +85,11 @@ pub trait Daemon: Debug {
async fn stop(&self) -> Result<(), DaemonError>;
async fn get_info(&self) -> Result<model::GetInfoResult, DaemonError>;
async fn get_new_address(&self) -> Result<model::GetAddressResult, DaemonError>;
async fn update_deriv_indexes(
&self,
receive: Option<u32>,
change: Option<u32>,
) -> Result<(), DaemonError>;
async fn list_coins(
&self,
statuses: &[CoinStatus],

View File

@ -627,6 +627,14 @@ impl Daemon for BackendWalletClient {
})
}
async fn update_deriv_indexes(
&self,
_receive: Option<u32>,
_change: Option<u32>,
) -> Result<(), DaemonError> {
Err(DaemonError::NotImplemented)
}
/// Spent coins are not returned if statuses is empty, unless their outpoints are specified.
async fn list_coins(
&self,