aboutsummaryrefslogtreecommitdiffstats
path: root/lib/utils.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-01-13 20:27:18 -0800
committerAdam Soltys <[email protected]>2023-01-13 20:27:18 -0800
commit8a114c50efaac41767042766f05390aa906da157 (patch)
treeeb65bc1e9adf3614cb30798210328f7e83e0a0ce /lib/utils.js
parentc3565838644123e77881ff4f8536792f074047b9 (diff)
downloadcoinos-server-8a114c50efaac41767042766f05390aa906da157.tar.gz
coinos-server-8a114c50efaac41767042766f05390aa906da157.zip
migrating to redis
Diffstat (limited to 'lib/utils.js')
-rw-r--r--lib/utils.js21
1 files changed, 1 insertions, 20 deletions
diff --git a/lib/utils.js b/lib/utils.js
index 559f8531..b556c46a 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -1,7 +1,6 @@
import store from "$lib/store";
import { g } from "$lib/redis";
import config from "$config";
-import ln from "$lib/ln";
export const nada = () => {};
@@ -18,15 +17,6 @@ export const requirePin = async ({ body, user }) => {
throw new Error("Invalid pin");
};
-export const getUser = async (uuid) => {
- let user = g(`user:${uuid}`);
- if (!user) throw new Error("user not found");
-
- user.haspin = !!user.pin;
-
- return user;
-};
-
export const prod = process.env.NODE_ENV === "production";
export const fail = msg => {
throw new Error(msg);
@@ -35,14 +25,5 @@ export const fail = msg => {
export const SATS = 100000000;
export const toSats = n => Math.round(n * SATS);
-export const derivePayRequest = async ({ amount, memo, tip }) => {
- if (!tip) tip = 0;
- let value = amount + tip;
-
- if (!memo) memo = "coinos";
- return (
- await ln.invoice(value ? `${value}sat` : "any", new Date(), memo, 360)
- ).bolt11;
-};
-
export const uniq = (a, k) => [...new Map(a.map(x => [k(x), x])).values()];
+export const pick = (O, K) => K.reduce((o, k) => ((o[k] = O[k]), o), {});