drk: Store bs58 encoded transaction history in the wallet

This commit is contained in:
parazyd
2023-06-01 15:57:20 +02:00
parent 572df8883f
commit f73856ecac
3 changed files with 13 additions and 6 deletions

View File

@@ -171,8 +171,7 @@ impl Drk {
let txid = serde_json::from_value(rep)?;
// Store transactions history record
// FIXME: This breaks with the DAO::Exec transaction
//self.insert_tx_history_record(tx).await?;
self.insert_tx_history_record(tx).await?;
Ok(txid)
}

View File

@@ -80,7 +80,7 @@ impl Drk {
WALLET_TXS_HISTORY_COL_TX_HASH,
QueryType::Text as u8,
WALLET_TXS_HISTORY_COL_STATUS,
QueryType::Blob as u8,
QueryType::Text as u8,
WALLET_TXS_HISTORY_COL_TX,
]);
@@ -99,7 +99,8 @@ impl Drk {
let status: String = serde_json::from_value(arr[1].clone())?;
let tx_bytes: Vec<u8> = serde_json::from_value(arr[2].clone())?;
let tx_encoded: String = serde_json::from_value(arr[2].clone())?;
let tx_bytes: Vec<u8> = bs58::decode(&tx_encoded).into_vec()?;
let tx: Transaction = deserialize(&tx_bytes)?;
Ok((tx_hash, status, tx))
@@ -121,8 +122,8 @@ impl Drk {
tx.hash().to_string(),
QueryType::Text as u8,
"Broadcasted",
QueryType::Blob as u8,
serialize(tx),
QueryType::Text as u8,
bs58::encode(&serialize(tx)).into_string().to_string(),
]);
let req = JsonRequest::new("wallet.exec_sql", params);

View File

@@ -50,3 +50,10 @@ CREATE TABLE IF NOT EXISTS money_aliases (
alias BLOB PRIMARY KEY NOT NULL,
token_id BLOB NOT NULL
);
CREATE TABLE IF NOT EXISTS transactions_history (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
transaction_hash TEXT UNIQUE NOT NULL,
status TEXT NOT NULL,
tx TEXT UNIQUE NOT NULL
);