diff --git a/liana-gui/src/app/error.rs b/liana-gui/src/app/error.rs index 4f279242..4050ed88 100644 --- a/liana-gui/src/app/error.rs +++ b/liana-gui/src/app/error.rs @@ -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), diff --git a/liana-gui/src/app/view/warning.rs b/liana-gui/src/app/view/warning.rs index 1496646a..cdc18bd8 100644 --- a/liana-gui/src/app/view/warning.rs +++ b/liana-gui/src/app/view/warning.rs @@ -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()), diff --git a/liana-gui/src/daemon/client/mod.rs b/liana-gui/src/daemon/client/mod.rs index 80ba9176..c0f69263 100644 --- a/liana-gui/src/daemon/client/mod.rs +++ b/liana-gui/src/daemon/client/mod.rs @@ -83,6 +83,14 @@ impl Daemon for Lianad { self.call("getnewaddress", Option::::None) } + async fn update_deriv_indexes( + &self, + receive: Option, + change: Option, + ) -> Result<(), DaemonError> { + self.call("updatederivationindexes", Some(vec![receive, change])) + } + async fn list_coins( &self, statuses: &[CoinStatus], diff --git a/liana-gui/src/daemon/embedded.rs b/liana-gui/src/daemon/embedded.rs index 4cafd5cc..96e63613 100644 --- a/liana-gui/src/daemon/embedded.rs +++ b/liana-gui/src/daemon/embedded.rs @@ -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, + change: Option, + ) -> 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], diff --git a/liana-gui/src/daemon/mod.rs b/liana-gui/src/daemon/mod.rs index f8779267..300fc918 100644 --- a/liana-gui/src/daemon/mod.rs +++ b/liana-gui/src/daemon/mod.rs @@ -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; async fn get_new_address(&self) -> Result; + async fn update_deriv_indexes( + &self, + receive: Option, + change: Option, + ) -> Result<(), DaemonError>; async fn list_coins( &self, statuses: &[CoinStatus], diff --git a/liana-gui/src/lianalite/client/backend/mod.rs b/liana-gui/src/lianalite/client/backend/mod.rs index 62d74019..e6095090 100644 --- a/liana-gui/src/lianalite/client/backend/mod.rs +++ b/liana-gui/src/lianalite/client/backend/mod.rs @@ -627,6 +627,14 @@ impl Daemon for BackendWalletClient { }) } + async fn update_deriv_indexes( + &self, + _receive: Option, + _change: Option, + ) -> Result<(), DaemonError> { + Err(DaemonError::NotImplemented) + } + /// Spent coins are not returned if statuses is empty, unless their outpoints are specified. async fn list_coins( &self,