From b82f045fe567f25c7d0a9fbb5163853373cd616c Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 22 Nov 2024 22:42:35 -0800 Subject: ecash receive --- lib/ecash.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'lib/ecash.ts') diff --git a/lib/ecash.ts b/lib/ecash.ts index 7c44bec0..1a214b46 100644 --- a/lib/ecash.ts +++ b/lib/ecash.ts @@ -6,11 +6,16 @@ import { CashuMint, CashuWallet, MintQuoteState, + PaymentRequest, + PaymentRequestTransport, + PaymentRequestTransportType, getDecodedToken, getEncodedToken, getEncodedTokenV4, } from "@cashu/cashu-ts"; +import { v4 } from "uuid"; +const { URL } = process.env; const m = new CashuMint(config.mintUrl); const w = new CashuWallet(m); @@ -92,3 +97,21 @@ export async function init(amount = 100000) { console.log(e); } } + +export function request(uuid, amount, memo) { + const target = `${URL}/ecash/${uuid}`; + const tags = [["n", "17"]]; + + const { POST: type } = PaymentRequestTransportType; + const transport = [{ type, target, tags }]; + const unit = "sat"; + + return new PaymentRequest( + transport, + uuid, + amount, + unit, + config.mintUrl, + memo, + ).toEncodedRequest(); +} -- cgit v1.2.3