Преглед изворни кода

return public keys from jsonserver instead of info message

ghassmo пре 5 година
родитељ
комит
be54498709
2 измењених фајлова са 15 додато и 10 уклоњено
  1. 5 6
      src/rpc/adapter.rs
  2. 10 4
      src/rpc/jsonserver.rs

+ 5 - 6
src/rpc/adapter.rs

@@ -64,19 +64,18 @@ impl RpcAdapter {
         Ok(())
     }
 
-    pub fn get_key(&self) -> Result<()> {
+    pub fn get_key(&self) -> Result<String> {
         debug!(target: "adapter", "get_key() [START]");
         let key_public = self.wallet.get_public()?; 
         let bs58_address = bs58::encode(serialize(&key_public)).into_string();
-        info!("Address: {}", bs58_address);
-        Ok(())
+        Ok(bs58_address)
     }
 
-    pub fn get_cash_key(&self) -> Result<()> {
+    pub fn get_cash_key(&self) -> Result<String> {
         debug!(target: "adapter", "get_cash_key() [START]");
         let cashier_public = self.wallet.get_cashier_public()?;
-        info!("{:?}", cashier_public);
-        Ok(())
+        let bs58_address = bs58::encode(serialize(&cashier_public)).into_string();
+        Ok(bs58_address)
     }
 
     pub fn test_wallet(&self) -> Result<()> {

+ 10 - 4
src/rpc/jsonserver.rs

@@ -150,16 +150,17 @@ impl RpcInterface {
         io.add_method("get_key", move |_| {
             let self2 = self1.clone();
             async move {
-                self2.adapter.get_key()?;
-                Ok(jsonrpc_core::Value::String("Getting public key...".into()))
+                let pub_key = self2.adapter.get_key()?;
+                Ok(jsonrpc_core::Value::String(pub_key))
             }
         });
+
         let self1 = self.clone();
         io.add_method("get_cash_key", move |_| {
             let self2 = self1.clone();
             async move {
-                self2.adapter.get_cash_key()?;
-                Ok(jsonrpc_core::Value::String("Getting cashier key...".into()))
+                let cash_key = self2.adapter.get_cash_key()?;
+                Ok(jsonrpc_core::Value::String(cash_key))
             }
         });
 
@@ -181,6 +182,7 @@ impl RpcInterface {
             }
         });
         let self1 = self.clone();
+
         io.add_method("create_wallet", move |_| {
             let self2 = self1.clone();
             async move {
@@ -192,6 +194,7 @@ impl RpcInterface {
                 Ok(jsonrpc_core::Value::String("Created wallet".into()))
             }
         });
+
         let self1 = self.clone();
         io.add_method("key_gen", move |_| {
             let self2 = self1.clone();
@@ -203,6 +206,7 @@ impl RpcInterface {
                 ))
             }
         });
+
         let self1 = self.clone();
         io.add_method("cash_key_gen", move |_| {
             let self2 = self1.clone();
@@ -214,6 +218,7 @@ impl RpcInterface {
                 ))
             }
         });
+
         let self1 = self.clone();
         io.add_method("test_wallet", move |_| {
             let self2 = self1.clone();
@@ -223,6 +228,7 @@ impl RpcInterface {
                 Ok(jsonrpc_core::Value::String("Test wallet".into()))
             }
         });
+
         let self1 = self.clone();
         io.add_method("create_cashier_wallet", move |_| {
             let self2 = self1.clone();