From 1b0ed0b99f8f36d7f04215b0ef846fdb13c095e7 Mon Sep 17 00:00:00 2001 From: Cifko Date: Thu, 29 Dec 2022 17:07:43 +0100 Subject: [PATCH] feat: add get tari address to wallet --- applications/tari_app_grpc/proto/wallet.proto | 6 ++++++ .../tari_console_wallet/src/grpc/wallet_grpc_server.rs | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/applications/tari_app_grpc/proto/wallet.proto b/applications/tari_app_grpc/proto/wallet.proto index f962aeb6c0..7da3b69062 100644 --- a/applications/tari_app_grpc/proto/wallet.proto +++ b/applications/tari_app_grpc/proto/wallet.proto @@ -39,6 +39,8 @@ service Wallet { rpc CheckForUpdates (Empty) returns (SoftwareUpdate); // This returns the identity information rpc Identify (GetIdentityRequest) returns (GetIdentityResponse); + // This returns the tari address + rpc GetAddress (Empty) returns (GetAddressResponse); // This returns a coinbase transaction rpc GetCoinbase (GetCoinbaseRequest) returns (GetCoinbaseResponse); // Send Tari to a number of recipients @@ -87,6 +89,10 @@ message GetVersionResponse { string version = 1; } +message GetAddressResponse { + bytes address = 1; +} + message TransferRequest { repeated PaymentRecipient recipients = 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 c3b5c1b3dd..eddf5e5f97 100644 --- a/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs +++ b/applications/tari_console_wallet/src/grpc/wallet_grpc_server.rs @@ -45,6 +45,7 @@ use tari_app_grpc::{ CreateBurnTransactionResponse, CreateTemplateRegistrationRequest, CreateTemplateRegistrationResponse, + GetAddressResponse, GetBalanceRequest, GetBalanceResponse, GetCoinbaseRequest, @@ -226,6 +227,15 @@ impl wallet_server::Wallet for WalletGrpcServer { })) } + async fn get_address(&self, _: Request) -> Result, Status> { + let network = self.wallet.network.as_network(); + let pk = self.wallet.comms.node_identity().public_key().clone(); + let address = TariAddress::new(pk, network); + Ok(Response::new(GetAddressResponse { + address: address.to_bytes().to_vec(), + })) + } + async fn set_base_node( &self, request: Request,