From fb8fb6a5e099e41164267c1b661e79bca15c388a Mon Sep 17 00:00:00 2001 From: woodser Date: Tue, 11 Jun 2024 18:34:33 -0400 Subject: [PATCH] support getting public spend and view keys over wallet rpc --- src/main/java/monero/wallet/MoneroWalletRpc.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/monero/wallet/MoneroWalletRpc.java b/src/main/java/monero/wallet/MoneroWalletRpc.java index 262fe10a..26f083f3 100644 --- a/src/main/java/monero/wallet/MoneroWalletRpc.java +++ b/src/main/java/monero/wallet/MoneroWalletRpc.java @@ -574,14 +574,24 @@ public String getPrivateViewKey() { } + @SuppressWarnings("unchecked") @Override public String getPublicViewKey() { - throw new MoneroError("MoneroWalletRpc.getPublicViewKey() not supported"); + Map params = new HashMap(); + params.put("key_type", "public_view_key"); + Map resp = rpc.sendJsonRequest("query_key", params); + Map result = (Map) resp.get("result"); + return (String) result.get("key"); } + @SuppressWarnings("unchecked") @Override public String getPublicSpendKey() { - throw new MoneroError("MoneroWalletRpc.getPublicSpendKey() not supported"); + Map params = new HashMap(); + params.put("key_type", "public_spend_key"); + Map resp = rpc.sendJsonRequest("query_key", params); + Map result = (Map) resp.get("result"); + return (String) result.get("key"); } @SuppressWarnings("unchecked")