aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ecash.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ecash.ts')
-rw-r--r--lib/ecash.ts23
1 files changed, 23 insertions, 0 deletions
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();
+}