bitmask-core 0.4.0 → 0.4.2

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/README.md CHANGED
@@ -4,12 +4,10 @@ Core functionality for the BitMask wallet - <https://bitmask.app>
4
4
  **BitMask** is a bitcoin wallet and a browser extension for accessing decentralized web applications on the Bitcoin blokchain. It is designed to support UTXO based smart contracting protocols such as RGB, with planned support for Omni layer, TARO and many others.
5
5
 
6
6
 
7
- [![Build Status](https://img.shields.io/github/workflow/status/diba-io/bitmask-core/Rust?style=flat-square)](https://github.com/diba-io/bitmask-core/actions/workflows/Rust.yml)
8
7
  [![Crates.io](https://img.shields.io/crates/v/bitmask-core?style=flat-square)](https://docs.rs/bitmask-core/latest/bitmask-core/)
9
8
  [![npm: bitmask-core](https://img.shields.io/npm/v/bitmask-core?style=flat-square)](https://www.npmjs.com/package/bitmask-core)
10
9
  [![License: MIT+APACHE](https://img.shields.io/crates/l/bitmask-core?style=flat-square)](https://mit-license.org)
11
- ![Lines of code](https://img.shields.io/tokei/lines/github/diba-io/bitmask-core?style=flat-square)
12
- [![Telegram: rust_in_bitcoin](https://img.shields.io/badge/telegram-rust_in_bitcoin-blue?style=flat-square)](https://t.me/rust_in_bitcoin)
10
+ [![Telegram](https://img.shields.io/badge/telegram-invite-blue?style=flat-square)](https://t.me/+eQk5aQ5--iUxYzVk)
13
11
 
14
12
  ## Uses
15
13
 
package/bitmask_core.d.ts CHANGED
@@ -85,9 +85,11 @@ export function create_asset(ticker: string, name: string, precision: number, su
85
85
  export function send_assets(btc_descriptor_xprv: string, btc_change_descriptor_xprv: string, rgb_assets_descriptor_xprv: string, rgb_assets_descriptor_xpub: string, blinded_utxo: string, amount: bigint, asset_contract: string, fee_rate: number): Promise<any>;
86
86
  /**
87
87
  * @param {string} consignment
88
+ * @param {string} blinding_factor
89
+ * @param {string} outpoint
88
90
  * @returns {Promise<any>}
89
91
  */
90
- export function accept_transfer(consignment: string): Promise<any>;
92
+ export function accept_transfer(consignment: string, blinding_factor: string, outpoint: string): Promise<any>;
91
93
  /**
92
94
  * @returns {Promise<any>}
93
95
  */
@@ -107,3 +109,38 @@ export function get_endpoint(path: string): Promise<any>;
107
109
  * @returns {Promise<any>}
108
110
  */
109
111
  export function switch_host(host: string): Promise<any>;
112
+ /**
113
+ * @param {string} username
114
+ * @param {string} password
115
+ * @returns {Promise<any>}
116
+ */
117
+ export function ln_create_wallet(username: string, password: string): Promise<any>;
118
+ /**
119
+ * @param {string} username
120
+ * @param {string} password
121
+ * @returns {Promise<any>}
122
+ */
123
+ export function ln_auth(username: string, password: string): Promise<any>;
124
+ /**
125
+ * @param {string} description
126
+ * @param {number} amount
127
+ * @param {string} token
128
+ * @returns {Promise<any>}
129
+ */
130
+ export function ln_create_invoice(description: string, amount: number, token: string): Promise<any>;
131
+ /**
132
+ * @param {string} token
133
+ * @returns {Promise<any>}
134
+ */
135
+ export function ln_get_balance(token: string): Promise<any>;
136
+ /**
137
+ * @param {string} token
138
+ * @returns {Promise<any>}
139
+ */
140
+ export function ln_get_txs(token: string): Promise<any>;
141
+ /**
142
+ * @param {string} payment_request
143
+ * @param {string} token
144
+ * @returns {Promise<any>}
145
+ */
146
+ export function ln_pay_invoice(payment_request: string, token: string): Promise<any>;
@@ -1,25 +1,5 @@
1
1
  import * as wasm from './bitmask_core_bg.wasm';
2
2
 
3
- const heap = new Array(32).fill(undefined);
4
-
5
- heap.push(undefined, null, true, false);
6
-
7
- function getObject(idx) { return heap[idx]; }
8
-
9
- let heap_next = heap.length;
10
-
11
- function dropObject(idx) {
12
- if (idx < 36) return;
13
- heap[idx] = heap_next;
14
- heap_next = idx;
15
- }
16
-
17
- function takeObject(idx) {
18
- const ret = getObject(idx);
19
- dropObject(idx);
20
- return ret;
21
- }
22
-
23
3
  const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
24
4
 
25
5
  let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
@@ -39,6 +19,12 @@ function getStringFromWasm0(ptr, len) {
39
19
  return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
40
20
  }
41
21
 
22
+ const heap = new Array(32).fill(undefined);
23
+
24
+ heap.push(undefined, null, true, false);
25
+
26
+ let heap_next = heap.length;
27
+
42
28
  function addHeapObject(obj) {
43
29
  if (heap_next === heap.length) heap.push(heap.length + 1);
44
30
  const idx = heap_next;
@@ -48,6 +34,20 @@ function addHeapObject(obj) {
48
34
  return idx;
49
35
  }
50
36
 
37
+ function getObject(idx) { return heap[idx]; }
38
+
39
+ function dropObject(idx) {
40
+ if (idx < 36) return;
41
+ heap[idx] = heap_next;
42
+ heap_next = idx;
43
+ }
44
+
45
+ function takeObject(idx) {
46
+ const ret = getObject(idx);
47
+ dropObject(idx);
48
+ return ret;
49
+ }
50
+
51
51
  let WASM_VECTOR_LEN = 0;
52
52
 
53
53
  const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
@@ -208,7 +208,7 @@ function makeMutClosure(arg0, arg1, dtor, f) {
208
208
  return real;
209
209
  }
210
210
  function __wbg_adapter_28(arg0, arg1, arg2) {
211
- wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__ha170fae5fa67bd5e(arg0, arg1, addHeapObject(arg2));
211
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3796fc407ba133cc(arg0, arg1, addHeapObject(arg2));
212
212
  }
213
213
 
214
214
  /**
@@ -400,12 +400,18 @@ export function send_assets(btc_descriptor_xprv, btc_change_descriptor_xprv, rgb
400
400
 
401
401
  /**
402
402
  * @param {string} consignment
403
+ * @param {string} blinding_factor
404
+ * @param {string} outpoint
403
405
  * @returns {Promise<any>}
404
406
  */
405
- export function accept_transfer(consignment) {
407
+ export function accept_transfer(consignment, blinding_factor, outpoint) {
406
408
  const ptr0 = passStringToWasm0(consignment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
407
409
  const len0 = WASM_VECTOR_LEN;
408
- const ret = wasm.accept_transfer(ptr0, len0);
410
+ const ptr1 = passStringToWasm0(blinding_factor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
411
+ const len1 = WASM_VECTOR_LEN;
412
+ const ptr2 = passStringToWasm0(outpoint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
413
+ const len2 = WASM_VECTOR_LEN;
414
+ const ret = wasm.accept_transfer(ptr0, len0, ptr1, len1, ptr2, len2);
409
415
  return takeObject(ret);
410
416
  }
411
417
 
@@ -450,6 +456,85 @@ export function switch_host(host) {
450
456
  return takeObject(ret);
451
457
  }
452
458
 
459
+ /**
460
+ * @param {string} username
461
+ * @param {string} password
462
+ * @returns {Promise<any>}
463
+ */
464
+ export function ln_create_wallet(username, password) {
465
+ const ptr0 = passStringToWasm0(username, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
466
+ const len0 = WASM_VECTOR_LEN;
467
+ const ptr1 = passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
468
+ const len1 = WASM_VECTOR_LEN;
469
+ const ret = wasm.ln_create_wallet(ptr0, len0, ptr1, len1);
470
+ return takeObject(ret);
471
+ }
472
+
473
+ /**
474
+ * @param {string} username
475
+ * @param {string} password
476
+ * @returns {Promise<any>}
477
+ */
478
+ export function ln_auth(username, password) {
479
+ const ptr0 = passStringToWasm0(username, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
480
+ const len0 = WASM_VECTOR_LEN;
481
+ const ptr1 = passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
482
+ const len1 = WASM_VECTOR_LEN;
483
+ const ret = wasm.ln_auth(ptr0, len0, ptr1, len1);
484
+ return takeObject(ret);
485
+ }
486
+
487
+ /**
488
+ * @param {string} description
489
+ * @param {number} amount
490
+ * @param {string} token
491
+ * @returns {Promise<any>}
492
+ */
493
+ export function ln_create_invoice(description, amount, token) {
494
+ const ptr0 = passStringToWasm0(description, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
495
+ const len0 = WASM_VECTOR_LEN;
496
+ const ptr1 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
497
+ const len1 = WASM_VECTOR_LEN;
498
+ const ret = wasm.ln_create_invoice(ptr0, len0, amount, ptr1, len1);
499
+ return takeObject(ret);
500
+ }
501
+
502
+ /**
503
+ * @param {string} token
504
+ * @returns {Promise<any>}
505
+ */
506
+ export function ln_get_balance(token) {
507
+ const ptr0 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
508
+ const len0 = WASM_VECTOR_LEN;
509
+ const ret = wasm.ln_get_balance(ptr0, len0);
510
+ return takeObject(ret);
511
+ }
512
+
513
+ /**
514
+ * @param {string} token
515
+ * @returns {Promise<any>}
516
+ */
517
+ export function ln_get_txs(token) {
518
+ const ptr0 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
519
+ const len0 = WASM_VECTOR_LEN;
520
+ const ret = wasm.ln_get_txs(ptr0, len0);
521
+ return takeObject(ret);
522
+ }
523
+
524
+ /**
525
+ * @param {string} payment_request
526
+ * @param {string} token
527
+ * @returns {Promise<any>}
528
+ */
529
+ export function ln_pay_invoice(payment_request, token) {
530
+ const ptr0 = passStringToWasm0(payment_request, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
531
+ const len0 = WASM_VECTOR_LEN;
532
+ const ptr1 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
533
+ const len1 = WASM_VECTOR_LEN;
534
+ const ret = wasm.ln_pay_invoice(ptr0, len0, ptr1, len1);
535
+ return takeObject(ret);
536
+ }
537
+
453
538
  let cachedUint32Memory0 = new Uint32Array();
454
539
 
455
540
  function getUint32Memory0() {
@@ -480,10 +565,15 @@ function handleError(f, args) {
480
565
  function getArrayU8FromWasm0(ptr, len) {
481
566
  return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
482
567
  }
483
- function __wbg_adapter_133(arg0, arg1, arg2, arg3) {
484
- wasm.wasm_bindgen__convert__closures__invoke2_mut__h18c6a056f8357172(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
568
+ function __wbg_adapter_137(arg0, arg1, arg2, arg3) {
569
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__h15f50af40ffe315b(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
485
570
  }
486
571
 
572
+ export function __wbindgen_string_new(arg0, arg1) {
573
+ const ret = getStringFromWasm0(arg0, arg1);
574
+ return addHeapObject(ret);
575
+ };
576
+
487
577
  export function __wbindgen_object_drop_ref(arg0) {
488
578
  takeObject(arg0);
489
579
  };
@@ -498,11 +588,6 @@ export function __wbindgen_cb_drop(arg0) {
498
588
  return ret;
499
589
  };
500
590
 
501
- export function __wbindgen_string_new(arg0, arg1) {
502
- const ret = getStringFromWasm0(arg0, arg1);
503
- return addHeapObject(ret);
504
- };
505
-
506
591
  export function __wbindgen_string_get(arg0, arg1) {
507
592
  const obj = getObject(arg1);
508
593
  const ret = typeof(obj) === 'string' ? obj : undefined;
@@ -551,16 +636,8 @@ export function __wbg_trace_fe50dc146726736b(arg0, arg1) {
551
636
  console.trace(...v0);
552
637
  };
553
638
 
554
- export function __wbg_randomFillSync_065afffde01daa66() { return handleError(function (arg0, arg1, arg2) {
555
- getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
556
- }, arguments) };
557
-
558
- export function __wbg_getRandomValues_b99eec4244a475bb() { return handleError(function (arg0, arg1) {
559
- getObject(arg0).getRandomValues(getObject(arg1));
560
- }, arguments) };
561
-
562
- export function __wbg_process_0cc2ada8524d6f83(arg0) {
563
- const ret = getObject(arg0).process;
639
+ export function __wbg_crypto_e1d53a1d73fb10b8(arg0) {
640
+ const ret = getObject(arg0).crypto;
564
641
  return addHeapObject(ret);
565
642
  };
566
643
 
@@ -570,12 +647,17 @@ export function __wbindgen_is_object(arg0) {
570
647
  return ret;
571
648
  };
572
649
 
573
- export function __wbg_versions_c11acceab27a6c87(arg0) {
650
+ export function __wbg_process_038c26bf42b093f8(arg0) {
651
+ const ret = getObject(arg0).process;
652
+ return addHeapObject(ret);
653
+ };
654
+
655
+ export function __wbg_versions_ab37218d2f0b24a8(arg0) {
574
656
  const ret = getObject(arg0).versions;
575
657
  return addHeapObject(ret);
576
658
  };
577
659
 
578
- export function __wbg_node_7ff1ce49caf23815(arg0) {
660
+ export function __wbg_node_080f4b19d15bc1fe(arg0) {
579
661
  const ret = getObject(arg0).node;
580
662
  return addHeapObject(ret);
581
663
  };
@@ -585,24 +667,35 @@ export function __wbindgen_is_string(arg0) {
585
667
  return ret;
586
668
  };
587
669
 
588
- export function __wbg_static_accessor_NODE_MODULE_cf6401cc1091279e() {
589
- const ret = module;
670
+ export function __wbg_msCrypto_6e7d3e1f92610cbb(arg0) {
671
+ const ret = getObject(arg0).msCrypto;
590
672
  return addHeapObject(ret);
591
673
  };
592
674
 
593
- export function __wbg_require_a746e79b322b9336() { return handleError(function (arg0, arg1, arg2) {
594
- const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
675
+ export function __wbg_require_78a3dcfbdba9cbce() { return handleError(function () {
676
+ const ret = module.require;
595
677
  return addHeapObject(ret);
596
678
  }, arguments) };
597
679
 
598
- export function __wbg_crypto_2036bed7c44c25e7(arg0) {
599
- const ret = getObject(arg0).crypto;
600
- return addHeapObject(ret);
680
+ export function __wbindgen_is_function(arg0) {
681
+ const ret = typeof(getObject(arg0)) === 'function';
682
+ return ret;
601
683
  };
602
684
 
603
- export function __wbg_msCrypto_a21fc88caf1ecdc8(arg0) {
604
- const ret = getObject(arg0).msCrypto;
605
- return addHeapObject(ret);
685
+ export function __wbg_getRandomValues_805f1c3d65988a5a() { return handleError(function (arg0, arg1) {
686
+ getObject(arg0).getRandomValues(getObject(arg1));
687
+ }, arguments) };
688
+
689
+ export function __wbg_randomFillSync_6894564c2c334c42() { return handleError(function (arg0, arg1, arg2) {
690
+ getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
691
+ }, arguments) };
692
+
693
+ export function __wbg_randomFillSync_85b3f4c52c56c313(arg0, arg1, arg2) {
694
+ getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
695
+ };
696
+
697
+ export function __wbg_getRandomValues_cd175915511f705e(arg0, arg1) {
698
+ getObject(arg0).getRandomValues(getObject(arg1));
606
699
  };
607
700
 
608
701
  export function __wbg_self_7eede1f4488bf346() { return handleError(function () {
@@ -640,29 +733,16 @@ export function __wbg_getRandomValues_307049345d0bd88c(arg0) {
640
733
  return addHeapObject(ret);
641
734
  };
642
735
 
643
- export function __wbg_getRandomValues_cd175915511f705e(arg0, arg1) {
644
- getObject(arg0).getRandomValues(getObject(arg1));
645
- };
646
-
647
- export function __wbg_randomFillSync_85b3f4c52c56c313(arg0, arg1, arg2) {
648
- getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
649
- };
650
-
651
736
  export function __wbindgen_object_clone_ref(arg0) {
652
737
  const ret = getObject(arg0);
653
738
  return addHeapObject(ret);
654
739
  };
655
740
 
656
- export function __wbg_fetch_386f87a3ebf5003c(arg0) {
741
+ export function __wbg_fetch_3894579f6e2af3be(arg0) {
657
742
  const ret = fetch(getObject(arg0));
658
743
  return addHeapObject(ret);
659
744
  };
660
745
 
661
- export function __wbg_fetch_749a56934f95c96c(arg0, arg1) {
662
- const ret = getObject(arg0).fetch(getObject(arg1));
663
- return addHeapObject(ret);
664
- };
665
-
666
746
  export function __wbg_instanceof_Response_eaa426220848a39e(arg0) {
667
747
  let result;
668
748
  try {
@@ -702,6 +782,11 @@ export function __wbg_text_1169d752cc697903() { return handleError(function (arg
702
782
  return addHeapObject(ret);
703
783
  }, arguments) };
704
784
 
785
+ export function __wbg_fetch_749a56934f95c96c(arg0, arg1) {
786
+ const ret = getObject(arg0).fetch(getObject(arg1));
787
+ return addHeapObject(ret);
788
+ };
789
+
705
790
  export function __wbg_new_2d0053ee81e4dd2a() { return handleError(function () {
706
791
  const ret = new Headers();
707
792
  return addHeapObject(ret);
@@ -716,11 +801,6 @@ export function __wbg_newwithstrandinit_05d7180788420c40() { return handleError(
716
801
  return addHeapObject(ret);
717
802
  }, arguments) };
718
803
 
719
- export function __wbindgen_is_function(arg0) {
720
- const ret = typeof(getObject(arg0)) === 'function';
721
- return ret;
722
- };
723
-
724
804
  export function __wbg_newnoargs_b5b063fc6c2f0376(arg0, arg1) {
725
805
  const ret = new Function(getStringFromWasm0(arg0, arg1));
726
806
  return addHeapObject(ret);
@@ -803,7 +883,7 @@ export function __wbg_new_9962f939219f1820(arg0, arg1) {
803
883
  const a = state0.a;
804
884
  state0.a = 0;
805
885
  try {
806
- return __wbg_adapter_133(a, state0.b, arg0, arg1);
886
+ return __wbg_adapter_137(a, state0.b, arg0, arg1);
807
887
  } finally {
808
888
  state0.a = a;
809
889
  }
@@ -939,8 +1019,8 @@ export function __wbindgen_memory() {
939
1019
  return addHeapObject(ret);
940
1020
  };
941
1021
 
942
- export function __wbindgen_closure_wrapper2961(arg0, arg1, arg2) {
943
- const ret = makeMutClosure(arg0, arg1, 913, __wbg_adapter_28);
1022
+ export function __wbindgen_closure_wrapper3005(arg0, arg1, arg2) {
1023
+ const ret = makeMutClosure(arg0, arg1, 941, __wbg_adapter_28);
944
1024
  return addHeapObject(ret);
945
1025
  };
946
1026
 
Binary file
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "Francisco Calderón <francisco@diba.io>"
7
7
  ],
8
8
  "description": "Core functionality for the BitMask wallet",
9
- "version": "0.4.0",
9
+ "version": "0.4.2",
10
10
  "license": "MIT",
11
11
  "repository": {
12
12
  "type": "git",