react-native-nitro-ark 0.0.35 → 0.0.36
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/cpp/NitroArk.hpp +23 -0
- package/cpp/generated/ark_cxx.h +15 -0
- package/lib/typescript/src/NitroArk.nitro.d.ts +5 -0
- package/lib/typescript/src/NitroArk.nitro.d.ts.map +1 -1
- package/nitrogen/generated/shared/c++/ArkoorPaymentResult.hpp +9 -2
- package/nitrogen/generated/shared/c++/Bolt11PaymentResult.hpp +9 -3
- package/nitrogen/generated/shared/c++/LnurlPaymentResult.hpp +9 -3
- package/nitrogen/generated/shared/c++/OnchainPaymentResult.hpp +9 -3
- package/nitrogen/generated/shared/c++/PaymentTypes.hpp +86 -0
- package/package.json +1 -1
- package/src/NitroArk.nitro.ts +6 -0
package/cpp/NitroArk.hpp
CHANGED
|
@@ -11,6 +11,25 @@
|
|
|
11
11
|
namespace margelo::nitro::nitroark
|
|
12
12
|
{
|
|
13
13
|
|
|
14
|
+
using namespace margelo::nitro;
|
|
15
|
+
// Helper function to convert rust cxx payment type to nitrogen payment type
|
|
16
|
+
inline PaymentTypes convertPaymentType(bark_cxx::PaymentTypes type)
|
|
17
|
+
{
|
|
18
|
+
switch (type)
|
|
19
|
+
{
|
|
20
|
+
case bark_cxx::PaymentTypes::Bolt11:
|
|
21
|
+
return PaymentTypes::BOLT11;
|
|
22
|
+
case bark_cxx::PaymentTypes::Lnurl:
|
|
23
|
+
return PaymentTypes::LNURL;
|
|
24
|
+
case bark_cxx::PaymentTypes::Arkoor:
|
|
25
|
+
return PaymentTypes::ARKOOR;
|
|
26
|
+
case bark_cxx::PaymentTypes::Onchain:
|
|
27
|
+
return PaymentTypes::ONCHAIN;
|
|
28
|
+
default:
|
|
29
|
+
throw std::runtime_error("Invalid payment type");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
14
33
|
class NitroArk : public HybridNitroArkSpec
|
|
15
34
|
{
|
|
16
35
|
public:
|
|
@@ -270,6 +289,7 @@ namespace margelo::nitro::nitroark
|
|
|
270
289
|
result.txid = std::string(rust_result.txid.data(), rust_result.txid.length());
|
|
271
290
|
result.amount_sat = static_cast<double>(rust_result.amount_sat);
|
|
272
291
|
result.destination_address = std::string(rust_result.destination_address.data(), rust_result.destination_address.length());
|
|
292
|
+
result.payment_type = convertPaymentType(rust_result.payment_type);
|
|
273
293
|
|
|
274
294
|
return result;
|
|
275
295
|
} catch (const rust::Error &e) {
|
|
@@ -350,6 +370,7 @@ namespace margelo::nitro::nitroark
|
|
|
350
370
|
ArkoorPaymentResult result;
|
|
351
371
|
result.amount_sat = static_cast<double>(rust_result.amount_sat);
|
|
352
372
|
result.destination_pubkey = std::string(rust_result.destination_pubkey.data(), rust_result.destination_pubkey.length());
|
|
373
|
+
result.payment_type = convertPaymentType(rust_result.payment_type);
|
|
353
374
|
|
|
354
375
|
std::vector<BarkVtxo> vtxos;
|
|
355
376
|
for (const auto& rust_vtxo : rust_result.vtxos) {
|
|
@@ -385,6 +406,7 @@ namespace margelo::nitro::nitroark
|
|
|
385
406
|
Bolt11PaymentResult result;
|
|
386
407
|
result.bolt11_invoice = std::string(rust_result.bolt11_invoice.data(), rust_result.bolt11_invoice.length());
|
|
387
408
|
result.preimage = std::string(rust_result.preimage.data(), rust_result.preimage.length());
|
|
409
|
+
result.payment_type = convertPaymentType(rust_result.payment_type);
|
|
388
410
|
|
|
389
411
|
return result;
|
|
390
412
|
} catch (const rust::Error &e) {
|
|
@@ -404,6 +426,7 @@ namespace margelo::nitro::nitroark
|
|
|
404
426
|
result.lnurl = std::string(rust_result.lnurl.data(), rust_result.lnurl.length());
|
|
405
427
|
result.bolt11_invoice = std::string(rust_result.bolt11_invoice.data(), rust_result.bolt11_invoice.length());
|
|
406
428
|
result.preimage = std::string(rust_result.preimage.data(), rust_result.preimage.length());
|
|
429
|
+
result.payment_type = convertPaymentType(rust_result.payment_type);
|
|
407
430
|
|
|
408
431
|
return result;
|
|
409
432
|
} catch (const rust::Error &e) {
|
package/cpp/generated/ark_cxx.h
CHANGED
|
@@ -798,6 +798,7 @@ std::size_t align_of() {
|
|
|
798
798
|
|
|
799
799
|
namespace bark_cxx {
|
|
800
800
|
struct BarkVtxo;
|
|
801
|
+
enum class PaymentTypes : ::std::uint8_t;
|
|
801
802
|
struct Bolt11PaymentResult;
|
|
802
803
|
struct LnurlPaymentResult;
|
|
803
804
|
struct ArkoorPaymentResult;
|
|
@@ -822,11 +823,22 @@ struct BarkVtxo final {
|
|
|
822
823
|
};
|
|
823
824
|
#endif // CXXBRIDGE1_STRUCT_bark_cxx$BarkVtxo
|
|
824
825
|
|
|
826
|
+
#ifndef CXXBRIDGE1_ENUM_bark_cxx$PaymentTypes
|
|
827
|
+
#define CXXBRIDGE1_ENUM_bark_cxx$PaymentTypes
|
|
828
|
+
enum class PaymentTypes : ::std::uint8_t {
|
|
829
|
+
Bolt11 = 0,
|
|
830
|
+
Lnurl = 1,
|
|
831
|
+
Arkoor = 2,
|
|
832
|
+
Onchain = 3,
|
|
833
|
+
};
|
|
834
|
+
#endif // CXXBRIDGE1_ENUM_bark_cxx$PaymentTypes
|
|
835
|
+
|
|
825
836
|
#ifndef CXXBRIDGE1_STRUCT_bark_cxx$Bolt11PaymentResult
|
|
826
837
|
#define CXXBRIDGE1_STRUCT_bark_cxx$Bolt11PaymentResult
|
|
827
838
|
struct Bolt11PaymentResult final {
|
|
828
839
|
::rust::String bolt11_invoice;
|
|
829
840
|
::rust::String preimage;
|
|
841
|
+
::bark_cxx::PaymentTypes payment_type;
|
|
830
842
|
|
|
831
843
|
using IsRelocatable = ::std::true_type;
|
|
832
844
|
};
|
|
@@ -838,6 +850,7 @@ struct LnurlPaymentResult final {
|
|
|
838
850
|
::rust::String lnurl;
|
|
839
851
|
::rust::String bolt11_invoice;
|
|
840
852
|
::rust::String preimage;
|
|
853
|
+
::bark_cxx::PaymentTypes payment_type;
|
|
841
854
|
|
|
842
855
|
using IsRelocatable = ::std::true_type;
|
|
843
856
|
};
|
|
@@ -848,6 +861,7 @@ struct LnurlPaymentResult final {
|
|
|
848
861
|
struct ArkoorPaymentResult final {
|
|
849
862
|
::std::uint64_t amount_sat CXX_DEFAULT_VALUE(0);
|
|
850
863
|
::rust::String destination_pubkey;
|
|
864
|
+
::bark_cxx::PaymentTypes payment_type;
|
|
851
865
|
::rust::Vec<::bark_cxx::BarkVtxo> vtxos;
|
|
852
866
|
|
|
853
867
|
using IsRelocatable = ::std::true_type;
|
|
@@ -860,6 +874,7 @@ struct OnchainPaymentResult final {
|
|
|
860
874
|
::rust::String txid;
|
|
861
875
|
::std::uint64_t amount_sat CXX_DEFAULT_VALUE(0);
|
|
862
876
|
::rust::String destination_address;
|
|
877
|
+
::bark_cxx::PaymentTypes payment_type;
|
|
863
878
|
|
|
864
879
|
using IsRelocatable = ::std::true_type;
|
|
865
880
|
};
|
|
@@ -36,24 +36,29 @@ export interface BarkVtxo {
|
|
|
36
36
|
exit_delta: number;
|
|
37
37
|
anchor_point: string;
|
|
38
38
|
}
|
|
39
|
+
export type PaymentTypes = 'Bolt11' | 'Lnurl' | 'Arkoor' | 'Onchain';
|
|
39
40
|
export interface ArkoorPaymentResult {
|
|
40
41
|
amount_sat: number;
|
|
41
42
|
destination_pubkey: string;
|
|
42
43
|
vtxos: BarkVtxo[];
|
|
44
|
+
payment_type: PaymentTypes;
|
|
43
45
|
}
|
|
44
46
|
export interface Bolt11PaymentResult {
|
|
45
47
|
bolt11_invoice: string;
|
|
46
48
|
preimage: string;
|
|
49
|
+
payment_type: PaymentTypes;
|
|
47
50
|
}
|
|
48
51
|
export interface LnurlPaymentResult {
|
|
49
52
|
lnurl: string;
|
|
50
53
|
bolt11_invoice: string;
|
|
51
54
|
preimage: string;
|
|
55
|
+
payment_type: PaymentTypes;
|
|
52
56
|
}
|
|
53
57
|
export interface OnchainPaymentResult {
|
|
54
58
|
txid: string;
|
|
55
59
|
amount_sat: number;
|
|
56
60
|
destination_address: string;
|
|
61
|
+
payment_type: PaymentTypes;
|
|
57
62
|
}
|
|
58
63
|
export interface NitroArk extends HybridObject<{
|
|
59
64
|
ios: 'c++';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NitroArk.nitro.d.ts","sourceRoot":"","sources":["../../../src/NitroArk.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAM/D,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6BAA6B,CAAC,EAAE,MAAM,CAAC;IACvC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAGD,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,C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AiB,CACf,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAChC,UAAU,CACR,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC/B,gBAAgB,CACd,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,MAAM,CAAC,CAAC;IAGnB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACnD,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAGlD,gBAAgB,CACd,OAAO,EAAE,MAAM,EAAE,EACjB,kBAAkB,EAAE,MAAM,GACzB,OAAO,CAAC,MAAM,CAAC,CAAC;IACnB,WAAW,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACtD,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAChC,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACrC"}
|
|
@@ -20,10 +20,13 @@
|
|
|
20
20
|
|
|
21
21
|
// Forward declaration of `BarkVtxo` to properly resolve imports.
|
|
22
22
|
namespace margelo::nitro::nitroark { struct BarkVtxo; }
|
|
23
|
+
// Forward declaration of `PaymentTypes` to properly resolve imports.
|
|
24
|
+
namespace margelo::nitro::nitroark { enum class PaymentTypes; }
|
|
23
25
|
|
|
24
26
|
#include <string>
|
|
25
27
|
#include <vector>
|
|
26
28
|
#include "BarkVtxo.hpp"
|
|
29
|
+
#include "PaymentTypes.hpp"
|
|
27
30
|
|
|
28
31
|
namespace margelo::nitro::nitroark {
|
|
29
32
|
|
|
@@ -35,10 +38,11 @@ namespace margelo::nitro::nitroark {
|
|
|
35
38
|
double amount_sat SWIFT_PRIVATE;
|
|
36
39
|
std::string destination_pubkey SWIFT_PRIVATE;
|
|
37
40
|
std::vector<BarkVtxo> vtxos SWIFT_PRIVATE;
|
|
41
|
+
PaymentTypes payment_type SWIFT_PRIVATE;
|
|
38
42
|
|
|
39
43
|
public:
|
|
40
44
|
ArkoorPaymentResult() = default;
|
|
41
|
-
explicit ArkoorPaymentResult(double amount_sat, std::string destination_pubkey, std::vector<BarkVtxo> vtxos): amount_sat(amount_sat), destination_pubkey(destination_pubkey), vtxos(vtxos) {}
|
|
45
|
+
explicit ArkoorPaymentResult(double amount_sat, std::string destination_pubkey, std::vector<BarkVtxo> vtxos, PaymentTypes payment_type): amount_sat(amount_sat), destination_pubkey(destination_pubkey), vtxos(vtxos), payment_type(payment_type) {}
|
|
42
46
|
};
|
|
43
47
|
|
|
44
48
|
} // namespace margelo::nitro::nitroark
|
|
@@ -55,7 +59,8 @@ namespace margelo::nitro {
|
|
|
55
59
|
return ArkoorPaymentResult(
|
|
56
60
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "amount_sat")),
|
|
57
61
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "destination_pubkey")),
|
|
58
|
-
JSIConverter<std::vector<BarkVtxo>>::fromJSI(runtime, obj.getProperty(runtime, "vtxos"))
|
|
62
|
+
JSIConverter<std::vector<BarkVtxo>>::fromJSI(runtime, obj.getProperty(runtime, "vtxos")),
|
|
63
|
+
JSIConverter<PaymentTypes>::fromJSI(runtime, obj.getProperty(runtime, "payment_type"))
|
|
59
64
|
);
|
|
60
65
|
}
|
|
61
66
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const ArkoorPaymentResult& arg) {
|
|
@@ -63,6 +68,7 @@ namespace margelo::nitro {
|
|
|
63
68
|
obj.setProperty(runtime, "amount_sat", JSIConverter<double>::toJSI(runtime, arg.amount_sat));
|
|
64
69
|
obj.setProperty(runtime, "destination_pubkey", JSIConverter<std::string>::toJSI(runtime, arg.destination_pubkey));
|
|
65
70
|
obj.setProperty(runtime, "vtxos", JSIConverter<std::vector<BarkVtxo>>::toJSI(runtime, arg.vtxos));
|
|
71
|
+
obj.setProperty(runtime, "payment_type", JSIConverter<PaymentTypes>::toJSI(runtime, arg.payment_type));
|
|
66
72
|
return obj;
|
|
67
73
|
}
|
|
68
74
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -73,6 +79,7 @@ namespace margelo::nitro {
|
|
|
73
79
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "amount_sat"))) return false;
|
|
74
80
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "destination_pubkey"))) return false;
|
|
75
81
|
if (!JSIConverter<std::vector<BarkVtxo>>::canConvert(runtime, obj.getProperty(runtime, "vtxos"))) return false;
|
|
82
|
+
if (!JSIConverter<PaymentTypes>::canConvert(runtime, obj.getProperty(runtime, "payment_type"))) return false;
|
|
76
83
|
return true;
|
|
77
84
|
}
|
|
78
85
|
};
|
|
@@ -18,9 +18,11 @@
|
|
|
18
18
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
19
|
#endif
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
// Forward declaration of `PaymentTypes` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::nitroark { enum class PaymentTypes; }
|
|
22
23
|
|
|
23
24
|
#include <string>
|
|
25
|
+
#include "PaymentTypes.hpp"
|
|
24
26
|
|
|
25
27
|
namespace margelo::nitro::nitroark {
|
|
26
28
|
|
|
@@ -31,10 +33,11 @@ namespace margelo::nitro::nitroark {
|
|
|
31
33
|
public:
|
|
32
34
|
std::string bolt11_invoice SWIFT_PRIVATE;
|
|
33
35
|
std::string preimage SWIFT_PRIVATE;
|
|
36
|
+
PaymentTypes payment_type SWIFT_PRIVATE;
|
|
34
37
|
|
|
35
38
|
public:
|
|
36
39
|
Bolt11PaymentResult() = default;
|
|
37
|
-
explicit Bolt11PaymentResult(std::string bolt11_invoice, std::string preimage): bolt11_invoice(bolt11_invoice), preimage(preimage) {}
|
|
40
|
+
explicit Bolt11PaymentResult(std::string bolt11_invoice, std::string preimage, PaymentTypes payment_type): bolt11_invoice(bolt11_invoice), preimage(preimage), payment_type(payment_type) {}
|
|
38
41
|
};
|
|
39
42
|
|
|
40
43
|
} // namespace margelo::nitro::nitroark
|
|
@@ -50,13 +53,15 @@ namespace margelo::nitro {
|
|
|
50
53
|
jsi::Object obj = arg.asObject(runtime);
|
|
51
54
|
return Bolt11PaymentResult(
|
|
52
55
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "bolt11_invoice")),
|
|
53
|
-
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "preimage"))
|
|
56
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "preimage")),
|
|
57
|
+
JSIConverter<PaymentTypes>::fromJSI(runtime, obj.getProperty(runtime, "payment_type"))
|
|
54
58
|
);
|
|
55
59
|
}
|
|
56
60
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const Bolt11PaymentResult& arg) {
|
|
57
61
|
jsi::Object obj(runtime);
|
|
58
62
|
obj.setProperty(runtime, "bolt11_invoice", JSIConverter<std::string>::toJSI(runtime, arg.bolt11_invoice));
|
|
59
63
|
obj.setProperty(runtime, "preimage", JSIConverter<std::string>::toJSI(runtime, arg.preimage));
|
|
64
|
+
obj.setProperty(runtime, "payment_type", JSIConverter<PaymentTypes>::toJSI(runtime, arg.payment_type));
|
|
60
65
|
return obj;
|
|
61
66
|
}
|
|
62
67
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -66,6 +71,7 @@ namespace margelo::nitro {
|
|
|
66
71
|
jsi::Object obj = value.getObject(runtime);
|
|
67
72
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "bolt11_invoice"))) return false;
|
|
68
73
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "preimage"))) return false;
|
|
74
|
+
if (!JSIConverter<PaymentTypes>::canConvert(runtime, obj.getProperty(runtime, "payment_type"))) return false;
|
|
69
75
|
return true;
|
|
70
76
|
}
|
|
71
77
|
};
|
|
@@ -18,9 +18,11 @@
|
|
|
18
18
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
19
|
#endif
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
// Forward declaration of `PaymentTypes` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::nitroark { enum class PaymentTypes; }
|
|
22
23
|
|
|
23
24
|
#include <string>
|
|
25
|
+
#include "PaymentTypes.hpp"
|
|
24
26
|
|
|
25
27
|
namespace margelo::nitro::nitroark {
|
|
26
28
|
|
|
@@ -32,10 +34,11 @@ namespace margelo::nitro::nitroark {
|
|
|
32
34
|
std::string lnurl SWIFT_PRIVATE;
|
|
33
35
|
std::string bolt11_invoice SWIFT_PRIVATE;
|
|
34
36
|
std::string preimage SWIFT_PRIVATE;
|
|
37
|
+
PaymentTypes payment_type SWIFT_PRIVATE;
|
|
35
38
|
|
|
36
39
|
public:
|
|
37
40
|
LnurlPaymentResult() = default;
|
|
38
|
-
explicit LnurlPaymentResult(std::string lnurl, std::string bolt11_invoice, std::string preimage): lnurl(lnurl), bolt11_invoice(bolt11_invoice), preimage(preimage) {}
|
|
41
|
+
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) {}
|
|
39
42
|
};
|
|
40
43
|
|
|
41
44
|
} // namespace margelo::nitro::nitroark
|
|
@@ -52,7 +55,8 @@ namespace margelo::nitro {
|
|
|
52
55
|
return LnurlPaymentResult(
|
|
53
56
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "lnurl")),
|
|
54
57
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "bolt11_invoice")),
|
|
55
|
-
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "preimage"))
|
|
58
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "preimage")),
|
|
59
|
+
JSIConverter<PaymentTypes>::fromJSI(runtime, obj.getProperty(runtime, "payment_type"))
|
|
56
60
|
);
|
|
57
61
|
}
|
|
58
62
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const LnurlPaymentResult& arg) {
|
|
@@ -60,6 +64,7 @@ namespace margelo::nitro {
|
|
|
60
64
|
obj.setProperty(runtime, "lnurl", JSIConverter<std::string>::toJSI(runtime, arg.lnurl));
|
|
61
65
|
obj.setProperty(runtime, "bolt11_invoice", JSIConverter<std::string>::toJSI(runtime, arg.bolt11_invoice));
|
|
62
66
|
obj.setProperty(runtime, "preimage", JSIConverter<std::string>::toJSI(runtime, arg.preimage));
|
|
67
|
+
obj.setProperty(runtime, "payment_type", JSIConverter<PaymentTypes>::toJSI(runtime, arg.payment_type));
|
|
63
68
|
return obj;
|
|
64
69
|
}
|
|
65
70
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -70,6 +75,7 @@ namespace margelo::nitro {
|
|
|
70
75
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "lnurl"))) return false;
|
|
71
76
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "bolt11_invoice"))) return false;
|
|
72
77
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "preimage"))) return false;
|
|
78
|
+
if (!JSIConverter<PaymentTypes>::canConvert(runtime, obj.getProperty(runtime, "payment_type"))) return false;
|
|
73
79
|
return true;
|
|
74
80
|
}
|
|
75
81
|
};
|
|
@@ -18,9 +18,11 @@
|
|
|
18
18
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
19
|
#endif
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
// Forward declaration of `PaymentTypes` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::nitroark { enum class PaymentTypes; }
|
|
22
23
|
|
|
23
24
|
#include <string>
|
|
25
|
+
#include "PaymentTypes.hpp"
|
|
24
26
|
|
|
25
27
|
namespace margelo::nitro::nitroark {
|
|
26
28
|
|
|
@@ -32,10 +34,11 @@ namespace margelo::nitro::nitroark {
|
|
|
32
34
|
std::string txid SWIFT_PRIVATE;
|
|
33
35
|
double amount_sat SWIFT_PRIVATE;
|
|
34
36
|
std::string destination_address SWIFT_PRIVATE;
|
|
37
|
+
PaymentTypes payment_type SWIFT_PRIVATE;
|
|
35
38
|
|
|
36
39
|
public:
|
|
37
40
|
OnchainPaymentResult() = default;
|
|
38
|
-
explicit OnchainPaymentResult(std::string txid, double amount_sat, std::string destination_address): txid(txid), amount_sat(amount_sat), destination_address(destination_address) {}
|
|
41
|
+
explicit OnchainPaymentResult(std::string txid, double amount_sat, std::string destination_address, PaymentTypes payment_type): txid(txid), amount_sat(amount_sat), destination_address(destination_address), payment_type(payment_type) {}
|
|
39
42
|
};
|
|
40
43
|
|
|
41
44
|
} // namespace margelo::nitro::nitroark
|
|
@@ -52,7 +55,8 @@ namespace margelo::nitro {
|
|
|
52
55
|
return OnchainPaymentResult(
|
|
53
56
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "txid")),
|
|
54
57
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "amount_sat")),
|
|
55
|
-
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "destination_address"))
|
|
58
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "destination_address")),
|
|
59
|
+
JSIConverter<PaymentTypes>::fromJSI(runtime, obj.getProperty(runtime, "payment_type"))
|
|
56
60
|
);
|
|
57
61
|
}
|
|
58
62
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const OnchainPaymentResult& arg) {
|
|
@@ -60,6 +64,7 @@ namespace margelo::nitro {
|
|
|
60
64
|
obj.setProperty(runtime, "txid", JSIConverter<std::string>::toJSI(runtime, arg.txid));
|
|
61
65
|
obj.setProperty(runtime, "amount_sat", JSIConverter<double>::toJSI(runtime, arg.amount_sat));
|
|
62
66
|
obj.setProperty(runtime, "destination_address", JSIConverter<std::string>::toJSI(runtime, arg.destination_address));
|
|
67
|
+
obj.setProperty(runtime, "payment_type", JSIConverter<PaymentTypes>::toJSI(runtime, arg.payment_type));
|
|
63
68
|
return obj;
|
|
64
69
|
}
|
|
65
70
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -70,6 +75,7 @@ namespace margelo::nitro {
|
|
|
70
75
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "txid"))) return false;
|
|
71
76
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "amount_sat"))) return false;
|
|
72
77
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "destination_address"))) return false;
|
|
78
|
+
if (!JSIConverter<PaymentTypes>::canConvert(runtime, obj.getProperty(runtime, "payment_type"))) return false;
|
|
73
79
|
return true;
|
|
74
80
|
}
|
|
75
81
|
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PaymentTypes.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/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::nitroark {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (PaymentTypes).
|
|
30
|
+
*/
|
|
31
|
+
enum class PaymentTypes {
|
|
32
|
+
BOLT11 SWIFT_NAME(bolt11) = 0,
|
|
33
|
+
LNURL SWIFT_NAME(lnurl) = 1,
|
|
34
|
+
ARKOOR SWIFT_NAME(arkoor) = 2,
|
|
35
|
+
ONCHAIN SWIFT_NAME(onchain) = 3,
|
|
36
|
+
} CLOSED_ENUM;
|
|
37
|
+
|
|
38
|
+
} // namespace margelo::nitro::nitroark
|
|
39
|
+
|
|
40
|
+
namespace margelo::nitro {
|
|
41
|
+
|
|
42
|
+
using namespace margelo::nitro::nitroark;
|
|
43
|
+
|
|
44
|
+
// C++ PaymentTypes <> JS PaymentTypes (union)
|
|
45
|
+
template <>
|
|
46
|
+
struct JSIConverter<PaymentTypes> final {
|
|
47
|
+
static inline PaymentTypes fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
48
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
49
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
50
|
+
case hashString("Bolt11"): return PaymentTypes::BOLT11;
|
|
51
|
+
case hashString("Lnurl"): return PaymentTypes::LNURL;
|
|
52
|
+
case hashString("Arkoor"): return PaymentTypes::ARKOOR;
|
|
53
|
+
case hashString("Onchain"): return PaymentTypes::ONCHAIN;
|
|
54
|
+
default: [[unlikely]]
|
|
55
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum PaymentTypes - invalid value!");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, PaymentTypes arg) {
|
|
59
|
+
switch (arg) {
|
|
60
|
+
case PaymentTypes::BOLT11: return JSIConverter<std::string>::toJSI(runtime, "Bolt11");
|
|
61
|
+
case PaymentTypes::LNURL: return JSIConverter<std::string>::toJSI(runtime, "Lnurl");
|
|
62
|
+
case PaymentTypes::ARKOOR: return JSIConverter<std::string>::toJSI(runtime, "Arkoor");
|
|
63
|
+
case PaymentTypes::ONCHAIN: return JSIConverter<std::string>::toJSI(runtime, "Onchain");
|
|
64
|
+
default: [[unlikely]]
|
|
65
|
+
throw std::invalid_argument("Cannot convert PaymentTypes to JS - invalid value: "
|
|
66
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
70
|
+
if (!value.isString()) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
74
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
75
|
+
case hashString("Bolt11"):
|
|
76
|
+
case hashString("Lnurl"):
|
|
77
|
+
case hashString("Arkoor"):
|
|
78
|
+
case hashString("Onchain"):
|
|
79
|
+
return true;
|
|
80
|
+
default:
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
} // namespace margelo::nitro
|
package/package.json
CHANGED
package/src/NitroArk.nitro.ts
CHANGED
|
@@ -47,27 +47,33 @@ export interface BarkVtxo {
|
|
|
47
47
|
anchor_point: string;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
export type PaymentTypes = 'Bolt11' | 'Lnurl' | 'Arkoor' | 'Onchain';
|
|
51
|
+
|
|
50
52
|
export interface ArkoorPaymentResult {
|
|
51
53
|
amount_sat: number; // u64
|
|
52
54
|
destination_pubkey: string;
|
|
53
55
|
vtxos: BarkVtxo[];
|
|
56
|
+
payment_type: PaymentTypes; // 'Arkoor'
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
export interface Bolt11PaymentResult {
|
|
57
60
|
bolt11_invoice: string;
|
|
58
61
|
preimage: string;
|
|
62
|
+
payment_type: PaymentTypes; // 'Bolt11'
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
export interface LnurlPaymentResult {
|
|
62
66
|
lnurl: string;
|
|
63
67
|
bolt11_invoice: string;
|
|
64
68
|
preimage: string;
|
|
69
|
+
payment_type: PaymentTypes; // 'Lnurl'
|
|
65
70
|
}
|
|
66
71
|
|
|
67
72
|
export interface OnchainPaymentResult {
|
|
68
73
|
txid: string; // Transaction ID
|
|
69
74
|
amount_sat: number; // Amount in satoshis
|
|
70
75
|
destination_address: string; // Destination address
|
|
76
|
+
payment_type: PaymentTypes; // 'Onchain'
|
|
71
77
|
}
|
|
72
78
|
|
|
73
79
|
// --- Nitro Module Interface ---
|