mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
return asset_id when request token public key from cashierdb
This commit is contained in:
@@ -204,8 +204,7 @@ impl CashierDb {
|
||||
pub fn get_withdraw_coin_public_key_by_dkey_public(
|
||||
&self,
|
||||
pub_key: &jubjub::SubgroupPoint,
|
||||
asset_id: &Vec<u8>,
|
||||
) -> Result<Option<Vec<u8>>> {
|
||||
) -> Result<Option<(Vec<u8>, jubjub::Fr)>> {
|
||||
debug!(target: "CASHIERDB", "Get coin address by pub_key");
|
||||
// open connection
|
||||
let conn = Connection::open(&self.path)?;
|
||||
@@ -217,15 +216,18 @@ impl CashierDb {
|
||||
let confirm = self.get_value_serialized(&false)?;
|
||||
|
||||
let mut stmt = conn.prepare(
|
||||
"SELECT coin_key_id FROM withdraw_keypairs WHERE d_key_public = :d_key_public AND asset_id = :asset_id AND confirm = :confirm;",
|
||||
"SELECT coin_key_id, asset_id FROM withdraw_keypairs WHERE d_key_public = :d_key_public AND confirm = :confirm;",
|
||||
)?;
|
||||
let addr_iter = stmt.query_map::<Vec<u8>, _, _>(
|
||||
&[
|
||||
(":d_key_public", &d_key_public),
|
||||
(":asset_id", &asset_id),
|
||||
(":confirm", &&confirm),
|
||||
],
|
||||
|row| Ok(row.get(0)?),
|
||||
let addr_iter = stmt.query_map::<(Vec<u8>, jubjub::Fr), _, _>(
|
||||
&[(":d_key_public", &d_key_public), (":confirm", &&confirm)],
|
||||
|row| {
|
||||
let coin_public_key = row.get(0)?;
|
||||
let asset_id = row.get(1)?;
|
||||
let asset_id: jubjub::Fr = self
|
||||
.get_value_deserialized(asset_id)
|
||||
.expect("deserialize asset_id");
|
||||
Ok((coin_public_key, asset_id))
|
||||
},
|
||||
)?;
|
||||
|
||||
let mut coin_addresses = vec![];
|
||||
|
||||
@@ -14,6 +14,7 @@ pub trait WalletApi {
|
||||
Ok(v)
|
||||
}
|
||||
|
||||
// TODO pass a reference of Vec<u8>
|
||||
fn get_value_deserialized<D: Decodable>(&self, key: Vec<u8>) -> Result<D> {
|
||||
let v: D = deserialize(&key)?;
|
||||
Ok(v)
|
||||
|
||||
Reference in New Issue
Block a user