From f8cfd7e189c62c6325a126df1dda3b24cb1bbc36 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 16 Aug 2024 14:27:56 -0700 Subject: transfer ecash --- routes/ecash.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 routes/ecash.js (limited to 'routes') diff --git a/routes/ecash.js b/routes/ecash.js new file mode 100644 index 00000000..6ca570bf --- /dev/null +++ b/routes/ecash.js @@ -0,0 +1,18 @@ +import { CashuMint, CashuWallet, MintQuoteState } from '@cashu/cashu-ts'; + +export default { + async mint({ body }, res) { + const mintUrl = 'http://mint:3338'; // the mint URL + const mint = new CashuMint(mintUrl); + const wallet = new CashuWallet(mint); + const mintQuote = await wallet.createMintQuote(64); + console.log(mintQuote) + // pay the invoice here before you continue... + const mintQuoteChecked = await wallet.checkMintQuote(mintQuote.quote); + console.log(mintQuoteChecked) + if (mintQuoteChecked.state == MintQuoteState.PAID) { + const { proofs } = await wallet.mintTokens(64, mintQuote.quote); + console.log(proofs) + } + } +} -- cgit v1.2.3