aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-03 09:15:39 -0800
committerAdam Soltys <[email protected]>2026-02-06 08:58:12 -0800
commit5e3bfba5eb3d54cc03551f98624a2e92dca5825f (patch)
tree723e0be4e4f0a987fa2375fcf0360022f1232eaa /lib
parent4850177f50b7ff5a0f37acaa92190219d6f72da5 (diff)
downloadcoinos-server-5e3bfba5eb3d54cc03551f98624a2e92dca5825f.tar.gz
coinos-server-5e3bfba5eb3d54cc03551f98624a2e92dca5825f.zip
custodial ark payments
Diffstat (limited to 'lib')
-rw-r--r--lib/ark.ts32
-rw-r--r--lib/invoices.ts2
2 files changed, 34 insertions, 0 deletions
diff --git a/lib/ark.ts b/lib/ark.ts
new file mode 100644
index 00000000..44fa4fdd
--- /dev/null
+++ b/lib/ark.ts
@@ -0,0 +1,32 @@
+import { EventSource } from "eventsource";
+if (!globalThis.EventSource) globalThis.EventSource = EventSource;
+
+import config from "$config";
+import { SingleKey, Wallet } from "@arkade-os/sdk";
+
+let wallet: any;
+
+const getWallet = async () => {
+ if (wallet) return wallet;
+
+ const { arkPrivateKey, arkServerUrl } = config.ark;
+ const identity = SingleKey.fromHex(arkPrivateKey);
+
+ wallet = await Wallet.create({ identity, arkServerUrl });
+ return wallet;
+};
+
+export const sendArk = async (address: string, amount: number) => {
+ const w = await getWallet();
+ return w.sendBitcoin({ address, amount });
+};
+
+export const getArkAddress = async () => {
+ const w = await getWallet();
+ return w.getAddress();
+};
+
+export const getArkBalance = async () => {
+ const w = await getWallet();
+ return w.getBalance();
+};
diff --git a/lib/invoices.ts b/lib/invoices.ts
index 6ddffe54..50cddd9a 100644
--- a/lib/invoices.ts
+++ b/lib/invoices.ts
@@ -131,6 +131,8 @@ export const generate = async ({ invoice, user }) => {
} else if (type === PaymentType.ecash) {
hash = id;
text = request(id, amount, memo);
+ } else if (type === PaymentType.ark) {
+ hash = id;
} else {
fail(`unrecognized type ${type}`);
}