react-native-nitro-ark 0.0.79 → 0.0.80

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.
@@ -36,7 +36,6 @@ export interface BarkArkInfo {
36
36
  vtxo_expiry_delta: number; // u16
37
37
  htlc_send_expiry_delta: number; // u16
38
38
  max_vtxo_amount: number; // u64
39
- max_arkoor_depth: number; // u16
40
39
  required_board_confirmations: number; // u8
41
40
  }
42
41
 
@@ -58,7 +57,7 @@ interface BarkVtxo {
58
57
 
59
58
  export interface BoardResult {
60
59
  funding_txid: string;
61
- vtxos: BarkVtxo[];
60
+ vtxos: string[];
62
61
  }
63
62
 
64
63
  export interface Bolt11Invoice {
@@ -76,23 +75,12 @@ export interface ArkoorPaymentResult {
76
75
  payment_type: PaymentTypes; // 'Arkoor'
77
76
  }
78
77
 
79
- export interface Bolt11PaymentResult {
80
- bolt11_invoice: string;
81
- preimage: string;
82
- payment_type: PaymentTypes; // 'Lightning'
83
- }
84
-
85
- export interface Bolt12PaymentResult {
86
- bolt12_offer: string;
87
- preimage: string;
88
- payment_type: PaymentTypes; // 'Bolt12'
89
- }
90
-
91
- export interface LnurlPaymentResult {
92
- lnurl: string;
93
- bolt11_invoice: string;
94
- preimage: string;
95
- payment_type: PaymentTypes; // 'Lnurl'
78
+ export interface LightningSendResult {
79
+ invoice: string;
80
+ amount: number; // u64
81
+ htlc_vtxos: BarkVtxo[];
82
+ movement_id: number; // u32
83
+ preimage: string | null;
96
84
  }
97
85
 
98
86
  export interface OnchainPaymentResult {
@@ -112,7 +100,6 @@ export interface LightningReceiveBalance {
112
100
  export interface OffchainBalanceResult {
113
101
  spendable: number; // u64
114
102
  pending_lightning_send: number; // u64
115
- pending_lightning_receive: LightningReceiveBalance;
116
103
  pending_in_round: number; // u64
117
104
  pending_exit: number; // u64
118
105
  pending_board: number; // u64
@@ -154,6 +141,7 @@ export interface BarkMovementSubsystem {
154
141
 
155
142
  export interface BarkMovementDestination {
156
143
  destination: string;
144
+ payment_method: string;
157
145
  amount_sat: number;
158
146
  }
159
147
 
@@ -200,13 +188,14 @@ export interface NitroArk extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
200
188
  loadWallet(datadir: string, config: BarkCreateOpts): Promise<void>;
201
189
  isWalletLoaded(): Promise<boolean>;
202
190
  closeWallet(): Promise<void>;
203
- checkConnection(): Promise<void>;
191
+ refreshServer(): Promise<void>;
204
192
  syncPendingBoards(): Promise<void>;
205
193
  maintenance(): Promise<void>;
206
194
  maintenanceWithOnchain(): Promise<void>;
207
195
  maintenanceRefresh(): Promise<void>;
208
196
  sync(): Promise<void>;
209
197
  syncExits(): Promise<void>;
198
+ syncPendingRounds(): Promise<void>;
210
199
 
211
200
  // --- Wallet Info ---
212
201
  getArkInfo(): Promise<BarkArkInfo>;
@@ -232,7 +221,7 @@ export interface NitroArk extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
232
221
  signature: string,
233
222
  publicKey: string
234
223
  ): Promise<boolean>;
235
- movements(): Promise<BarkMovement[]>;
224
+ history(): Promise<BarkMovement[]>;
236
225
  vtxos(): Promise<BarkVtxo[]>;
237
226
  getFirstExpiringVtxoBlockheight(): Promise<number | undefined>;
238
227
  getNextRequiredRefreshBlockheight(): Promise<number | undefined>;
@@ -272,16 +261,16 @@ export interface NitroArk extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
272
261
  payLightningInvoice(
273
262
  destination: string,
274
263
  amountSat?: number
275
- ): Promise<Bolt11PaymentResult>;
264
+ ): Promise<LightningSendResult>;
276
265
  payLightningOffer(
277
266
  offer: string,
278
267
  amountSat?: number
279
- ): Promise<Bolt12PaymentResult>;
268
+ ): Promise<LightningSendResult>;
280
269
  payLightningAddress(
281
270
  addr: string,
282
271
  amountSat: number,
283
272
  comment: string
284
- ): Promise<LnurlPaymentResult>;
273
+ ): Promise<LightningSendResult>;
285
274
  sendRoundOnchainPayment(
286
275
  destination: string,
287
276
  amountSat: number
@@ -292,6 +281,10 @@ export interface NitroArk extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
292
281
  lightningReceiveStatus(
293
282
  paymentHash: string
294
283
  ): Promise<LightningReceive | undefined>;
284
+ checkLightningPayment(
285
+ paymentHash: string,
286
+ wait: boolean
287
+ ): Promise<string | null>;
295
288
  tryClaimLightningReceive(
296
289
  paymentHash: string,
297
290
  wait: boolean,
package/src/index.tsx CHANGED
@@ -6,9 +6,7 @@ import type {
6
6
  Bolt11Invoice,
7
7
  BarkSendManyOutput,
8
8
  ArkoorPaymentResult,
9
- Bolt11PaymentResult,
10
- Bolt12PaymentResult,
11
- LnurlPaymentResult,
9
+ LightningSendResult,
12
10
  OnchainPaymentResult,
13
11
  OffchainBalanceResult,
14
12
  OnchainBalanceResult,
@@ -16,6 +14,7 @@ import type {
16
14
  KeyPairResult,
17
15
  LightningReceive,
18
16
  BarkMovement as NitroBarkMovement,
17
+ BarkMovementDestination as NitroBarkMovementDestination,
19
18
  BoardResult,
20
19
  RoundStatus,
21
20
  } from './NitroArk.nitro';
@@ -32,8 +31,21 @@ export type BarkVtxo = {
32
31
 
33
32
  export type MovementStatus = 'pending' | 'finished' | 'failed' | 'cancelled';
34
33
 
34
+ export type BarkMovementDestination = NitroBarkMovementDestination & {
35
+ payment_method:
36
+ | 'ark'
37
+ | 'bitcoin'
38
+ | 'output-script'
39
+ | 'invoice'
40
+ | 'offer'
41
+ | 'lightning-address'
42
+ | 'custom';
43
+ };
44
+
35
45
  export type BarkMovement = NitroBarkMovement & {
36
46
  status: MovementStatus;
47
+ sent_to: BarkMovementDestination[];
48
+ received_on: BarkMovementDestination[];
37
49
  };
38
50
 
39
51
  // Create the hybrid object instance
@@ -85,8 +97,12 @@ export function closeWallet(): Promise<void> {
85
97
  return NitroArkHybridObject.closeWallet();
86
98
  }
87
99
 
88
- export function checkConnection(): Promise<void> {
89
- return NitroArkHybridObject.checkConnection();
100
+ /**
101
+ * Refreshes the server state.
102
+ * @returns A promise that resolves on success or rejects on error.
103
+ */
104
+ export function refreshServer(): Promise<void> {
105
+ return NitroArkHybridObject.refreshServer();
90
106
  }
91
107
 
92
108
  /**
@@ -147,6 +163,14 @@ export function syncExits(): Promise<void> {
147
163
  return NitroArkHybridObject.syncExits();
148
164
  }
149
165
 
166
+ /**
167
+ * Synchronizes pending rounds.
168
+ * @returns A promise that resolves on success.
169
+ */
170
+ export function syncPendingRounds(): Promise<void> {
171
+ return NitroArkHybridObject.syncPendingRounds();
172
+ }
173
+
150
174
  // --- Wallet Info ---
151
175
 
152
176
  /**
@@ -267,11 +291,11 @@ export function verifyMessage(
267
291
  }
268
292
 
269
293
  /**
270
- * Gets a paginated list of wallet movements (balance changes).
294
+ * Gets a paginated list of wallet history (balance changes).
271
295
  * @returns A promise resolving to an array of BarkMovement objects.
272
296
  */
273
- export function movements(): Promise<BarkMovement[]> {
274
- return NitroArkHybridObject.movements() as Promise<BarkMovement[]>;
297
+ export function history(): Promise<BarkMovement[]> {
298
+ return NitroArkHybridObject.history() as Promise<BarkMovement[]>;
275
299
  }
276
300
 
277
301
  /**
@@ -410,6 +434,19 @@ export function lightningReceiveStatus(
410
434
  return NitroArkHybridObject.lightningReceiveStatus(paymentHash);
411
435
  }
412
436
 
437
+ /**
438
+ * Checks if a Lightning payment has been received and returns the preimage if available.
439
+ * @param paymentHash The payment hash of the Lightning payment.
440
+ * @param wait Whether to wait for the payment to be received.
441
+ * @returns A promise resolving to the preimage string if payment received, or null if not.
442
+ */
443
+ export function checkLightningPayment(
444
+ paymentHash: string,
445
+ wait: boolean
446
+ ): Promise<string | null> {
447
+ return NitroArkHybridObject.checkLightningPayment(paymentHash, wait);
448
+ }
449
+
413
450
  /**
414
451
  * Attempts to claim a Lightning payment, optionally using a claim token.
415
452
  * @param paymentHash The payment hash of the Lightning payment.
@@ -442,12 +479,12 @@ export function tryClaimAllLightningReceives(wait: boolean): Promise<void> {
442
479
  * Pays a Bolt11 Lightning invoice.
443
480
  * @param destination The Lightning invoice.
444
481
  * @param amountSat The amount in satoshis to send. Use 0 for invoice amount.
445
- * @returns A promise resolving to a Bolt11PaymentResult object
482
+ * @returns A promise resolving to a LightningSendResult object
446
483
  */
447
484
  export function payLightningInvoice(
448
485
  destination: string,
449
486
  amountSat?: number
450
- ): Promise<Bolt11PaymentResult> {
487
+ ): Promise<LightningSendResult> {
451
488
  return NitroArkHybridObject.payLightningInvoice(destination, amountSat);
452
489
  }
453
490
 
@@ -455,12 +492,12 @@ export function payLightningInvoice(
455
492
  * Sends a payment to a Bolt12 offer.
456
493
  * @param offer The Bolt12 offer.
457
494
  * @param amountSat The amount in satoshis to send. Use 0 for invoice amount.
458
- * @returns A promise resolving to a Bolt12PaymentResult object
495
+ * @returns A promise resolving to a LightningSendResult object
459
496
  */
460
497
  export function payLightningOffer(
461
498
  offer: string,
462
499
  amountSat?: number
463
- ): Promise<Bolt12PaymentResult> {
500
+ ): Promise<LightningSendResult> {
464
501
  return NitroArkHybridObject.payLightningOffer(offer, amountSat);
465
502
  }
466
503
 
@@ -469,13 +506,13 @@ export function payLightningOffer(
469
506
  * @param addr The Lightning Address.
470
507
  * @param amountSat The amount in satoshis to send.
471
508
  * @param comment An optional comment.
472
- * @returns A promise resolving to a LnurlPaymentResult object
509
+ * @returns A promise resolving to a LightningSendResult object
473
510
  */
474
511
  export function payLightningAddress(
475
512
  addr: string,
476
513
  amountSat: number,
477
514
  comment: string
478
- ): Promise<LnurlPaymentResult> {
515
+ ): Promise<LightningSendResult> {
479
516
  return NitroArkHybridObject.payLightningAddress(addr, amountSat, comment);
480
517
  }
481
518
 
@@ -567,8 +604,7 @@ export type {
567
604
  BoardResult,
568
605
  BarkSendManyOutput,
569
606
  ArkoorPaymentResult,
570
- Bolt11PaymentResult,
571
- LnurlPaymentResult,
607
+ LightningSendResult,
572
608
  OnchainPaymentResult,
573
609
  PaymentTypes,
574
610
  OffchainBalanceResult,
@@ -1,85 +0,0 @@
1
- ///
2
- /// Bolt11PaymentResult.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- #pragma once
9
-
10
- #if __has_include(<NitroModules/JSIConverter.hpp>)
11
- #include <NitroModules/JSIConverter.hpp>
12
- #else
13
- #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
- #endif
15
- #if __has_include(<NitroModules/NitroDefines.hpp>)
16
- #include <NitroModules/NitroDefines.hpp>
17
- #else
18
- #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
- #endif
20
- #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
- #include <NitroModules/JSIHelpers.hpp>
22
- #else
23
- #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
- #endif
25
-
26
- // Forward declaration of `PaymentTypes` to properly resolve imports.
27
- namespace margelo::nitro::nitroark { enum class PaymentTypes; }
28
-
29
- #include <string>
30
- #include "PaymentTypes.hpp"
31
-
32
- namespace margelo::nitro::nitroark {
33
-
34
- /**
35
- * A struct which can be represented as a JavaScript object (Bolt11PaymentResult).
36
- */
37
- struct Bolt11PaymentResult {
38
- public:
39
- std::string bolt11_invoice SWIFT_PRIVATE;
40
- std::string preimage SWIFT_PRIVATE;
41
- PaymentTypes payment_type SWIFT_PRIVATE;
42
-
43
- public:
44
- Bolt11PaymentResult() = default;
45
- explicit Bolt11PaymentResult(std::string bolt11_invoice, std::string preimage, PaymentTypes payment_type): bolt11_invoice(bolt11_invoice), preimage(preimage), payment_type(payment_type) {}
46
- };
47
-
48
- } // namespace margelo::nitro::nitroark
49
-
50
- namespace margelo::nitro {
51
-
52
- // C++ Bolt11PaymentResult <> JS Bolt11PaymentResult (object)
53
- template <>
54
- struct JSIConverter<margelo::nitro::nitroark::Bolt11PaymentResult> final {
55
- static inline margelo::nitro::nitroark::Bolt11PaymentResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
56
- jsi::Object obj = arg.asObject(runtime);
57
- return margelo::nitro::nitroark::Bolt11PaymentResult(
58
- JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "bolt11_invoice")),
59
- JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "preimage")),
60
- JSIConverter<margelo::nitro::nitroark::PaymentTypes>::fromJSI(runtime, obj.getProperty(runtime, "payment_type"))
61
- );
62
- }
63
- static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroark::Bolt11PaymentResult& arg) {
64
- jsi::Object obj(runtime);
65
- obj.setProperty(runtime, "bolt11_invoice", JSIConverter<std::string>::toJSI(runtime, arg.bolt11_invoice));
66
- obj.setProperty(runtime, "preimage", JSIConverter<std::string>::toJSI(runtime, arg.preimage));
67
- obj.setProperty(runtime, "payment_type", JSIConverter<margelo::nitro::nitroark::PaymentTypes>::toJSI(runtime, arg.payment_type));
68
- return obj;
69
- }
70
- static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
71
- if (!value.isObject()) {
72
- return false;
73
- }
74
- jsi::Object obj = value.getObject(runtime);
75
- if (!nitro::isPlainObject(runtime, obj)) {
76
- return false;
77
- }
78
- if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "bolt11_invoice"))) return false;
79
- if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "preimage"))) return false;
80
- if (!JSIConverter<margelo::nitro::nitroark::PaymentTypes>::canConvert(runtime, obj.getProperty(runtime, "payment_type"))) return false;
81
- return true;
82
- }
83
- };
84
-
85
- } // namespace margelo::nitro
@@ -1,85 +0,0 @@
1
- ///
2
- /// Bolt12PaymentResult.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- #pragma once
9
-
10
- #if __has_include(<NitroModules/JSIConverter.hpp>)
11
- #include <NitroModules/JSIConverter.hpp>
12
- #else
13
- #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
- #endif
15
- #if __has_include(<NitroModules/NitroDefines.hpp>)
16
- #include <NitroModules/NitroDefines.hpp>
17
- #else
18
- #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
- #endif
20
- #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
- #include <NitroModules/JSIHelpers.hpp>
22
- #else
23
- #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
- #endif
25
-
26
- // Forward declaration of `PaymentTypes` to properly resolve imports.
27
- namespace margelo::nitro::nitroark { enum class PaymentTypes; }
28
-
29
- #include <string>
30
- #include "PaymentTypes.hpp"
31
-
32
- namespace margelo::nitro::nitroark {
33
-
34
- /**
35
- * A struct which can be represented as a JavaScript object (Bolt12PaymentResult).
36
- */
37
- struct Bolt12PaymentResult {
38
- public:
39
- std::string bolt12_offer SWIFT_PRIVATE;
40
- std::string preimage SWIFT_PRIVATE;
41
- PaymentTypes payment_type SWIFT_PRIVATE;
42
-
43
- public:
44
- Bolt12PaymentResult() = default;
45
- explicit Bolt12PaymentResult(std::string bolt12_offer, std::string preimage, PaymentTypes payment_type): bolt12_offer(bolt12_offer), preimage(preimage), payment_type(payment_type) {}
46
- };
47
-
48
- } // namespace margelo::nitro::nitroark
49
-
50
- namespace margelo::nitro {
51
-
52
- // C++ Bolt12PaymentResult <> JS Bolt12PaymentResult (object)
53
- template <>
54
- struct JSIConverter<margelo::nitro::nitroark::Bolt12PaymentResult> final {
55
- static inline margelo::nitro::nitroark::Bolt12PaymentResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
56
- jsi::Object obj = arg.asObject(runtime);
57
- return margelo::nitro::nitroark::Bolt12PaymentResult(
58
- JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "bolt12_offer")),
59
- JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "preimage")),
60
- JSIConverter<margelo::nitro::nitroark::PaymentTypes>::fromJSI(runtime, obj.getProperty(runtime, "payment_type"))
61
- );
62
- }
63
- static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroark::Bolt12PaymentResult& arg) {
64
- jsi::Object obj(runtime);
65
- obj.setProperty(runtime, "bolt12_offer", JSIConverter<std::string>::toJSI(runtime, arg.bolt12_offer));
66
- obj.setProperty(runtime, "preimage", JSIConverter<std::string>::toJSI(runtime, arg.preimage));
67
- obj.setProperty(runtime, "payment_type", JSIConverter<margelo::nitro::nitroark::PaymentTypes>::toJSI(runtime, arg.payment_type));
68
- return obj;
69
- }
70
- static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
71
- if (!value.isObject()) {
72
- return false;
73
- }
74
- jsi::Object obj = value.getObject(runtime);
75
- if (!nitro::isPlainObject(runtime, obj)) {
76
- return false;
77
- }
78
- if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "bolt12_offer"))) return false;
79
- if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "preimage"))) return false;
80
- if (!JSIConverter<margelo::nitro::nitroark::PaymentTypes>::canConvert(runtime, obj.getProperty(runtime, "payment_type"))) return false;
81
- return true;
82
- }
83
- };
84
-
85
- } // namespace margelo::nitro
@@ -1,79 +0,0 @@
1
- ///
2
- /// LightningReceiveBalance.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- #pragma once
9
-
10
- #if __has_include(<NitroModules/JSIConverter.hpp>)
11
- #include <NitroModules/JSIConverter.hpp>
12
- #else
13
- #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
- #endif
15
- #if __has_include(<NitroModules/NitroDefines.hpp>)
16
- #include <NitroModules/NitroDefines.hpp>
17
- #else
18
- #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
- #endif
20
- #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
- #include <NitroModules/JSIHelpers.hpp>
22
- #else
23
- #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
- #endif
25
-
26
-
27
-
28
-
29
-
30
- namespace margelo::nitro::nitroark {
31
-
32
- /**
33
- * A struct which can be represented as a JavaScript object (LightningReceiveBalance).
34
- */
35
- struct LightningReceiveBalance {
36
- public:
37
- double total SWIFT_PRIVATE;
38
- double claimable SWIFT_PRIVATE;
39
-
40
- public:
41
- LightningReceiveBalance() = default;
42
- explicit LightningReceiveBalance(double total, double claimable): total(total), claimable(claimable) {}
43
- };
44
-
45
- } // namespace margelo::nitro::nitroark
46
-
47
- namespace margelo::nitro {
48
-
49
- // C++ LightningReceiveBalance <> JS LightningReceiveBalance (object)
50
- template <>
51
- struct JSIConverter<margelo::nitro::nitroark::LightningReceiveBalance> final {
52
- static inline margelo::nitro::nitroark::LightningReceiveBalance fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
53
- jsi::Object obj = arg.asObject(runtime);
54
- return margelo::nitro::nitroark::LightningReceiveBalance(
55
- JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "total")),
56
- JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "claimable"))
57
- );
58
- }
59
- static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroark::LightningReceiveBalance& arg) {
60
- jsi::Object obj(runtime);
61
- obj.setProperty(runtime, "total", JSIConverter<double>::toJSI(runtime, arg.total));
62
- obj.setProperty(runtime, "claimable", JSIConverter<double>::toJSI(runtime, arg.claimable));
63
- return obj;
64
- }
65
- static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
66
- if (!value.isObject()) {
67
- return false;
68
- }
69
- jsi::Object obj = value.getObject(runtime);
70
- if (!nitro::isPlainObject(runtime, obj)) {
71
- return false;
72
- }
73
- if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "total"))) return false;
74
- if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "claimable"))) return false;
75
- return true;
76
- }
77
- };
78
-
79
- } // namespace margelo::nitro
@@ -1,89 +0,0 @@
1
- ///
2
- /// LnurlPaymentResult.hpp
3
- /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2025 Marc Rousavy @ Margelo
6
- ///
7
-
8
- #pragma once
9
-
10
- #if __has_include(<NitroModules/JSIConverter.hpp>)
11
- #include <NitroModules/JSIConverter.hpp>
12
- #else
13
- #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
- #endif
15
- #if __has_include(<NitroModules/NitroDefines.hpp>)
16
- #include <NitroModules/NitroDefines.hpp>
17
- #else
18
- #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
- #endif
20
- #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
- #include <NitroModules/JSIHelpers.hpp>
22
- #else
23
- #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
- #endif
25
-
26
- // Forward declaration of `PaymentTypes` to properly resolve imports.
27
- namespace margelo::nitro::nitroark { enum class PaymentTypes; }
28
-
29
- #include <string>
30
- #include "PaymentTypes.hpp"
31
-
32
- namespace margelo::nitro::nitroark {
33
-
34
- /**
35
- * A struct which can be represented as a JavaScript object (LnurlPaymentResult).
36
- */
37
- struct LnurlPaymentResult {
38
- public:
39
- std::string lnurl SWIFT_PRIVATE;
40
- std::string bolt11_invoice SWIFT_PRIVATE;
41
- std::string preimage SWIFT_PRIVATE;
42
- PaymentTypes payment_type SWIFT_PRIVATE;
43
-
44
- public:
45
- LnurlPaymentResult() = default;
46
- explicit LnurlPaymentResult(std::string lnurl, std::string bolt11_invoice, std::string preimage, PaymentTypes payment_type): lnurl(lnurl), bolt11_invoice(bolt11_invoice), preimage(preimage), payment_type(payment_type) {}
47
- };
48
-
49
- } // namespace margelo::nitro::nitroark
50
-
51
- namespace margelo::nitro {
52
-
53
- // C++ LnurlPaymentResult <> JS LnurlPaymentResult (object)
54
- template <>
55
- struct JSIConverter<margelo::nitro::nitroark::LnurlPaymentResult> final {
56
- static inline margelo::nitro::nitroark::LnurlPaymentResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
57
- jsi::Object obj = arg.asObject(runtime);
58
- return margelo::nitro::nitroark::LnurlPaymentResult(
59
- JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "lnurl")),
60
- JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "bolt11_invoice")),
61
- JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "preimage")),
62
- JSIConverter<margelo::nitro::nitroark::PaymentTypes>::fromJSI(runtime, obj.getProperty(runtime, "payment_type"))
63
- );
64
- }
65
- static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroark::LnurlPaymentResult& arg) {
66
- jsi::Object obj(runtime);
67
- obj.setProperty(runtime, "lnurl", JSIConverter<std::string>::toJSI(runtime, arg.lnurl));
68
- obj.setProperty(runtime, "bolt11_invoice", JSIConverter<std::string>::toJSI(runtime, arg.bolt11_invoice));
69
- obj.setProperty(runtime, "preimage", JSIConverter<std::string>::toJSI(runtime, arg.preimage));
70
- obj.setProperty(runtime, "payment_type", JSIConverter<margelo::nitro::nitroark::PaymentTypes>::toJSI(runtime, arg.payment_type));
71
- return obj;
72
- }
73
- static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
74
- if (!value.isObject()) {
75
- return false;
76
- }
77
- jsi::Object obj = value.getObject(runtime);
78
- if (!nitro::isPlainObject(runtime, obj)) {
79
- return false;
80
- }
81
- if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "lnurl"))) return false;
82
- if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "bolt11_invoice"))) return false;
83
- if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "preimage"))) return false;
84
- if (!JSIConverter<margelo::nitro::nitroark::PaymentTypes>::canConvert(runtime, obj.getProperty(runtime, "payment_type"))) return false;
85
- return true;
86
- }
87
- };
88
-
89
- } // namespace margelo::nitro