blob: 44fa4fdd6ed70d1e5879b675146fc2bb9db742f3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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();
};
|