gui: implement Daemon.update_deriv_indexes()
This commit is contained in:
parent
39f71d3de8
commit
6988fa40c9
@ -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),
|
||||
|
||||
@ -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()),
|
||||
|
||||
@ -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],
|
||||
|
||||
@ -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],
|
||||
|
||||
@ -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],
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user