aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/db.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-06-13 18:19:20 +0200
committerFlorian Dold <florian@dold.me>2024-06-13 18:22:23 +0200
commit10aa5e767a35d39d6612f5e4addf4e04f3241a42 (patch)
tree70d62dbbe02a9257e0af988a09de8cc0ee9ba557 /packages/taler-wallet-core/src/db.ts
parent955b957ef6d7d27d444d363cf80ea8942233f97c (diff)
downloadwallet-core-10aa5e767a35d39d6612f5e4addf4e04f3241a42.tar.xz
wallet-core: introduce coin history store, spend coins transactionally
Diffstat (limited to 'packages/taler-wallet-core/src/db.ts')
-rw-r--r--packages/taler-wallet-core/src/db.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts
index 5c381eea7..0ce838fd2 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -912,6 +912,27 @@ export interface CoinRecord {
ageCommitmentProof: AgeCommitmentProof | undefined;
}
+export type HistoryItem =
+ | {
+ type: "withdraw";
+ transactionId: TransactionIdStr;
+ }
+ | { type: "spend"; transactionId: TransactionIdStr; amount: AmountString }
+ | { type: "refresh"; transactionId: TransactionIdStr; amount: AmountString }
+ | { type: "recoup"; transactionId: TransactionIdStr; amount: AmountString }
+ | { type: "refund"; transactionId: TransactionIdStr; amount: AmountString };
+
+/**
+ * History event for a coin from the wallet's perspective.
+ */
+export interface CoinHistoryRecord {
+ coinPub: string;
+
+ timestamp: DbPreciseTimestamp;
+
+ item: HistoryItem;
+}
+
/**
* Coin allocation, i.e. what a coin has been used for.
*/
@@ -2423,6 +2444,11 @@ export const WalletStoresV1 = {
}),
},
),
+ coinHistory: describeStoreV2({
+ storeName: "coinHistory",
+ recordCodec: passthroughCodec<CoinHistoryRecord>(),
+ keyPath: ["coinPub", "timestamp"],
+ }),
coins: describeStore(
"coins",
describeContents<CoinRecord>({