taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 38357f6735361010d6030ebb8ebfc57fde7e1c8e
parent 7bae442956ab603886979ff99a6aff816ed1bc19
Author: Florian Dold <dold@taler.net>
Date:   Thu,  3 Sep 2026 15:41:17 +0200

wallet-core: refuse to spend a coin that is no longer fresh

Diffstat:
Mpackages/taler-wallet-core/src/common.ts | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/packages/taler-wallet-core/src/common.ts b/packages/taler-wallet-core/src/common.ts @@ -247,6 +247,14 @@ export async function spendCoins( if (!coin) { throw Error("coin allocated for payment doesn't exist anymore"); } + if (coin.status !== CoinStatus.Fresh) { + // Selection and spending are not always in one transaction; a coin + // another operation took in between must fail this one instead of + // being spent twice. + throw Error( + `coin ${coin.coinPub} allocated for payment is not fresh (status ${coin.status})`, + ); + } const denomKey = denomRefKey(coin); const denom = denomByRef.get(denomKey); checkDbInvariant(