@ibearua/bitmask-core-dev 1.0.0-beta.11 → 1.0.0-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bp.ts ADDED
@@ -0,0 +1,72 @@
1
+
2
+ // BP
3
+ import * as BMC from "./bitmask_core";
4
+ import {FundVaultDetails, TransactionDataDetails, WalletTransaction} from "./bitcoin";
5
+
6
+ export const transferBtc = async (
7
+ nostrHexSk: string,
8
+ address: string,
9
+ sats: bigint,
10
+ feeRate: number,
11
+ secrets: string[],
12
+ ): Promise<TransactionData> => JSON.parse(await BMC.transfer_sats(nostrHexSk,address, sats, feeRate, secrets));
13
+
14
+ export const fundRgbVault = async (
15
+ nostrHexSk: string,
16
+ feeRate: number,
17
+ secrets: string[],
18
+ broadcast: boolean,
19
+ fundValue?: bigint | null,
20
+ coordinatorFee?: boolean | null,
21
+ ): Promise<FundVaultDetails> => JSON.parse(await BMC.fund_rgb_vault(
22
+ nostrHexSk,
23
+ feeRate,
24
+ secrets,
25
+ broadcast,
26
+ fundValue || null,
27
+ coordinatorFee || false,
28
+ ));
29
+
30
+ export const backupBtcWallet = async (
31
+ nostrHexSk: string,
32
+ ): Promise<boolean> => JSON.parse(await BMC.backup_btc_data(nostrHexSk));
33
+
34
+ export const restoreBtcWallet = async (
35
+ nostrHexSk: string,
36
+ ): Promise<boolean> => JSON.parse(await BMC.restore_btc_data(nostrHexSk));
37
+
38
+ export const recoverFundsFromBadWallets = async (
39
+ seed: string,
40
+ passPhrase: string,
41
+ recoverAddress: string,
42
+ ): Promise<RecoverVaultDetails> => JSON.parse(await BMC.recover_funds_from_bad_wallets(seed, passPhrase, recoverAddress));
43
+
44
+ export const getBtcWallet = async (
45
+ nostrHexSk: string,
46
+ ): Promise<WalletData> => JSON.parse(await BMC.get_btc_wallet(nostrHexSk));
47
+
48
+
49
+ export interface TransactionData {
50
+ details: TransactionDataDetails;
51
+ vsize: number;
52
+ feeRate: number;
53
+ }
54
+
55
+ export interface WalletBalance {
56
+ confirmed: number;
57
+ }
58
+
59
+
60
+ export interface WalletData {
61
+ wallet?: string;
62
+ name: string;
63
+ address: string;
64
+ balance: WalletBalance;
65
+ transactions: WalletTransaction[];
66
+ utxos: string[];
67
+ }
68
+
69
+ export interface RecoverVaultDetails {
70
+ txid: string;
71
+ fee: number;
72
+ }
package/carbonado.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ export declare const store: (nostrHexSk: string, data: Uint8Array, force: boolean, name?: string, meta?: Uint8Array) => Promise<void>;
2
+ export declare const retrieve: (nostrHexSk: string, lookup: string) => Promise<Uint8Array>;
3
+ export declare const retrieveMetadata: (nostrHexSk: string, lookup: string) => Promise<FileMetadata>;
4
+ export declare const encodeHex: (bytes: Uint8Array) => string;
5
+ export declare const encodeBase64: (bytes: Uint8Array) => string;
6
+ export declare const decodeHex: (str: string) => Uint8Array;
7
+ export declare const decodeBase64: (str: string) => Uint8Array;
8
+ export interface FileMetadata {
9
+ filename: string;
10
+ metadata: Uint8Array;
11
+ }
12
+ //# sourceMappingURL=carbonado.d.ts.map
package/carbonado.js ADDED
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ // Methods meant to work with Carbonado storage defined within the web::carbonado module from bitmask-core:
3
+ // https://github.com/diba-io/bitmask-core/blob/development/src/web.rs
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || function (mod) {
21
+ if (mod && mod.__esModule) return mod;
22
+ var result = {};
23
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
+ __setModuleDefault(result, mod);
25
+ return result;
26
+ };
27
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
28
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
29
+ return new (P || (P = Promise))(function (resolve, reject) {
30
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
31
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
32
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
33
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
34
+ });
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.decodeBase64 = exports.decodeHex = exports.encodeBase64 = exports.encodeHex = exports.retrieveMetadata = exports.retrieve = exports.store = void 0;
38
+ const BMC = __importStar(require("./bitmask_core"));
39
+ const store = (nostrHexSk, data, force, name, meta) => __awaiter(void 0, void 0, void 0, function* () { return BMC.store(nostrHexSk, name || "", data, force, meta); });
40
+ exports.store = store;
41
+ const retrieve = (nostrHexSk, lookup) => BMC.retrieve(nostrHexSk, lookup);
42
+ exports.retrieve = retrieve;
43
+ const retrieveMetadata = (nostrHexSk, lookup) => BMC.retrieve_metadata(nostrHexSk, lookup);
44
+ exports.retrieveMetadata = retrieveMetadata;
45
+ const encodeHex = (bytes) => BMC.encode_hex(bytes);
46
+ exports.encodeHex = encodeHex;
47
+ const encodeBase64 = (bytes) => BMC.encode_base64(bytes);
48
+ exports.encodeBase64 = encodeBase64;
49
+ const decodeHex = (str) => BMC.decode_hex(str);
50
+ exports.decodeHex = decodeHex;
51
+ const decodeBase64 = (str) => BMC.decode_base64(str);
52
+ exports.decodeBase64 = decodeBase64;
package/carbonado.ts ADDED
@@ -0,0 +1,34 @@
1
+ // Methods meant to work with Carbonado storage defined within the web::carbonado module from bitmask-core:
2
+ // https://github.com/diba-io/bitmask-core/blob/development/src/web.rs
3
+
4
+ import * as BMC from "./bitmask_core";
5
+
6
+ export const store = async (
7
+ nostrHexSk: string,
8
+ data: Uint8Array,
9
+ force: boolean,
10
+ name?: string,
11
+ meta?: Uint8Array
12
+ ): Promise<void> => BMC.store(nostrHexSk, name || "", data, force, meta);
13
+
14
+ export const retrieve = (
15
+ nostrHexSk: string,
16
+ lookup: string
17
+ ): Promise<Uint8Array> => BMC.retrieve(nostrHexSk, lookup);
18
+
19
+ export const retrieveMetadata = (
20
+ nostrHexSk: string,
21
+ lookup: string
22
+ ): Promise<FileMetadata> => BMC.retrieve_metadata(nostrHexSk, lookup);
23
+
24
+ export const encodeHex = (bytes: Uint8Array): string => BMC.encode_hex(bytes);
25
+ export const encodeBase64 = (bytes: Uint8Array): string =>
26
+ BMC.encode_base64(bytes);
27
+
28
+ export const decodeHex = (str: string): Uint8Array => BMC.decode_hex(str);
29
+ export const decodeBase64 = (str: string): Uint8Array => BMC.decode_base64(str);
30
+
31
+ export interface FileMetadata {
32
+ filename: string;
33
+ metadata: Uint8Array;
34
+ }
package/constants.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ export declare const getNetwork: () => Promise<string>;
2
+ export declare const switchNetwork: (network: Network) => Promise<void>;
3
+ export declare const getEnv: (key: string) => Promise<string>;
4
+ export declare const setEnv: (key: string, value: string) => Promise<void>;
5
+ export declare enum Network {
6
+ bitcoin = "bitcoin",
7
+ testnet = "testnet",
8
+ signet = "signet",
9
+ regtest = "regtest"
10
+ }
11
+ export declare const DISABLE_LN: string | boolean;
12
+ export declare let LNDHUBX: boolean;
13
+ export declare let CARBONADO: boolean;
14
+ export declare let BITMASK: boolean;
15
+ export declare const init: (networkOverride?: string) => Promise<void>;
16
+ //# sourceMappingURL=constants.d.ts.map
package/constants.js ADDED
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ // Methods meant to work with bitmask-core constants defined within the web::constants module from bitmask-core:
3
+ // https://github.com/diba-io/bitmask-core/blob/development/src/web.rs
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || function (mod) {
21
+ if (mod && mod.__esModule) return mod;
22
+ var result = {};
23
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
+ __setModuleDefault(result, mod);
25
+ return result;
26
+ };
27
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
28
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
29
+ return new (P || (P = Promise))(function (resolve, reject) {
30
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
31
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
32
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
33
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
34
+ });
35
+ };
36
+ var _a;
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.init = exports.BITMASK = exports.CARBONADO = exports.LNDHUBX = exports.DISABLE_LN = exports.Network = exports.setEnv = exports.getEnv = exports.switchNetwork = exports.getNetwork = void 0;
39
+ const bitmask_core_1 = __importStar(require("./bitmask_core")), BMC = bitmask_core_1;
40
+ const getNetwork = () => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.get_network()); });
41
+ exports.getNetwork = getNetwork;
42
+ const switchNetwork = (network) => __awaiter(void 0, void 0, void 0, function* () { return BMC.switch_network(network.toString()); });
43
+ exports.switchNetwork = switchNetwork;
44
+ const getEnv = (key) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.get_env(key)); });
45
+ exports.getEnv = getEnv;
46
+ const setEnv = (key, value) => __awaiter(void 0, void 0, void 0, function* () { return BMC.set_env(key, value); });
47
+ exports.setEnv = setEnv;
48
+ var Network;
49
+ (function (Network) {
50
+ Network["bitcoin"] = "bitcoin";
51
+ Network["testnet"] = "testnet";
52
+ Network["signet"] = "signet";
53
+ Network["regtest"] = "regtest";
54
+ })(Network || (exports.Network = Network = {}));
55
+ exports.DISABLE_LN = ((_a = process.env) === null || _a === void 0 ? void 0 : _a.DISABLE_LN) === "true" ? true : false || "";
56
+ exports.LNDHUBX = false;
57
+ exports.CARBONADO = false;
58
+ exports.BITMASK = false;
59
+ const init = (networkOverride) => __awaiter(void 0, void 0, void 0, function* () {
60
+ try {
61
+ if (networkOverride) {
62
+ yield (0, exports.switchNetwork)(Network[networkOverride]);
63
+ }
64
+ yield (0, bitmask_core_1.default)();
65
+ const network = yield (0, exports.getNetwork)();
66
+ if (network === "bitcoin" && process.env.PROD_LNDHUB_ENDPOINT) {
67
+ yield (0, exports.setEnv)("LNDHUB_ENDPOINT", process.env.PROD_LNDHUB_ENDPOINT);
68
+ }
69
+ else if (process.env.TEST_LNDHUB_ENDPOINT) {
70
+ yield (0, exports.setEnv)("LNDHUB_ENDPOINT", process.env.TEST_LNDHUB_ENDPOINT);
71
+ }
72
+ if (process.env.CARBONADO_ENDPOINT) {
73
+ yield (0, exports.setEnv)("CARBONADO_ENDPOINT", process.env.CARBONADO_ENDPOINT);
74
+ }
75
+ if (process.env.BITMASK_ENDPOINT) {
76
+ yield (0, exports.setEnv)("BITMASK_ENDPOINT", process.env.BITMASK_ENDPOINT);
77
+ }
78
+ if (process.env.BITCOIN_EXPLORER_API_MAINNET) {
79
+ yield (0, exports.setEnv)("BITCOIN_EXPLORER_API_MAINNET", process.env.BITCOIN_EXPLORER_API_MAINNET);
80
+ }
81
+ if (process.env.BITCOIN_EXPLORER_API_TESTNET) {
82
+ yield (0, exports.setEnv)("BITCOIN_EXPLORER_API_TESTNET", process.env.BITCOIN_EXPLORER_API_TESTNET);
83
+ }
84
+ }
85
+ catch (err) {
86
+ console.error("Error in setEnv", err);
87
+ }
88
+ const lndhubx = yield (0, exports.getEnv)("LNDHUB_ENDPOINT");
89
+ const carbonado = yield (0, exports.getEnv)("CARBONADO_ENDPOINT");
90
+ const bitmask = yield (0, exports.getEnv)("BITMASK_ENDPOINT");
91
+ try {
92
+ if (!exports.DISABLE_LN) {
93
+ yield fetch(`${lndhubx}/nodeinfo`);
94
+ exports.LNDHUBX = true;
95
+ console.debug(`${lndhubx}/nodeinfo successfully reached`);
96
+ }
97
+ }
98
+ catch (e) {
99
+ exports.LNDHUBX = false;
100
+ console.warn("Could not reach lndhubx", lndhubx, e);
101
+ }
102
+ try {
103
+ yield fetch(`${carbonado}/status`);
104
+ exports.CARBONADO = true;
105
+ console.debug(`${carbonado}/status successfully reached`);
106
+ }
107
+ catch (e) {
108
+ exports.CARBONADO = false;
109
+ console.warn("Could not reach carbonado", carbonado, e);
110
+ }
111
+ try {
112
+ yield fetch(`${bitmask}/carbonado/status`);
113
+ exports.BITMASK = true;
114
+ console.debug(`${bitmask}/status successfully reached`);
115
+ }
116
+ catch (e) {
117
+ exports.BITMASK = false;
118
+ console.warn("Could not reach bitmask", bitmask, e);
119
+ }
120
+ console.debug(BMC.version(), "initialized");
121
+ console.debug("Using LNDHubX endpoint:", lndhubx);
122
+ console.debug("Using Carbonado endpoint:", carbonado);
123
+ console.debug("Using bitmaskd endpoint:", bitmask);
124
+ });
125
+ exports.init = init;
126
+ const networkOverride = process.env.NETWORK_OVERRIDE;
127
+ if (networkOverride) {
128
+ const network = Network[networkOverride.toLowerCase()];
129
+ (0, exports.init)(network);
130
+ }
131
+ else {
132
+ (0, exports.init)();
133
+ }
package/constants.ts ADDED
@@ -0,0 +1,112 @@
1
+ // Methods meant to work with bitmask-core constants defined within the web::constants module from bitmask-core:
2
+ // https://github.com/diba-io/bitmask-core/blob/development/src/web.rs
3
+
4
+ import initBMC, * as BMC from "./bitmask_core";
5
+
6
+ export const getNetwork = async (): Promise<string> =>
7
+ JSON.parse(await BMC.get_network());
8
+
9
+ export const switchNetwork = async (network: Network): Promise<void> =>
10
+ BMC.switch_network(network.toString());
11
+
12
+ export const getEnv = async (key: string): Promise<string> =>
13
+ JSON.parse(await BMC.get_env(key));
14
+
15
+ export const setEnv = async (key: string, value: string): Promise<void> =>
16
+ BMC.set_env(key, value);
17
+
18
+ export enum Network {
19
+ bitcoin = "bitcoin",
20
+ testnet = "testnet",
21
+ signet = "signet",
22
+ regtest = "regtest",
23
+ }
24
+ type NetworkType = typeof Network;
25
+ type NetworkKeyType = keyof NetworkType;
26
+
27
+ export const DISABLE_LN =
28
+ process.env?.DISABLE_LN === "true" ? true : false || "";
29
+ export let LNDHUBX = false;
30
+ export let CARBONADO = false;
31
+ export let BITMASK = false;
32
+
33
+ export const init = async (networkOverride?: string) => {
34
+ try {
35
+ if (networkOverride) {
36
+ await switchNetwork(Network[networkOverride as NetworkKeyType]);
37
+ }
38
+ await initBMC();
39
+
40
+ const network = await getNetwork();
41
+ if (network === "bitcoin" && process.env.PROD_LNDHUB_ENDPOINT) {
42
+ await setEnv("LNDHUB_ENDPOINT", process.env.PROD_LNDHUB_ENDPOINT);
43
+ } else if (process.env.TEST_LNDHUB_ENDPOINT) {
44
+ await setEnv("LNDHUB_ENDPOINT", process.env.TEST_LNDHUB_ENDPOINT);
45
+ }
46
+ if (process.env.CARBONADO_ENDPOINT) {
47
+ await setEnv("CARBONADO_ENDPOINT", process.env.CARBONADO_ENDPOINT);
48
+ }
49
+ if (process.env.BITMASK_ENDPOINT) {
50
+ await setEnv("BITMASK_ENDPOINT", process.env.BITMASK_ENDPOINT);
51
+ }
52
+ if (process.env.BITCOIN_EXPLORER_API_MAINNET) {
53
+ await setEnv(
54
+ "BITCOIN_EXPLORER_API_MAINNET",
55
+ process.env.BITCOIN_EXPLORER_API_MAINNET
56
+ );
57
+ }
58
+ if (process.env.BITCOIN_EXPLORER_API_TESTNET) {
59
+ await setEnv(
60
+ "BITCOIN_EXPLORER_API_TESTNET",
61
+ process.env.BITCOIN_EXPLORER_API_TESTNET
62
+ );
63
+ }
64
+ } catch (err) {
65
+ console.error("Error in setEnv", err);
66
+ }
67
+
68
+ const lndhubx = await getEnv("LNDHUB_ENDPOINT");
69
+ const carbonado = await getEnv("CARBONADO_ENDPOINT");
70
+ const bitmask = await getEnv("BITMASK_ENDPOINT");
71
+
72
+ try {
73
+ if (!DISABLE_LN) {
74
+ await fetch(`${lndhubx}/nodeinfo`);
75
+ LNDHUBX = true;
76
+ console.debug(`${lndhubx}/nodeinfo successfully reached`);
77
+ }
78
+ } catch (e) {
79
+ LNDHUBX = false;
80
+ console.warn("Could not reach lndhubx", lndhubx, e);
81
+ }
82
+ try {
83
+ await fetch(`${carbonado}/status`);
84
+ CARBONADO = true;
85
+ console.debug(`${carbonado}/status successfully reached`);
86
+ } catch (e) {
87
+ CARBONADO = false;
88
+ console.warn("Could not reach carbonado", carbonado, e);
89
+ }
90
+ try {
91
+ await fetch(`${bitmask}/carbonado/status`);
92
+ BITMASK = true;
93
+ console.debug(`${bitmask}/status successfully reached`);
94
+ } catch (e) {
95
+ BITMASK = false;
96
+ console.warn("Could not reach bitmask", bitmask, e);
97
+ }
98
+
99
+ console.debug(BMC.version(), "initialized");
100
+ console.debug("Using LNDHubX endpoint:", lndhubx);
101
+ console.debug("Using Carbonado endpoint:", carbonado);
102
+ console.debug("Using bitmaskd endpoint:", bitmask);
103
+ };
104
+
105
+ const networkOverride = process.env.NETWORK_OVERRIDE;
106
+
107
+ if (networkOverride) {
108
+ const network = Network[networkOverride.toLowerCase() as keyof typeof Network];
109
+ init(network);
110
+ } else {
111
+ init();
112
+ }
package/index.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ import * as BMC from "./bitmask_core";
2
+ export * from "./bitmask_core";
3
+ import * as bitcoin from "./bitcoin";
4
+ import * as carbonado from "./carbonado";
5
+ import * as constants from "./constants";
6
+ import * as lightning from "./lightning";
7
+ import * as nostr from "./nostr";
8
+ import * as rgb from "./rgb";
9
+ import * as wallet from "./wallet";
10
+ export * as bitcoin from "./bitcoin";
11
+ export * as carbonado from "./carbonado";
12
+ export * as constants from "./constants";
13
+ export * as lightning from "./lightning";
14
+ export * as nostr from "./nostr";
15
+ export * as rgb from "./rgb";
16
+ export * as wallet from "./wallet";
17
+ export * as bp from "./bp";
18
+ export type { WalletData } from "./bp";
19
+ declare const _default: {
20
+ BMC: typeof BMC;
21
+ bitcoin: typeof bitcoin;
22
+ carbonado: typeof carbonado;
23
+ constants: typeof constants;
24
+ lightning: typeof lightning;
25
+ nostr: typeof nostr;
26
+ rgb: typeof rgb;
27
+ wallet: typeof wallet;
28
+ };
29
+ export default _default;
30
+ //# sourceMappingURL=index.d.ts.map
package/index.js ADDED
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.bp = exports.wallet = exports.rgb = exports.nostr = exports.lightning = exports.constants = exports.carbonado = exports.bitcoin = void 0;
30
+ const BMC = __importStar(require("./bitmask_core"));
31
+ __exportStar(require("./bitmask_core"), exports); // kludge :c
32
+ const bitcoin = __importStar(require("./bitcoin"));
33
+ const carbonado = __importStar(require("./carbonado"));
34
+ const constants = __importStar(require("./constants"));
35
+ const lightning = __importStar(require("./lightning"));
36
+ const nostr = __importStar(require("./nostr"));
37
+ const rgb = __importStar(require("./rgb"));
38
+ const wallet = __importStar(require("./wallet"));
39
+ exports.bitcoin = __importStar(require("./bitcoin"));
40
+ exports.carbonado = __importStar(require("./carbonado"));
41
+ exports.constants = __importStar(require("./constants"));
42
+ exports.lightning = __importStar(require("./lightning"));
43
+ exports.nostr = __importStar(require("./nostr"));
44
+ exports.rgb = __importStar(require("./rgb"));
45
+ exports.wallet = __importStar(require("./wallet"));
46
+ exports.bp = __importStar(require("./bp"));
47
+ exports.default = {
48
+ BMC,
49
+ bitcoin,
50
+ carbonado,
51
+ constants,
52
+ lightning,
53
+ nostr,
54
+ rgb,
55
+ wallet,
56
+ };
package/index.ts ADDED
@@ -0,0 +1,33 @@
1
+ import * as BMC from "./bitmask_core";
2
+ export * from "./bitmask_core"; // kludge :c
3
+
4
+ import * as bitcoin from "./bitcoin";
5
+ import * as carbonado from "./carbonado";
6
+ import * as constants from "./constants";
7
+ import * as lightning from "./lightning";
8
+ import * as nostr from "./nostr";
9
+ import * as rgb from "./rgb";
10
+ import * as wallet from "./wallet";
11
+ import * as bp from "./bp";
12
+
13
+ export * as bitcoin from "./bitcoin";
14
+ export * as carbonado from "./carbonado";
15
+ export * as constants from "./constants";
16
+ export * as lightning from "./lightning";
17
+ export * as nostr from "./nostr";
18
+ export * as rgb from "./rgb";
19
+ export * as wallet from "./wallet";
20
+ export * as bp from "./bp";
21
+
22
+ export type { WalletData } from "./bp";
23
+
24
+ export default {
25
+ BMC,
26
+ bitcoin,
27
+ carbonado,
28
+ constants,
29
+ lightning,
30
+ nostr,
31
+ rgb,
32
+ wallet,
33
+ };
package/lightning.d.ts ADDED
@@ -0,0 +1,101 @@
1
+ export declare const createWallet: (username: string, password: string) => Promise<CreateWalletResponse>;
2
+ export declare const auth: (username: string, password: string) => Promise<AuthResponse>;
3
+ export declare const createInvoice: (description: string, amount: number, token: string) => Promise<AddInvoiceResponse>;
4
+ export declare const getBalance: (token: string) => Promise<Account>;
5
+ export declare const getTxs: (token: string) => Promise<LnTransaction[]>;
6
+ export declare const payInvoice: (paymentRequest: string, token: string) => Promise<PayInvoiceResponse>;
7
+ export declare const checkPayment: (paymentHash: string) => Promise<CheckPaymentResponse>;
8
+ export declare const swapBtcLn: (token: string) => Promise<SwapBtcLnResponse>;
9
+ export declare const swapLnBtc: (address: string, amount: bigint, token: string) => Promise<SwapLnBtcResponse>;
10
+ export interface LnCredentials {
11
+ login: string;
12
+ password: string;
13
+ refreshToken: string;
14
+ accessToken: string;
15
+ }
16
+ export interface CreateWalletResponse {
17
+ username?: string;
18
+ error?: string;
19
+ }
20
+ export type AuthResponse = ErrorResponse | AuthResponseOk;
21
+ export interface AuthResponseOk {
22
+ refresh: string;
23
+ token: string;
24
+ }
25
+ export interface ErrorResponse {
26
+ error: string;
27
+ }
28
+ export interface Account {
29
+ account_id: string;
30
+ balance: string;
31
+ currency: string;
32
+ }
33
+ export interface Money {
34
+ value: string;
35
+ currency: string;
36
+ }
37
+ export interface AddInvoiceResponse {
38
+ req_id: string;
39
+ uid: number;
40
+ payment_request: string;
41
+ meta: string;
42
+ metadata: string;
43
+ amount: Money;
44
+ rate: string;
45
+ currency: string;
46
+ target_account_currency: string;
47
+ account_id: string;
48
+ error: string;
49
+ fees: string;
50
+ }
51
+ export interface LnTransaction {
52
+ txid: string;
53
+ fee_txid: string;
54
+ outbound_txid: string;
55
+ inbound_txid: string;
56
+ created_at: bigint;
57
+ date: number;
58
+ outbound_amount: string;
59
+ inbound_amount: string;
60
+ outbound_account_id: string;
61
+ inbound_account_id: string;
62
+ outbound_uid: number;
63
+ inbound_uid: number;
64
+ outbound_currency: string;
65
+ inbound_currency: string;
66
+ exchange_rate: string;
67
+ tx_type: string;
68
+ fees: string;
69
+ reference: string;
70
+ }
71
+ export interface LnWalletData {
72
+ balance: Account;
73
+ transactions: LnTransaction[];
74
+ }
75
+ export interface PayInvoiceResponse {
76
+ payment_hash: string;
77
+ uid: number;
78
+ success: boolean;
79
+ currency: string;
80
+ payment_request: string;
81
+ amount: Money;
82
+ fees: Money;
83
+ error: string;
84
+ payment_preimage: string;
85
+ destination: string;
86
+ description: string;
87
+ }
88
+ export interface CheckPaymentResponse {
89
+ paid: boolean;
90
+ }
91
+ export interface SwapBtcLnResponse {
92
+ address: string;
93
+ commitment: string;
94
+ signature: string;
95
+ secret_access_key: string;
96
+ }
97
+ export interface SwapLnBtcResponse {
98
+ bolt11_invoice: string;
99
+ fee_sats: number;
100
+ }
101
+ //# sourceMappingURL=lightning.d.ts.map