@ibearua/bitmask-core-dev 1.0.0-beta.10 → 1.0.0-beta.12

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/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
package/lightning.js ADDED
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ // Methods meant to work with LNDHubX defined within the web::lightning 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.swapLnBtc = exports.swapBtcLn = exports.checkPayment = exports.payInvoice = exports.getTxs = exports.getBalance = exports.createInvoice = exports.auth = exports.createWallet = void 0;
38
+ const BMC = __importStar(require("./bitmask_core"));
39
+ const createWallet = (username, password) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.create_wallet(username, password)); });
40
+ exports.createWallet = createWallet;
41
+ const auth = (username, password) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.auth(username, password)); });
42
+ exports.auth = auth;
43
+ const createInvoice = (description, amount, token) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.ln_create_invoice(description, amount, token)); });
44
+ exports.createInvoice = createInvoice;
45
+ const getBalance = (token) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.get_balance(token)); });
46
+ exports.getBalance = getBalance;
47
+ const getTxs = (token) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.get_txs(token)); });
48
+ exports.getTxs = getTxs;
49
+ const payInvoice = (paymentRequest, token) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.pay_invoice(paymentRequest, token)); });
50
+ exports.payInvoice = payInvoice;
51
+ const checkPayment = (paymentHash) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.check_payment(paymentHash)); });
52
+ exports.checkPayment = checkPayment;
53
+ const swapBtcLn = (token) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.swap_btc_ln(token)); });
54
+ exports.swapBtcLn = swapBtcLn;
55
+ const swapLnBtc = (address, amount, token) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.swap_ln_btc(address, amount, token)); });
56
+ exports.swapLnBtc = swapLnBtc;
package/lightning.ts ADDED
@@ -0,0 +1,165 @@
1
+ // Methods meant to work with LNDHubX defined within the web::lightning 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 createWallet = async (
7
+ username: string,
8
+ password: string
9
+ ): Promise<CreateWalletResponse> =>
10
+ JSON.parse(await BMC.create_wallet(username, password));
11
+
12
+ export const auth = async (
13
+ username: string,
14
+ password: string
15
+ ): Promise<AuthResponse> => JSON.parse(await BMC.auth(username, password));
16
+
17
+ export const createInvoice = async (
18
+ description: string,
19
+ amount: number,
20
+ token: string
21
+ ): Promise<AddInvoiceResponse> =>
22
+ JSON.parse(await BMC.ln_create_invoice(description, amount, token));
23
+
24
+ export const getBalance = async (token: string): Promise<Account> =>
25
+ JSON.parse(await BMC.get_balance(token));
26
+
27
+ export const getTxs = async (token: string): Promise<LnTransaction[]> =>
28
+ JSON.parse(await BMC.get_txs(token));
29
+
30
+ export const payInvoice = async (
31
+ paymentRequest: string,
32
+ token: string
33
+ ): Promise<PayInvoiceResponse> =>
34
+ JSON.parse(await BMC.pay_invoice(paymentRequest, token));
35
+
36
+ export const checkPayment = async (
37
+ paymentHash: string
38
+ ): Promise<CheckPaymentResponse> =>
39
+ JSON.parse(await BMC.check_payment(paymentHash));
40
+
41
+ export const swapBtcLn = async (token: string): Promise<SwapBtcLnResponse> =>
42
+ JSON.parse(await BMC.swap_btc_ln(token));
43
+
44
+ export const swapLnBtc = async (
45
+ address: string,
46
+ amount: bigint,
47
+ token: string
48
+ ): Promise<SwapLnBtcResponse> =>
49
+ JSON.parse(await BMC.swap_ln_btc(address, amount, token));
50
+
51
+ // Core type interfaces based on structs defined within the bitmask-core Rust crate:
52
+ // https://github.com/diba-io/bitmask-core/blob/development/src/structs.rs
53
+
54
+ export interface LnCredentials {
55
+ login: string;
56
+ password: string;
57
+ refreshToken: string;
58
+ accessToken: string;
59
+ }
60
+
61
+ // Lndhubx Create wallet endpoint response
62
+ export interface CreateWalletResponse {
63
+ username?: string;
64
+ error?: string;
65
+ }
66
+
67
+ // lndhubx Auth response
68
+ export type AuthResponse = ErrorResponse | AuthResponseOk;
69
+
70
+ export interface AuthResponseOk {
71
+ refresh: string;
72
+ token: string;
73
+ }
74
+
75
+ export interface ErrorResponse {
76
+ error: string;
77
+ }
78
+
79
+ // User Account
80
+ export interface Account {
81
+ account_id: string;
82
+ balance: string;
83
+ currency: string;
84
+ }
85
+
86
+ // Amount and currency
87
+ export interface Money {
88
+ value: string;
89
+ currency: string;
90
+ }
91
+
92
+ // Lndhubx Add invoice endpoint response
93
+ export interface AddInvoiceResponse {
94
+ req_id: string;
95
+ uid: number;
96
+ payment_request: string;
97
+ meta: string;
98
+ metadata: string;
99
+ amount: Money;
100
+ rate: string;
101
+ currency: string;
102
+ target_account_currency: string;
103
+ account_id: string;
104
+ error: string;
105
+ fees: string;
106
+ }
107
+
108
+ // Lndhubx lightning transaction
109
+ export interface LnTransaction {
110
+ txid: string;
111
+ fee_txid: string;
112
+ outbound_txid: string;
113
+ inbound_txid: string;
114
+ created_at: bigint;
115
+ date: number;
116
+ outbound_amount: string;
117
+ inbound_amount: string;
118
+ outbound_account_id: string;
119
+ inbound_account_id: string;
120
+ outbound_uid: number;
121
+ inbound_uid: number;
122
+ outbound_currency: string;
123
+ inbound_currency: string;
124
+ exchange_rate: string;
125
+ tx_type: string;
126
+ fees: string;
127
+ reference: string;
128
+ }
129
+
130
+ export interface LnWalletData {
131
+ balance: Account;
132
+ transactions: LnTransaction[];
133
+ }
134
+
135
+ // Lndhubx Pay invoice response
136
+ export interface PayInvoiceResponse {
137
+ payment_hash: string;
138
+ uid: number;
139
+ success: boolean;
140
+ currency: string;
141
+ payment_request: string;
142
+ amount: Money;
143
+ fees: Money;
144
+ error: string;
145
+ payment_preimage: string;
146
+ destination: string;
147
+ description: string;
148
+ }
149
+
150
+ // Lndhubx Check payment response
151
+ export interface CheckPaymentResponse {
152
+ paid: boolean;
153
+ }
154
+
155
+ export interface SwapBtcLnResponse {
156
+ address: string;
157
+ commitment: string;
158
+ signature: string;
159
+ secret_access_key: string;
160
+ }
161
+
162
+ export interface SwapLnBtcResponse {
163
+ bolt11_invoice: string;
164
+ fee_sats: number;
165
+ }
package/nostr.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export interface Response {
2
+ status: string;
3
+ }
4
+ export declare const newNostrPubkey: (pubkey: string, token: string) => Promise<Response>;
5
+ export declare const updateNostrPubkey: (pubkey: string, token: string) => Promise<Response>;
6
+ //# sourceMappingURL=nostr.d.ts.map
package/nostr.js ADDED
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ // Methods meant to work with LNDHubX defined within the web::nostr 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.updateNostrPubkey = exports.newNostrPubkey = void 0;
38
+ const BMC = __importStar(require("./bitmask_core"));
39
+ const newNostrPubkey = (pubkey, token) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.new_nostr_pubkey(pubkey, token)); });
40
+ exports.newNostrPubkey = newNostrPubkey;
41
+ const updateNostrPubkey = (pubkey, token) => __awaiter(void 0, void 0, void 0, function* () { return JSON.parse(yield BMC.update_nostr_pubkey(pubkey, token)); });
42
+ exports.updateNostrPubkey = updateNostrPubkey;
package/nostr.ts ADDED
@@ -0,0 +1,19 @@
1
+ // Methods meant to work with LNDHubX defined within the web::nostr 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 interface Response {
7
+ status: string;
8
+ }
9
+
10
+ export const newNostrPubkey = async (
11
+ pubkey: string,
12
+ token: string
13
+ ): Promise<Response> => JSON.parse(await BMC.new_nostr_pubkey(pubkey, token));
14
+
15
+ export const updateNostrPubkey = async (
16
+ pubkey: string,
17
+ token: string
18
+ ): Promise<Response> =>
19
+ JSON.parse(await BMC.update_nostr_pubkey(pubkey, token));
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  "Trevor O'Farrell <trevor@diba.io>",
10
10
  "Stanley Arua <stanarua@aol.com>"
11
11
  ],
12
- "description": "Core functionality for the BitMask wallet -Dev",
13
- "version": "1.0.0-beta.10",
12
+ "description": "Core functionality for the BitMask wallet",
13
+ "version": "1.0.0-beta.12",
14
14
  "license": "MIT/Apache-2.0",
15
15
  "repository": {
16
16
  "type": "git",
@@ -20,6 +20,33 @@
20
20
  "bitmask_core_bg.wasm",
21
21
  "bitmask_core.js",
22
22
  "bitmask_core.d.ts",
23
+ "bitcoin.d.ts",
24
+ "bitcoin.js",
25
+ "bitcoin.ts",
26
+ "bp.d.ts",
27
+ "bp.js",
28
+ "bp.ts",
29
+ "carbonado.d.ts",
30
+ "carbonado.js",
31
+ "carbonado.ts",
32
+ "constants.d.ts",
33
+ "constants.js",
34
+ "constants.ts",
35
+ "index.d.ts",
36
+ "index.js",
37
+ "index.ts",
38
+ "lightning.d.ts",
39
+ "lightning.js",
40
+ "lightning.ts",
41
+ "nostr.d.ts",
42
+ "nostr.js",
43
+ "nostr.ts",
44
+ "rgb.d.ts",
45
+ "rgb.js",
46
+ "rgb.ts",
47
+ "wallet.d.ts",
48
+ "wallet.js",
49
+ "wallet.ts",
23
50
  "LICENSE-MIT",
24
51
  "LICENSE-APACHE"
25
52
  ],