diff --git a/.env b/.env index d0574b8..a92e67b 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ PORT=3000 MINT_URL='https://legend.lnbits.com/cashu/api/v1/4gr9Xcmz3XEkUNwiBiQGoC' -FAUCET_INTERVAL=10000 -SATS_PER_INTERVAL=10 \ No newline at end of file +FAUCET_INTERVAL=5000 +SATS_PER_INTERVAL=1 \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 37f6af6..baf66f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@gandlaf21/cashu-tools": "^0.1.4", + "@gandlaf21/cashu-tools": "^0.1.5", "cors": "^2.8.5", "dotenv": "^16.0.3", "express": "^4.18.2", @@ -76,18 +76,18 @@ } }, "node_modules/@gandlaf21/cashu-tools": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/@gandlaf21/cashu-tools/-/cashu-tools-0.1.4.tgz", - "integrity": "sha512-ifWxlko6yDlEMWfTx7HzNhSvxm2jiJZi/b9BssFIFNlvh5pyJiI4Lm7gzHWDsbYfnvlQDN72vebrRij0s6Lcpg==", + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/@gandlaf21/cashu-tools/-/cashu-tools-0.1.5.tgz", + "integrity": "sha512-rKydq6pIHuFZvxMt2FjZd93GRdQGxKmLLkX4NW8bxJ+Um35q3ehXs06i8y695i0rqhZkblqJFjjztrbfzu4USA==", "dependencies": { - "@gandlaf21/cashu-ts": "^0.5.0", + "@gandlaf21/cashu-ts": "^0.6.0", "lnurl-pay": "^2.1.1" } }, "node_modules/@gandlaf21/cashu-ts": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@gandlaf21/cashu-ts/-/cashu-ts-0.5.0.tgz", - "integrity": "sha512-V0qY3E49FMvdXEn8af/uYkSOQGbczzBJU/kBA/6vSIN4ZKWgjsSoYpPmzKtpD9dmyr4gJHxp7LbELodogTSygw==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@gandlaf21/cashu-ts/-/cashu-ts-0.6.0.tgz", + "integrity": "sha512-5K46HrdIiWXwzTkCq+qM50KOSNjWnHIKz+aZFH0X6dVgTNNYUWP/ucBxiOuHKs71VfjqWmDl0KqSAptKdclkEQ==", "dependencies": { "@gandlaf21/bolt11-decode": "^3.0.6", "@noble/secp256k1": "^1.7.0", @@ -1534,18 +1534,18 @@ } }, "@gandlaf21/cashu-tools": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/@gandlaf21/cashu-tools/-/cashu-tools-0.1.4.tgz", - "integrity": "sha512-ifWxlko6yDlEMWfTx7HzNhSvxm2jiJZi/b9BssFIFNlvh5pyJiI4Lm7gzHWDsbYfnvlQDN72vebrRij0s6Lcpg==", + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/@gandlaf21/cashu-tools/-/cashu-tools-0.1.5.tgz", + "integrity": "sha512-rKydq6pIHuFZvxMt2FjZd93GRdQGxKmLLkX4NW8bxJ+Um35q3ehXs06i8y695i0rqhZkblqJFjjztrbfzu4USA==", "requires": { - "@gandlaf21/cashu-ts": "^0.5.0", + "@gandlaf21/cashu-ts": "^0.6.0", "lnurl-pay": "^2.1.1" } }, "@gandlaf21/cashu-ts": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@gandlaf21/cashu-ts/-/cashu-ts-0.5.0.tgz", - "integrity": "sha512-V0qY3E49FMvdXEn8af/uYkSOQGbczzBJU/kBA/6vSIN4ZKWgjsSoYpPmzKtpD9dmyr4gJHxp7LbELodogTSygw==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@gandlaf21/cashu-ts/-/cashu-ts-0.6.0.tgz", + "integrity": "sha512-5K46HrdIiWXwzTkCq+qM50KOSNjWnHIKz+aZFH0X6dVgTNNYUWP/ucBxiOuHKs71VfjqWmDl0KqSAptKdclkEQ==", "requires": { "@gandlaf21/bolt11-decode": "^3.0.6", "@noble/secp256k1": "^1.7.0", diff --git a/package.json b/package.json index 6e767bb..8f124b8 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "author": "gandlaf21", "license": "ISC", "dependencies": { - "@gandlaf21/cashu-tools": "^0.1.4", + "@gandlaf21/cashu-tools": "^0.1.5", "cors": "^2.8.5", "dotenv": "^16.0.3", "express": "^4.18.2", diff --git a/server.js b/server.js index 99ab7d4..65bbe77 100644 --- a/server.js +++ b/server.js @@ -1,7 +1,7 @@ require('dotenv').config() -const { CashuMint, CashuWallet, getEncodedProofs } = require("@gandlaf21/cashu-ts") -const { Faucet, utils } = require ("@gandlaf21/cashu-tools") +const { getEncodedProofs } = require("@gandlaf21/cashu-ts") +const { AnarchoFaucet , utils } = require ("@gandlaf21/cashu-tools") const rateLimit = require('express-rate-limit') const cors = require('cors'); @@ -23,29 +23,26 @@ app.use(cors()); app.get('/', (req, res) => { let responseString ="Token has already been claimed! waiting for next token..." - if(faucet.currentToken.length>0){ + if(faucet.currentToken){ responseString = - getEncodedProofs(faucet.currentToken ,[{url:process.env.MINT_URL, keysets: [...new Set(faucet.currentToken.map(t=>t.id))]}]) + getEncodedProofs(faucet.currentToken.proofs ,faucet.currentToken.mints) } res.send({token: responseString}) }) app.get('/balance', async (req, res) => { - res.send({remaining: utils.getAmountForTokenSet(faucet.balance)}) + res.send({remaining: utils.getAmountForTokenSet(faucet.balance), + mintCount: faucet.wallets.length}) }) app.get('/charge', async (req, res) => { const token = req.query.token const message = await faucet.charge(token) - console.log("all Tokens: ", getEncodedProofs(faucet.balance ,[{url:process.env.MINT_URL, keysets: [...new Set(faucet.currentToken.map(t=>t.id))]}])) res.send({message}) }) app.listen(port, async () => { - const cashuMint = new CashuMint(process.env.MINT_URL) - const keys = await cashuMint.getKeys() - const cashuWallet = new CashuWallet(keys, cashuMint) - faucet = new Faucet(cashuWallet, process.env.FAUCET_INTERVAL, process.env.SATS_PER_INTERVAL) + faucet = new AnarchoFaucet(process.env.FAUCET_INTERVAL, process.env.SATS_PER_INTERVAL) await faucet.start() console.log(`Example app listening on port ${port}`) })