diff options
author | Florian Dold <florian@dold.me> | 2022-09-16 16:20:47 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-09-16 16:32:21 +0200 |
commit | b91caf977fad8da11e523ca3a39064dd86e04c64 (patch) | |
tree | 732e1543d2555094d7f9a9ca242309847c1a33a3 /packages/taler-wallet-core/src/db.ts | |
parent | 2747bc260bc05418974570d04d7f999dfc988cda (diff) | |
download | wallet-core-b91caf977fad8da11e523ca3a39064dd86e04c64.tar.xz |
wallet-core: support age restrictions in new coin selection
Diffstat (limited to 'packages/taler-wallet-core/src/db.ts')
-rw-r--r-- | packages/taler-wallet-core/src/db.ts | 55 |
1 files changed, 46 insertions, 9 deletions
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index 760234941..6466edf5a 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -319,11 +319,6 @@ export interface DenominationRecord { * that includes this denomination. */ listIssueDate: TalerProtocolTimestamp; - - /** - * Number of fresh coins of this denomination that are available. - */ - freshCoinCount?: number; } export namespace DenominationRecord { @@ -546,6 +541,8 @@ export interface PlanchetRecord { coinEvHash: string; + maxAge: number; + ageCommitmentProof?: AgeCommitmentProof; } @@ -674,6 +671,8 @@ export interface CoinRecord { */ allocation?: CoinAllocation; + maxAge: number; + ageCommitmentProof?: AgeCommitmentProof; } @@ -1770,7 +1769,45 @@ export interface OperationAttemptLongpollResult { type: OperationAttemptResultType.Longpoll; } +/** + * Availability of coins of a given denomination (and age restriction!). + * + * We can't store this information with the denomination record, as one denomination + * can be withdrawn with multiple age restrictions. + */ +export interface CoinAvailabilityRecord { + currency: string; + amountVal: number; + amountFrac: number; + denomPubHash: string; + exchangeBaseUrl: string; + + /** + * Age restriction on the coin, or 0 for no age restriction (or + * denomination without age restriction support). + */ + maxAge: number; + + /** + * Number of fresh coins of this denomination that are available. + */ + freshCoinCount: number; +} + export const WalletStoresV1 = { + coinAvailability: describeStore( + "coinAvailability", + describeContents<CoinAvailabilityRecord>({ + keyPath: ["exchangeBaseUrl", "denomPubHash", "maxAge"], + }), + { + byExchangeAgeAvailability: describeIndex("byExchangeAgeAvailability", [ + "exchangeBaseUrl", + "maxAge", + "freshCoinCount", + ]), + }, + ), coins: describeStore( "coins", describeContents<CoinRecord>({ @@ -1779,10 +1816,10 @@ export const WalletStoresV1 = { { byBaseUrl: describeIndex("byBaseUrl", "exchangeBaseUrl"), byDenomPubHash: describeIndex("byDenomPubHash", "denomPubHash"), - byDenomPubHashAndStatus: describeIndex("byDenomPubHashAndStatus", [ - "denomPubHash", - "status", - ]), + byExchangeDenomPubHashAndAgeAndStatus: describeIndex( + "byExchangeDenomPubHashAndAgeAndStatus", + ["exchangeBaseUrl", "denomPubHash", "maxAge", "status"], + ), byCoinEvHash: describeIndex("byCoinEvHash", "coinEvHash"), }, ), |