mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-20 14:14:49 +01:00
feat: use derivation path by unit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
ALTER TABLE keyset ADD derivation_path_index INTEGER;
|
||||
@@ -408,8 +408,8 @@ WHERE id=?
|
||||
sqlx::query(
|
||||
r#"
|
||||
INSERT OR REPLACE INTO keyset
|
||||
(id, unit, active, valid_from, valid_to, derivation_path, max_order, input_fee_ppk)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?);
|
||||
(id, unit, active, valid_from, valid_to, derivation_path, max_order, input_fee_ppk, derivation_path_index)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);
|
||||
"#,
|
||||
)
|
||||
.bind(keyset.id.to_string())
|
||||
@@ -420,6 +420,7 @@ VALUES (?, ?, ?, ?, ?, ?, ?, ?);
|
||||
.bind(keyset.derivation_path.to_string())
|
||||
.bind(keyset.max_order)
|
||||
.bind(keyset.input_fee_ppk as i64)
|
||||
.bind(keyset.derivation_path_index)
|
||||
.execute(&self.pool)
|
||||
.await
|
||||
.map_err(Error::from)?;
|
||||
@@ -716,6 +717,8 @@ fn sqlite_row_to_keyset_info(row: SqliteRow) -> Result<MintKeySetInfo, Error> {
|
||||
let row_derivation_path: String = row.try_get("derivation_path").map_err(Error::from)?;
|
||||
let row_max_order: u8 = row.try_get("max_order").map_err(Error::from)?;
|
||||
let row_keyset_ppk: Option<i64> = row.try_get("input_fee_ppk").map_err(Error::from)?;
|
||||
let row_derivation_path_index: Option<i64> =
|
||||
row.try_get("derivation_path_index").map_err(Error::from)?;
|
||||
|
||||
Ok(MintKeySetInfo {
|
||||
id: Id::from_str(&row_id).map_err(Error::from)?,
|
||||
@@ -724,6 +727,7 @@ fn sqlite_row_to_keyset_info(row: SqliteRow) -> Result<MintKeySetInfo, Error> {
|
||||
valid_from: row_valid_from as u64,
|
||||
valid_to: row_valid_to.map(|v| v as u64),
|
||||
derivation_path: DerivationPath::from_str(&row_derivation_path).map_err(Error::from)?,
|
||||
derivation_path_index: row_derivation_path_index.map(|d| d as u32),
|
||||
max_order: row_max_order,
|
||||
input_fee_ppk: row_keyset_ppk.unwrap_or(0) as u64,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user