From 5e3bfba5eb3d54cc03551f98624a2e92dca5825f Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 3 Feb 2026 09:15:39 -0800 Subject: custodial ark payments --- lib/ark.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 lib/ark.ts (limited to 'lib/ark.ts') 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(); +}; -- cgit v1.2.3