@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/bitcoin.d.ts +140 -0
- package/bitcoin.js +154 -0
- package/bitcoin.ts +317 -0
- package/bp.d.ts +28 -0
- package/bp.js +51 -0
- package/bp.ts +72 -0
- package/carbonado.d.ts +12 -0
- package/carbonado.js +52 -0
- package/carbonado.ts +34 -0
- package/constants.d.ts +16 -0
- package/constants.js +133 -0
- package/constants.ts +112 -0
- package/index.d.ts +30 -0
- package/index.js +56 -0
- package/index.ts +33 -0
- package/lightning.d.ts +101 -0
- package/lightning.js +56 -0
- package/lightning.ts +165 -0
- package/nostr.d.ts +6 -0
- package/nostr.js +42 -0
- package/nostr.ts +19 -0
- package/package.json +31 -4
- package/rgb.d.ts +363 -0
- package/rgb.js +120 -0
- package/rgb.ts +710 -0
- package/wallet.d.ts +9 -0
- package/wallet.js +51 -0
- package/wallet.ts +46 -0
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibearua/bitmask-core-dev",
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
"collaborators": [
|
|
5
5
|
"DIBA Team <team@diba.io>",
|
|
6
6
|
"Jose Diego Robles <jose@diba.io>",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"Stanley Arua <stanarua@aol.com>"
|
|
11
11
|
],
|
|
12
12
|
"description": "Core functionality for the BitMask wallet",
|
|
13
|
-
"version": "1.0.0-beta.
|
|
13
|
+
"version": "1.0.0-beta.13",
|
|
14
14
|
"license": "MIT/Apache-2.0",
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
@@ -20,12 +20,39 @@
|
|
|
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
|
],
|
|
26
|
-
"main": "
|
|
53
|
+
"main": "index.js",
|
|
27
54
|
"homepage": "https://bitmask.app",
|
|
28
|
-
"types": "
|
|
55
|
+
"types": "index.d.ts",
|
|
29
56
|
"sideEffects": [
|
|
30
57
|
"./snippets/*"
|
|
31
58
|
]
|