diff options
| author | Adam Soltys <[email protected]> | 2024-08-20 16:13:50 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-08-20 16:13:50 -0700 |
| commit | 6588913c949d5440c33e657b0a86ed62ba94164e (patch) | |
| tree | ebfcb6c1c703a729492fdcb904c27a6d8dff99a1 /lib/ecash.js | |
| parent | 0dd1feac21158c13cf99a96a306f3c8bf92e31cd (diff) | |
| download | coinos-server-6588913c949d5440c33e657b0a86ed62ba94164e.tar.gz coinos-server-6588913c949d5440c33e657b0a86ed62ba94164e.zip | |
show spent ecash
Diffstat (limited to 'lib/ecash.js')
| -rw-r--r-- | lib/ecash.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/ecash.js b/lib/ecash.js index 0e4a3c1a..df7759bf 100644 --- a/lib/ecash.js +++ b/lib/ecash.js @@ -32,3 +32,13 @@ export async function mint(amount) { await s(`cash`, enc(returnChange)); return enc(rcvd); } + +export async function check(token) { + let { proofs } = dec(token); + let total = proofs.reduce((a, b) => a + b.amount, 0); + + let r = await wallet.checkProofsSpent(proofs); + let spent = r.reduce((a, b) => a + b.amount, 0); + + return { total, spent }; +} |
