summaryrefslogtreecommitdiff
path: root/packages/taler-util
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-10-15 11:52:07 +0200
committerFlorian Dold <florian@dold.me>2022-10-15 11:53:16 +0200
commite075134ffc94fda3582b179122bda594d91a962b (patch)
tree547920b2aa07bdb9f2c87a0c1f8c35dbcd64c8f7 /packages/taler-util
parent4d70391f3db386766a516bdecc3d1d265c5d49a1 (diff)
downloadwallet-core-e075134ffc94fda3582b179122bda594d91a962b.tar.gz
wallet-core-e075134ffc94fda3582b179122bda594d91a962b.tar.bz2
wallet-core-e075134ffc94fda3582b179122bda594d91a962b.zip
wallet-core: simplify coin record
we only track the allocation now, not the remaining amount
Diffstat (limited to 'packages/taler-util')
-rw-r--r--packages/taler-util/src/backup-types.ts11
-rw-r--r--packages/taler-util/src/taler-types.ts54
-rw-r--r--packages/taler-util/src/wallet-types.ts81
3 files changed, 86 insertions, 60 deletions
diff --git a/packages/taler-util/src/backup-types.ts b/packages/taler-util/src/backup-types.ts
index 6c7b203b5..5d53f178e 100644
--- a/packages/taler-util/src/backup-types.ts
+++ b/packages/taler-util/src/backup-types.ts
@@ -475,6 +475,7 @@ export interface BackupRecoupGroup {
timestamp_finish?: TalerProtocolTimestamp;
finish_clock?: TalerProtocolTimestamp;
+ // FIXME: Use some enum here!
finish_is_failure?: boolean;
/**
@@ -483,7 +484,6 @@ export interface BackupRecoupGroup {
coins: {
coin_pub: string;
recoup_finished: boolean;
- old_amount: BackupAmountString;
}[];
}
@@ -582,9 +582,14 @@ export interface BackupCoin {
denom_sig: UnblindedSignature;
/**
- * Amount that's left on the coin.
+ * Information about where and how the coin was spent.
*/
- current_amount: BackupAmountString;
+ spend_allocation:
+ | {
+ id: string;
+ amount: BackupAmountString;
+ }
+ | undefined;
/**
* Blinding key used when withdrawing the coin.
diff --git a/packages/taler-util/src/taler-types.ts b/packages/taler-util/src/taler-types.ts
index de88fef69..71ceb7939 100644
--- a/packages/taler-util/src/taler-types.ts
+++ b/packages/taler-util/src/taler-types.ts
@@ -968,60 +968,6 @@ export class WithdrawBatchResponse {
ev_sigs: WithdrawResponse[];
}
-/**
- * Easy to process format for the public data of coins
- * managed by the wallet.
- */
-export interface CoinDumpJson {
- coins: Array<{
- /**
- * The coin's denomination's public key.
- */
- denom_pub: DenominationPubKey;
- /**
- * Hash of denom_pub.
- */
- denom_pub_hash: string;
- /**
- * Value of the denomination (without any fees).
- */
- denom_value: string;
- /**
- * Public key of the coin.
- */
- coin_pub: string;
- /**
- * Base URL of the exchange for the coin.
- */
- exchange_base_url: string;
- /**
- * Remaining value on the coin, to the knowledge of
- * the wallet.
- */
- remaining_value: string;
- /**
- * Public key of the parent coin.
- * Only present if this coin was obtained via refreshing.
- */
- refresh_parent_coin_pub: string | undefined;
- /**
- * Public key of the reserve for this coin.
- * Only present if this coin was obtained via refreshing.
- */
- withdrawal_reserve_pub: string | undefined;
- /**
- * Is the coin suspended?
- * Suspended coins are not considered for payments.
- */
- coin_suspended: boolean;
-
- /**
- * Information about the age restriction
- */
- ageCommitmentProof: AgeCommitmentProof | undefined;
- }>;
-}
-
export interface MerchantPayResponse {
sig: string;
}
diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts
index d4de53972..54f4c54a2 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -63,7 +63,10 @@ import {
ExchangeAuditor,
UnblindedSignature,
} from "./taler-types.js";
-import { OrderShortInfo, codecForOrderShortInfo } from "./transactions-types.js";
+import {
+ OrderShortInfo,
+ codecForOrderShortInfo,
+} from "./transactions-types.js";
import { BackupRecovery } from "./backup-types.js";
import { PaytoUri } from "./payto.js";
import { TalerErrorCode } from "./taler-error-codes.js";
@@ -141,6 +144,77 @@ export function mkAmount(
return { value, fraction, currency };
}
+/**
+ * Status of a coin.
+ */
+export enum CoinStatus {
+ /**
+ * Withdrawn and never shown to anybody.
+ */
+ Fresh = "fresh",
+
+ /**
+ * Fresh, but currently marked as "suspended", thus won't be used
+ * for spending. Used for testing.
+ */
+ FreshSuspended = "fresh-suspended",
+
+ /**
+ * A coin that has been spent and refreshed.
+ */
+ Dormant = "dormant",
+}
+
+/**
+ * Easy to process format for the public data of coins
+ * managed by the wallet.
+ */
+export interface CoinDumpJson {
+ coins: Array<{
+ /**
+ * The coin's denomination's public key.
+ */
+ denom_pub: DenominationPubKey;
+ /**
+ * Hash of denom_pub.
+ */
+ denom_pub_hash: string;
+ /**
+ * Value of the denomination (without any fees).
+ */
+ denom_value: string;
+ /**
+ * Public key of the coin.
+ */
+ coin_pub: string;
+ /**
+ * Base URL of the exchange for the coin.
+ */
+ exchange_base_url: string;
+ /**
+ * Public key of the parent coin.
+ * Only present if this coin was obtained via refreshing.
+ */
+ refresh_parent_coin_pub: string | undefined;
+ /**
+ * Public key of the reserve for this coin.
+ * Only present if this coin was obtained via refreshing.
+ */
+ withdrawal_reserve_pub: string | undefined;
+ coin_status: CoinStatus;
+ spend_allocation:
+ | {
+ id: string;
+ amount: string;
+ }
+ | undefined;
+ /**
+ * Information about the age restriction
+ */
+ ageCommitmentProof: AgeCommitmentProof | undefined;
+ }>;
+}
+
export enum ConfirmPayResultType {
Done = "done",
Pending = "pending",
@@ -568,10 +642,11 @@ export enum RefreshReason {
}
/**
- * Wrapper for coin public keys.
+ * Request to refresh a single coin.
*/
-export interface CoinPublicKey {
+export interface CoinRefreshRequest {
readonly coinPub: string;
+ readonly amount: AmountJson;
}
/**