diff --git a/applications/tari_app_grpc/proto/wallet.proto b/applications/tari_app_grpc/proto/wallet.proto index c7e750d526..c4fe339144 100644 --- a/applications/tari_app_grpc/proto/wallet.proto +++ b/applications/tari_app_grpc/proto/wallet.proto @@ -30,6 +30,8 @@ import "types.proto"; service Wallet { // This returns the current version rpc GetVersion (GetVersionRequest) returns (GetVersionResponse); + // This checks if the wallet is healthy and running + rpc CheckConnectivity(GetConnectivityRequest) returns (CheckConnectivityResponse); // Check for new updates rpc CheckForUpdates (Empty) returns (SoftwareUpdate); // This returns the identity information @@ -354,3 +356,14 @@ message SetBaseNodeRequest { } message SetBaseNodeResponse{} + +message GetConnectivityRequest{} + +message CheckConnectivityResponse{ + enum OnlineStatus { + Connecting = 0; + Online = 1; + Offline = 2; + } + OnlineStatus status = 1; +} diff --git a/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs b/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs index c62543e3cd..7abe012f5b 100644 --- a/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs +++ b/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs @@ -30,6 +30,7 @@ use tari_app_grpc::{ self, payment_recipient::PaymentType, wallet_server, + CheckConnectivityResponse, ClaimHtlcRefundRequest, ClaimHtlcRefundResponse, ClaimShaAtomicSwapRequest, @@ -48,6 +49,7 @@ use tari_app_grpc::{ GetCoinbaseResponse, GetCompletedTransactionsRequest, GetCompletedTransactionsResponse, + GetConnectivityRequest, GetIdentityRequest, GetIdentityResponse, GetOwnedAssetsResponse, @@ -88,6 +90,7 @@ use tari_core::transactions::{ use tari_crypto::{ristretto::RistrettoPublicKey, tari_utilities::Hashable}; use tari_utilities::{hex::Hex, ByteArray}; use tari_wallet::{ + connectivity_service::{OnlineStatus, WalletConnectivityInterface}, output_manager_service::handle::OutputManagerHandle, transaction_service::{handle::TransactionServiceHandle, storage::models}, WalletSqlite, @@ -129,6 +132,22 @@ impl wallet_server::Wallet for WalletGrpcServer { })) } + async fn check_connectivity( + &self, + _: Request, + ) -> Result, Status> { + let mut connectivity = self.wallet.wallet_connectivity.clone(); + let status = connectivity.get_connectivity_status(); + let grpc_connectivity = match status { + tari_wallet::connectivity_service::OnlineStatus::Connecting => OnlineStatus::Connecting, + tari_wallet::connectivity_service::OnlineStatus::Online => OnlineStatus::Online, + tari_wallet::connectivity_service::OnlineStatus::Offline => OnlineStatus::Offline, + }; + Ok(Response::new(CheckConnectivityResponse { + status: grpc_connectivity as i32, + })) + } + async fn check_for_updates( &self, _: Request,