bitmask-core 1.0.0-beta.9 → 1.0.1-beta

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.js CHANGED
@@ -17,13 +17,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
17
17
  }) : function(o, v) {
18
18
  o["default"] = v;
19
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
- };
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
27
37
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
28
38
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
29
39
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -34,16 +44,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
34
44
  });
35
45
  };
36
46
  Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.quoteSwapFeeSats = exports.guessSwapVbytes = exports.feeFromRate = exports.fetchFeeEstimates = exports.bumpFee = exports.drainWallet = exports.getAssetsVault = exports.fundVault = exports.sendSats = exports.getNewAddress = exports.getWalletData = exports.encryptWallet = exports.newWallet = exports.syncWallets = exports.upgradeWallet = exports.decryptWallet = exports.hashPassword = void 0;
47
+ exports.bumpFee = exports.drainWallet = exports.getAssetsVault = exports.fundVault = exports.sendSats = exports.getNewAddress = exports.getWalletData = exports.encryptWallet = exports.newWallet = exports.syncWallets = exports.upgradeWallet = exports.decryptWallet = exports.hashPassword = void 0;
48
+ exports.fetchFeeEstimates = fetchFeeEstimates;
49
+ exports.feeFromRate = feeFromRate;
50
+ exports.guessSwapVbytes = guessSwapVbytes;
51
+ exports.quoteSwapFeeSats = quoteSwapFeeSats;
38
52
  const BMC = __importStar(require("./bitmask_core"));
39
53
  const constants_1 = require("./constants");
40
- const hashPassword = (password) => BMC.hash_password(password);
54
+ const hashPassword = (password) => {
55
+ if (typeof BMC.hash_password !== 'function') {
56
+ throw new Error('WASM module not initialized: hash_password not available');
57
+ }
58
+ return BMC.hash_password(password);
59
+ };
41
60
  exports.hashPassword = hashPassword;
42
- const decryptWallet = (hash, encryptedDescriptors, seedPassword = "") => __awaiter(void 0, void 0, void 0, function* () {
61
+ const decryptWallet = (hash_1, encryptedDescriptors_1, ...args_1) => __awaiter(void 0, [hash_1, encryptedDescriptors_1, ...args_1], void 0, function* (hash, encryptedDescriptors, seedPassword = "") {
43
62
  return JSON.parse(yield BMC.decrypt_wallet(hash, encryptedDescriptors, seedPassword));
44
63
  });
45
64
  exports.decryptWallet = decryptWallet;
46
- const upgradeWallet = (hash, encryptedDescriptors, seedPassword = "") => __awaiter(void 0, void 0, void 0, function* () {
65
+ const upgradeWallet = (hash_1, encryptedDescriptors_1, ...args_1) => __awaiter(void 0, [hash_1, encryptedDescriptors_1, ...args_1], void 0, function* (hash, encryptedDescriptors, seedPassword = "") {
47
66
  return JSON.parse(yield BMC.upgrade_wallet(hash, encryptedDescriptors, seedPassword));
48
67
  });
49
68
  exports.upgradeWallet = upgradeWallet;
@@ -111,11 +130,9 @@ function fetchFeeEstimates() {
111
130
  return (yield resp.json());
112
131
  });
113
132
  }
114
- exports.fetchFeeEstimates = fetchFeeEstimates;
115
133
  function feeFromRate(vbytes, satPerVb) {
116
134
  return Math.ceil(vbytes * satPerVb);
117
135
  }
118
- exports.feeFromRate = feeFromRate;
119
136
  /**
120
137
  * Rough vbytes guesser for swap/bid PSBTs when you don't yet know exact inputs/outputs.
121
138
  * Prefer passing a conservative bound to avoid underpaying relays:
@@ -134,7 +151,6 @@ function guessSwapVbytes(inputs = 2, outputs = 3, taprootHeavy = true) {
134
151
  const est = inputs * perIn + outputs * perOut + overhead;
135
152
  return Math.max(est, 300);
136
153
  }
137
- exports.guessSwapVbytes = guessSwapVbytes;
138
154
  /**
139
155
  * Convenience: get a safe absolute fee quote for a swap given a target confirmation bucket.
140
156
  * - bucket can be "1","2","3","6","144", etc., matching Esplora keys.
@@ -142,8 +158,8 @@ exports.guessSwapVbytes = guessSwapVbytes;
142
158
  * - Adds a small 10% safety margin on the feerate to reduce min-relay rejections.
143
159
  */
144
160
  function quoteSwapFeeSats(bucket, vbytesEstimate) {
145
- var _a, _b;
146
161
  return __awaiter(this, void 0, void 0, function* () {
162
+ var _a, _b;
147
163
  const estimates = yield fetchFeeEstimates();
148
164
  const satPerVb = (_b = (_a = estimates[bucket]) !== null && _a !== void 0 ? _a : estimates["6"]) !== null && _b !== void 0 ? _b : 1.0;
149
165
  const paddedRate = Math.max(1.0, satPerVb * 1.1); // 10% headroom
@@ -151,4 +167,3 @@ function quoteSwapFeeSats(bucket, vbytesEstimate) {
151
167
  return { rate: paddedRate, fee };
152
168
  });
153
169
  }
154
- exports.quoteSwapFeeSats = quoteSwapFeeSats;
package/bitmask_core.d.ts CHANGED
@@ -1,12 +1,21 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function store(secret_key: string, name: string, data: Uint8Array, force: boolean, metadata?: Uint8Array | null): Promise<any>;
4
- export function retrieve(secret_key: string, name: string): Promise<any>;
5
- export function retrieve_metadata(secret_key: string, name: string): Promise<any>;
6
- export function encode_hex(bytes: Uint8Array): string;
7
- export function encode_base64(bytes: Uint8Array): string;
8
- export function decode_hex(string: string): Uint8Array;
9
- export function decode_base64(string: string): Uint8Array;
3
+ export function get_network(): Promise<any>;
4
+ export function switch_network(network_str: string): Promise<any>;
5
+ export function get_env(key: string): Promise<any>;
6
+ export function set_env(key: string, value: string): Promise<any>;
7
+ export function sleep(ms: number): Promise<any>;
8
+ export function create_wallet(username: string, password: string): Promise<any>;
9
+ export function auth(username: string, password: string): Promise<any>;
10
+ export function ln_create_invoice(description: string, amount: number, token: string): Promise<any>;
11
+ export function get_balance(token: string): Promise<any>;
12
+ export function get_txs(token: string): Promise<any>;
13
+ export function pay_invoice(payment_request: string, token: string): Promise<any>;
14
+ export function check_payment(payment_hash: string): Promise<any>;
15
+ export function swap_btc_ln(token: string, ln_address?: string | null): Promise<any>;
16
+ export function swap_ln_btc(address: string, amount: bigint, token: string): Promise<any>;
17
+ export function new_nostr_pubkey(pubkey: string, token: string): Promise<any>;
18
+ export function update_nostr_pubkey(pubkey: string, token: string): Promise<any>;
10
19
  export function get_rgb_version(): string;
11
20
  export function get_rgb_wallet(nostr_hex_sk: string): Promise<any>;
12
21
  export function get_contract(nostr_hex_sk: string, request: string): Promise<any>;
@@ -42,36 +51,13 @@ export function create_airdrop_claim(nostr_hex_sk: string, request: any): Promis
42
51
  export function close_airdrop(nostr_hex_sk: string, request: any): Promise<any>;
43
52
  export function backup_rgb_data(nostr_hex_sk: string): Promise<any>;
44
53
  export function restore_rgb_data(nostr_hex_sk: string): Promise<any>;
45
- export function create_watcher(nostr_hex_sk: string, request: any): Promise<any>;
46
- export function recover_watcher(nostr_hex_sk: string, request: any): Promise<any>;
47
- export function destroy_watcher(nostr_hex_sk: string): Promise<any>;
48
- export function destroy_recover_watcher(nostr_hex_sk: string): Promise<any>;
49
- export function check_watcher(nostr_hex_sk: string): Promise<any>;
50
- export function watcher_next_address(nostr_hex_sk: string, request: string): Promise<any>;
51
- export function watcher_next_utxo(nostr_hex_sk: string, request: string): Promise<any>;
52
- export function watcher_unspent_utxos(nostr_hex_sk: string, request: string): Promise<any>;
53
- export function get_network(): Promise<any>;
54
- export function switch_network(network_str: string): Promise<any>;
55
- export function get_env(key: string): Promise<any>;
56
- export function set_env(key: string, value: string): Promise<any>;
57
- export function sleep(ms: number): Promise<any>;
58
- export function create_wallet(username: string, password: string): Promise<any>;
59
- export function auth(username: string, password: string): Promise<any>;
60
- export function ln_create_invoice(description: string, amount: number, token: string): Promise<any>;
61
- export function get_balance(token: string): Promise<any>;
62
- export function get_txs(token: string): Promise<any>;
63
- export function pay_invoice(payment_request: string, token: string): Promise<any>;
64
- export function check_payment(payment_hash: string): Promise<any>;
65
- export function swap_btc_ln(token: string, ln_address?: string | null): Promise<any>;
66
- export function swap_ln_btc(address: string, amount: bigint, token: string): Promise<any>;
67
- export function fund_rgb_vault(sk: string, fee_rate: number, secrets: any, broadcast: boolean, fund_value: bigint | null | undefined, coordinator_fee: boolean): Promise<any>;
68
- export function transfer_sats(sk: string, address: string, sats: bigint, fee_rate: number, secrets: any): Promise<any>;
69
- export function get_btc_wallet(sk: string): Promise<any>;
70
- export function backup_btc_data(nostr_hex_sk: string): Promise<any>;
71
- export function recover_funds_from_bad_wallets(seed: string, pass_phrase: string, recover_address: string): Promise<any>;
72
- export function restore_btc_data(nostr_hex_sk: string): Promise<any>;
73
- export function new_nostr_pubkey(pubkey: string, token: string): Promise<any>;
74
- export function update_nostr_pubkey(pubkey: string, token: string): Promise<any>;
54
+ export function store(secret_key: string, name: string, data: Uint8Array, force: boolean, metadata?: Uint8Array | null): Promise<any>;
55
+ export function retrieve(secret_key: string, name: string): Promise<any>;
56
+ export function retrieve_metadata(secret_key: string, name: string): Promise<any>;
57
+ export function encode_hex(bytes: Uint8Array): string;
58
+ export function encode_base64(bytes: Uint8Array): string;
59
+ export function decode_hex(string: string): Uint8Array;
60
+ export function decode_base64(string: string): Uint8Array;
75
61
  export function hash_password(password: string): string;
76
62
  export function new_mnemonic(password: string): Promise<any>;
77
63
  export function save_mnemonic(seed: string, password: string): Promise<any>;
@@ -89,23 +75,46 @@ export function drain_wallet(destination: string, descriptor: string, change_des
89
75
  export function bump_fee(txid: string, fee_rate: number, descriptor: string, change_descriptor: string | null | undefined, broadcast: boolean): Promise<any>;
90
76
  export function psbt_sign_and_publish_file(request: any): Promise<any>;
91
77
  export function psbt_publish_file(request: any): Promise<any>;
78
+ export function fund_rgb_vault(sk: string, fee_rate: number, secrets: any, broadcast: boolean, fund_value: bigint | null | undefined, coordinator_fee: boolean): Promise<any>;
79
+ export function transfer_sats(sk: string, address: string, sats: bigint, fee_rate: number, secrets: any): Promise<any>;
80
+ export function get_btc_wallet(sk: string): Promise<any>;
81
+ export function backup_btc_data(nostr_hex_sk: string): Promise<any>;
82
+ export function recover_funds_from_bad_wallets(seed: string, pass_phrase: string, recover_address: string): Promise<any>;
83
+ export function restore_btc_data(nostr_hex_sk: string): Promise<any>;
92
84
  export function convert_contract_amount_raw(decimal: string, precision: number): string;
93
85
  export function convert_contract_amount_string(amount: bigint, precision: number): string;
94
86
  export function parse_contract_amount(amount: string): any;
95
87
  export function parse_contract_amount_precision(amount: string, precision: number): string;
96
88
  export function version(): any;
89
+ export function create_watcher(nostr_hex_sk: string, request: any): Promise<any>;
90
+ export function recover_watcher(nostr_hex_sk: string, request: any): Promise<any>;
91
+ export function destroy_watcher(nostr_hex_sk: string): Promise<any>;
92
+ export function destroy_recover_watcher(nostr_hex_sk: string): Promise<any>;
93
+ export function check_watcher(nostr_hex_sk: string): Promise<any>;
94
+ export function watcher_next_address(nostr_hex_sk: string, request: string): Promise<any>;
95
+ export function watcher_next_utxo(nostr_hex_sk: string, request: string): Promise<any>;
96
+ export function watcher_unspent_utxos(nostr_hex_sk: string, request: string): Promise<any>;
97
97
 
98
98
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
99
99
 
100
100
  export interface InitOutput {
101
101
  readonly memory: WebAssembly.Memory;
102
- readonly store: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => any;
103
- readonly retrieve: (a: number, b: number, c: number, d: number) => any;
104
- readonly retrieve_metadata: (a: number, b: number, c: number, d: number) => any;
105
- readonly encode_hex: (a: number, b: number) => [number, number];
106
- readonly encode_base64: (a: number, b: number) => [number, number];
107
- readonly decode_hex: (a: number, b: number) => [number, number, number, number];
108
- readonly decode_base64: (a: number, b: number) => [number, number, number, number];
102
+ readonly get_network: () => any;
103
+ readonly switch_network: (a: number, b: number) => any;
104
+ readonly get_env: (a: number, b: number) => any;
105
+ readonly set_env: (a: number, b: number, c: number, d: number) => any;
106
+ readonly sleep: (a: number) => any;
107
+ readonly create_wallet: (a: number, b: number, c: number, d: number) => any;
108
+ readonly auth: (a: number, b: number, c: number, d: number) => any;
109
+ readonly ln_create_invoice: (a: number, b: number, c: number, d: number, e: number) => any;
110
+ readonly get_balance: (a: number, b: number) => any;
111
+ readonly get_txs: (a: number, b: number) => any;
112
+ readonly pay_invoice: (a: number, b: number, c: number, d: number) => any;
113
+ readonly check_payment: (a: number, b: number) => any;
114
+ readonly swap_btc_ln: (a: number, b: number, c: number, d: number) => any;
115
+ readonly swap_ln_btc: (a: number, b: number, c: bigint, d: number, e: number) => any;
116
+ readonly new_nostr_pubkey: (a: number, b: number, c: number, d: number) => any;
117
+ readonly update_nostr_pubkey: (a: number, b: number, c: number, d: number) => any;
109
118
  readonly get_rgb_version: () => [number, number];
110
119
  readonly get_rgb_wallet: (a: number, b: number) => any;
111
120
  readonly get_contract: (a: number, b: number, c: number, d: number) => any;
@@ -141,36 +150,13 @@ export interface InitOutput {
141
150
  readonly close_airdrop: (a: number, b: number, c: any) => any;
142
151
  readonly backup_rgb_data: (a: number, b: number) => any;
143
152
  readonly restore_rgb_data: (a: number, b: number) => any;
144
- readonly create_watcher: (a: number, b: number, c: any) => any;
145
- readonly recover_watcher: (a: number, b: number, c: any) => any;
146
- readonly destroy_watcher: (a: number, b: number) => any;
147
- readonly destroy_recover_watcher: (a: number, b: number) => any;
148
- readonly check_watcher: (a: number, b: number) => any;
149
- readonly watcher_next_address: (a: number, b: number, c: number, d: number) => any;
150
- readonly watcher_next_utxo: (a: number, b: number, c: number, d: number) => any;
151
- readonly watcher_unspent_utxos: (a: number, b: number, c: number, d: number) => any;
152
- readonly get_network: () => any;
153
- readonly switch_network: (a: number, b: number) => any;
154
- readonly get_env: (a: number, b: number) => any;
155
- readonly set_env: (a: number, b: number, c: number, d: number) => any;
156
- readonly sleep: (a: number) => any;
157
- readonly create_wallet: (a: number, b: number, c: number, d: number) => any;
158
- readonly auth: (a: number, b: number, c: number, d: number) => any;
159
- readonly ln_create_invoice: (a: number, b: number, c: number, d: number, e: number) => any;
160
- readonly get_balance: (a: number, b: number) => any;
161
- readonly get_txs: (a: number, b: number) => any;
162
- readonly pay_invoice: (a: number, b: number, c: number, d: number) => any;
163
- readonly check_payment: (a: number, b: number) => any;
164
- readonly swap_btc_ln: (a: number, b: number, c: number, d: number) => any;
165
- readonly swap_ln_btc: (a: number, b: number, c: bigint, d: number, e: number) => any;
166
- readonly fund_rgb_vault: (a: number, b: number, c: number, d: any, e: number, f: number, g: bigint, h: number) => any;
167
- readonly transfer_sats: (a: number, b: number, c: number, d: number, e: bigint, f: number, g: any) => any;
168
- readonly get_btc_wallet: (a: number, b: number) => any;
169
- readonly backup_btc_data: (a: number, b: number) => any;
170
- readonly recover_funds_from_bad_wallets: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
171
- readonly restore_btc_data: (a: number, b: number) => any;
172
- readonly new_nostr_pubkey: (a: number, b: number, c: number, d: number) => any;
173
- readonly update_nostr_pubkey: (a: number, b: number, c: number, d: number) => any;
153
+ readonly store: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => any;
154
+ readonly retrieve: (a: number, b: number, c: number, d: number) => any;
155
+ readonly retrieve_metadata: (a: number, b: number, c: number, d: number) => any;
156
+ readonly encode_hex: (a: number, b: number) => [number, number];
157
+ readonly encode_base64: (a: number, b: number) => [number, number];
158
+ readonly decode_hex: (a: number, b: number) => [number, number, number, number];
159
+ readonly decode_base64: (a: number, b: number) => [number, number, number, number];
174
160
  readonly hash_password: (a: number, b: number) => [number, number];
175
161
  readonly new_mnemonic: (a: number, b: number) => any;
176
162
  readonly save_mnemonic: (a: number, b: number, c: number, d: number) => any;
@@ -188,11 +174,25 @@ export interface InitOutput {
188
174
  readonly bump_fee: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => any;
189
175
  readonly psbt_sign_and_publish_file: (a: any) => any;
190
176
  readonly psbt_publish_file: (a: any) => any;
177
+ readonly fund_rgb_vault: (a: number, b: number, c: number, d: any, e: number, f: number, g: bigint, h: number) => any;
178
+ readonly transfer_sats: (a: number, b: number, c: number, d: number, e: bigint, f: number, g: any) => any;
179
+ readonly get_btc_wallet: (a: number, b: number) => any;
180
+ readonly backup_btc_data: (a: number, b: number) => any;
181
+ readonly recover_funds_from_bad_wallets: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
182
+ readonly restore_btc_data: (a: number, b: number) => any;
191
183
  readonly convert_contract_amount_raw: (a: number, b: number, c: number) => [number, number];
192
184
  readonly convert_contract_amount_string: (a: bigint, b: number) => [number, number];
193
185
  readonly parse_contract_amount: (a: number, b: number) => any;
194
186
  readonly parse_contract_amount_precision: (a: number, b: number, c: number) => [number, number];
195
187
  readonly version: () => any;
188
+ readonly create_watcher: (a: number, b: number, c: any) => any;
189
+ readonly recover_watcher: (a: number, b: number, c: any) => any;
190
+ readonly destroy_watcher: (a: number, b: number) => any;
191
+ readonly destroy_recover_watcher: (a: number, b: number) => any;
192
+ readonly check_watcher: (a: number, b: number) => any;
193
+ readonly watcher_next_address: (a: number, b: number, c: number, d: number) => any;
194
+ readonly watcher_next_utxo: (a: number, b: number, c: number, d: number) => any;
195
+ readonly watcher_unspent_utxos: (a: number, b: number, c: number, d: number) => any;
196
196
  readonly rustsecp256k1_v0_9_2_context_create: (a: number) => number;
197
197
  readonly rustsecp256k1_v0_9_2_context_destroy: (a: number) => void;
198
198
  readonly rustsecp256k1_v0_9_2_default_illegal_callback_fn: (a: number, b: number) => void;
@@ -218,11 +218,11 @@ export interface InitOutput {
218
218
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
219
219
  readonly __wbindgen_export_7: WebAssembly.Table;
220
220
  readonly __externref_table_dealloc: (a: number) => void;
221
- readonly closure1486_externref_shim: (a: number, b: number, c: any) => void;
222
- readonly closure1989_externref_shim: (a: number, b: number, c: any) => void;
223
- readonly closure2664_externref_shim: (a: number, b: number, c: any) => void;
224
- readonly closure3837_externref_shim: (a: number, b: number, c: any) => void;
225
- readonly closure4132_externref_shim: (a: number, b: number, c: any, d: any) => void;
221
+ readonly closure1237_externref_shim: (a: number, b: number, c: any) => void;
222
+ readonly closure1999_externref_shim: (a: number, b: number, c: any) => void;
223
+ readonly closure2670_externref_shim: (a: number, b: number, c: any) => void;
224
+ readonly closure3841_externref_shim: (a: number, b: number, c: any) => void;
225
+ readonly closure4133_externref_shim: (a: number, b: number, c: any, d: any) => void;
226
226
  readonly __wbindgen_start: () => void;
227
227
  }
228
228