Преглед на файлове

fix an error happen when query public key from walletdb

ghassmo преди 5 години
родител
ревизия
40d71df4dd
променени са 2 файла, в които са добавени 8 реда и са изтрити 3 реда
  1. 1 1
      src/rpc/jsonserver.rs
  2. 7 2
      src/wallet/walletdb.rs

+ 1 - 1
src/rpc/jsonserver.rs

@@ -151,7 +151,7 @@ impl RpcInterface {
             let self2 = self1.clone();
             async move {
                 self2.adapter.get_key()?;
-                Ok(jsonrpc_core::Value::String("Getting cashier key...".into()))
+                Ok(jsonrpc_core::Value::String("Getting public key...".into()))
             }
         });
         let self1 = self.clone();

+ 7 - 2
src/wallet/walletdb.rs

@@ -216,12 +216,17 @@ impl WalletDb {
         conn.pragma_update(None, "key", &self.password)?;
         let mut stmt = conn.prepare("SELECT key_public FROM keys")?;
         // this just gets the first key. maybe we should randomize this
-        let key_iter = stmt.query_map::<u8, _, _>([], |row| row.get(0))?;
+        let key_iter = stmt.query_map::<Vec<u8>, _, _>([], |row| row.get(0))?;
         let mut pub_keys = Vec::new();
         for key in key_iter {
             pub_keys.push(key?);
         }
-        let public: jubjub::SubgroupPoint = self.get_value_deserialized(pub_keys)?;
+        let public: jubjub::SubgroupPoint = self.get_value_deserialized(
+            pub_keys
+                .pop()
+                .expect("unable to load public_key from walletdb"),
+        )?;
+
         Ok(public)
     }