fix an error happen when query public key from walletdb

This commit is contained in:
ghassmo
2021-08-05 05:01:02 +03:00
parent d945634cd9
commit 40d71df4dd
2 changed files with 8 additions and 3 deletions

View File

@@ -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();

View File

@@ -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)
}