react-native-nitro-ark 0.0.79 → 0.0.81
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/android/src/main/jniLibs/arm64-v8a/libcxxbridge1.a +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libcxxbridge1.a +0 -0
- package/android/src/main/jniLibs/x86_64/libcxxbridge1.a +0 -0
- package/cpp/NitroArk.hpp +85 -55
- package/cpp/generated/ark_cxx.h +21 -55
- package/lib/module/index.js +31 -8
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NitroArk.nitro.d.ts +16 -26
- package/lib/typescript/src/NitroArk.nitro.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +32 -11
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/nitrogen/generated/shared/c++/ArkoorPaymentResult.hpp +2 -9
- package/nitrogen/generated/shared/c++/BarkArkInfo.hpp +1 -5
- package/nitrogen/generated/shared/c++/BarkMovementDestination.hpp +5 -1
- package/nitrogen/generated/shared/c++/BoardResult.hpp +6 -8
- package/nitrogen/generated/shared/c++/HybridNitroArkSpec.cpp +4 -2
- package/nitrogen/generated/shared/c++/HybridNitroArkSpec.hpp +12 -14
- package/nitrogen/generated/shared/c++/LightningSendResult.hpp +101 -0
- package/nitrogen/generated/shared/c++/OffchainBalanceResult.hpp +3 -8
- package/nitrogen/generated/shared/c++/OnchainPaymentResult.hpp +3 -9
- package/package.json +4 -4
- package/src/NitroArk.nitro.ts +19 -29
- package/src/index.tsx +52 -17
- package/nitrogen/generated/shared/c++/Bolt11PaymentResult.hpp +0 -85
- package/nitrogen/generated/shared/c++/Bolt12PaymentResult.hpp +0 -85
- package/nitrogen/generated/shared/c++/LightningReceiveBalance.hpp +0 -79
- package/nitrogen/generated/shared/c++/LnurlPaymentResult.hpp +0 -89
- package/nitrogen/generated/shared/c++/PaymentTypes.hpp +0 -88
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// LightningSendResult.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 `BarkVtxo` to properly resolve imports.
|
|
27
|
+
namespace margelo::nitro::nitroark { struct BarkVtxo; }
|
|
28
|
+
|
|
29
|
+
#include <string>
|
|
30
|
+
#include "BarkVtxo.hpp"
|
|
31
|
+
#include <vector>
|
|
32
|
+
#include <NitroModules/Null.hpp>
|
|
33
|
+
#include <variant>
|
|
34
|
+
#include <optional>
|
|
35
|
+
|
|
36
|
+
namespace margelo::nitro::nitroark {
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A struct which can be represented as a JavaScript object (LightningSendResult).
|
|
40
|
+
*/
|
|
41
|
+
struct LightningSendResult {
|
|
42
|
+
public:
|
|
43
|
+
std::string invoice SWIFT_PRIVATE;
|
|
44
|
+
std::string payment_hash SWIFT_PRIVATE;
|
|
45
|
+
double amount SWIFT_PRIVATE;
|
|
46
|
+
std::vector<BarkVtxo> htlc_vtxos SWIFT_PRIVATE;
|
|
47
|
+
double movement_id SWIFT_PRIVATE;
|
|
48
|
+
std::optional<std::variant<nitro::NullType, std::string>> preimage SWIFT_PRIVATE;
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
LightningSendResult() = default;
|
|
52
|
+
explicit LightningSendResult(std::string invoice, std::string payment_hash, double amount, std::vector<BarkVtxo> htlc_vtxos, double movement_id, std::optional<std::variant<nitro::NullType, std::string>> preimage): invoice(invoice), payment_hash(payment_hash), amount(amount), htlc_vtxos(htlc_vtxos), movement_id(movement_id), preimage(preimage) {}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
} // namespace margelo::nitro::nitroark
|
|
56
|
+
|
|
57
|
+
namespace margelo::nitro {
|
|
58
|
+
|
|
59
|
+
// C++ LightningSendResult <> JS LightningSendResult (object)
|
|
60
|
+
template <>
|
|
61
|
+
struct JSIConverter<margelo::nitro::nitroark::LightningSendResult> final {
|
|
62
|
+
static inline margelo::nitro::nitroark::LightningSendResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
63
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
64
|
+
return margelo::nitro::nitroark::LightningSendResult(
|
|
65
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "invoice")),
|
|
66
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "payment_hash")),
|
|
67
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "amount")),
|
|
68
|
+
JSIConverter<std::vector<margelo::nitro::nitroark::BarkVtxo>>::fromJSI(runtime, obj.getProperty(runtime, "htlc_vtxos")),
|
|
69
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "movement_id")),
|
|
70
|
+
JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, "preimage"))
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroark::LightningSendResult& arg) {
|
|
74
|
+
jsi::Object obj(runtime);
|
|
75
|
+
obj.setProperty(runtime, "invoice", JSIConverter<std::string>::toJSI(runtime, arg.invoice));
|
|
76
|
+
obj.setProperty(runtime, "payment_hash", JSIConverter<std::string>::toJSI(runtime, arg.payment_hash));
|
|
77
|
+
obj.setProperty(runtime, "amount", JSIConverter<double>::toJSI(runtime, arg.amount));
|
|
78
|
+
obj.setProperty(runtime, "htlc_vtxos", JSIConverter<std::vector<margelo::nitro::nitroark::BarkVtxo>>::toJSI(runtime, arg.htlc_vtxos));
|
|
79
|
+
obj.setProperty(runtime, "movement_id", JSIConverter<double>::toJSI(runtime, arg.movement_id));
|
|
80
|
+
obj.setProperty(runtime, "preimage", JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.preimage));
|
|
81
|
+
return obj;
|
|
82
|
+
}
|
|
83
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
84
|
+
if (!value.isObject()) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
jsi::Object obj = value.getObject(runtime);
|
|
88
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "invoice"))) return false;
|
|
92
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "payment_hash"))) return false;
|
|
93
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "amount"))) return false;
|
|
94
|
+
if (!JSIConverter<std::vector<margelo::nitro::nitroark::BarkVtxo>>::canConvert(runtime, obj.getProperty(runtime, "htlc_vtxos"))) return false;
|
|
95
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "movement_id"))) return false;
|
|
96
|
+
if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, "preimage"))) return false;
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
} // namespace margelo::nitro
|
|
@@ -23,10 +23,9 @@
|
|
|
23
23
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
24
|
#endif
|
|
25
25
|
|
|
26
|
-
// Forward declaration of `LightningReceiveBalance` to properly resolve imports.
|
|
27
|
-
namespace margelo::nitro::nitroark { struct LightningReceiveBalance; }
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
|
|
28
|
+
|
|
30
29
|
|
|
31
30
|
namespace margelo::nitro::nitroark {
|
|
32
31
|
|
|
@@ -37,14 +36,13 @@ namespace margelo::nitro::nitroark {
|
|
|
37
36
|
public:
|
|
38
37
|
double spendable SWIFT_PRIVATE;
|
|
39
38
|
double pending_lightning_send SWIFT_PRIVATE;
|
|
40
|
-
LightningReceiveBalance pending_lightning_receive SWIFT_PRIVATE;
|
|
41
39
|
double pending_in_round SWIFT_PRIVATE;
|
|
42
40
|
double pending_exit SWIFT_PRIVATE;
|
|
43
41
|
double pending_board SWIFT_PRIVATE;
|
|
44
42
|
|
|
45
43
|
public:
|
|
46
44
|
OffchainBalanceResult() = default;
|
|
47
|
-
explicit OffchainBalanceResult(double spendable, double pending_lightning_send,
|
|
45
|
+
explicit OffchainBalanceResult(double spendable, double pending_lightning_send, double pending_in_round, double pending_exit, double pending_board): spendable(spendable), pending_lightning_send(pending_lightning_send), pending_in_round(pending_in_round), pending_exit(pending_exit), pending_board(pending_board) {}
|
|
48
46
|
};
|
|
49
47
|
|
|
50
48
|
} // namespace margelo::nitro::nitroark
|
|
@@ -59,7 +57,6 @@ namespace margelo::nitro {
|
|
|
59
57
|
return margelo::nitro::nitroark::OffchainBalanceResult(
|
|
60
58
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "spendable")),
|
|
61
59
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "pending_lightning_send")),
|
|
62
|
-
JSIConverter<margelo::nitro::nitroark::LightningReceiveBalance>::fromJSI(runtime, obj.getProperty(runtime, "pending_lightning_receive")),
|
|
63
60
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "pending_in_round")),
|
|
64
61
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "pending_exit")),
|
|
65
62
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "pending_board"))
|
|
@@ -69,7 +66,6 @@ namespace margelo::nitro {
|
|
|
69
66
|
jsi::Object obj(runtime);
|
|
70
67
|
obj.setProperty(runtime, "spendable", JSIConverter<double>::toJSI(runtime, arg.spendable));
|
|
71
68
|
obj.setProperty(runtime, "pending_lightning_send", JSIConverter<double>::toJSI(runtime, arg.pending_lightning_send));
|
|
72
|
-
obj.setProperty(runtime, "pending_lightning_receive", JSIConverter<margelo::nitro::nitroark::LightningReceiveBalance>::toJSI(runtime, arg.pending_lightning_receive));
|
|
73
69
|
obj.setProperty(runtime, "pending_in_round", JSIConverter<double>::toJSI(runtime, arg.pending_in_round));
|
|
74
70
|
obj.setProperty(runtime, "pending_exit", JSIConverter<double>::toJSI(runtime, arg.pending_exit));
|
|
75
71
|
obj.setProperty(runtime, "pending_board", JSIConverter<double>::toJSI(runtime, arg.pending_board));
|
|
@@ -85,7 +81,6 @@ namespace margelo::nitro {
|
|
|
85
81
|
}
|
|
86
82
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "spendable"))) return false;
|
|
87
83
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "pending_lightning_send"))) return false;
|
|
88
|
-
if (!JSIConverter<margelo::nitro::nitroark::LightningReceiveBalance>::canConvert(runtime, obj.getProperty(runtime, "pending_lightning_receive"))) return false;
|
|
89
84
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "pending_in_round"))) return false;
|
|
90
85
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "pending_exit"))) return false;
|
|
91
86
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "pending_board"))) return false;
|
|
@@ -23,11 +23,9 @@
|
|
|
23
23
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
24
|
#endif
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
namespace margelo::nitro::nitroark { enum class PaymentTypes; }
|
|
26
|
+
|
|
28
27
|
|
|
29
28
|
#include <string>
|
|
30
|
-
#include "PaymentTypes.hpp"
|
|
31
29
|
|
|
32
30
|
namespace margelo::nitro::nitroark {
|
|
33
31
|
|
|
@@ -39,11 +37,10 @@ namespace margelo::nitro::nitroark {
|
|
|
39
37
|
std::string txid SWIFT_PRIVATE;
|
|
40
38
|
double amount_sat SWIFT_PRIVATE;
|
|
41
39
|
std::string destination_address SWIFT_PRIVATE;
|
|
42
|
-
PaymentTypes payment_type SWIFT_PRIVATE;
|
|
43
40
|
|
|
44
41
|
public:
|
|
45
42
|
OnchainPaymentResult() = default;
|
|
46
|
-
explicit OnchainPaymentResult(std::string txid, double amount_sat, std::string destination_address
|
|
43
|
+
explicit OnchainPaymentResult(std::string txid, double amount_sat, std::string destination_address): txid(txid), amount_sat(amount_sat), destination_address(destination_address) {}
|
|
47
44
|
};
|
|
48
45
|
|
|
49
46
|
} // namespace margelo::nitro::nitroark
|
|
@@ -58,8 +55,7 @@ namespace margelo::nitro {
|
|
|
58
55
|
return margelo::nitro::nitroark::OnchainPaymentResult(
|
|
59
56
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "txid")),
|
|
60
57
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "amount_sat")),
|
|
61
|
-
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "destination_address"))
|
|
62
|
-
JSIConverter<margelo::nitro::nitroark::PaymentTypes>::fromJSI(runtime, obj.getProperty(runtime, "payment_type"))
|
|
58
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "destination_address"))
|
|
63
59
|
);
|
|
64
60
|
}
|
|
65
61
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroark::OnchainPaymentResult& arg) {
|
|
@@ -67,7 +63,6 @@ namespace margelo::nitro {
|
|
|
67
63
|
obj.setProperty(runtime, "txid", JSIConverter<std::string>::toJSI(runtime, arg.txid));
|
|
68
64
|
obj.setProperty(runtime, "amount_sat", JSIConverter<double>::toJSI(runtime, arg.amount_sat));
|
|
69
65
|
obj.setProperty(runtime, "destination_address", JSIConverter<std::string>::toJSI(runtime, arg.destination_address));
|
|
70
|
-
obj.setProperty(runtime, "payment_type", JSIConverter<margelo::nitro::nitroark::PaymentTypes>::toJSI(runtime, arg.payment_type));
|
|
71
66
|
return obj;
|
|
72
67
|
}
|
|
73
68
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -81,7 +76,6 @@ namespace margelo::nitro {
|
|
|
81
76
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "txid"))) return false;
|
|
82
77
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "amount_sat"))) return false;
|
|
83
78
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "destination_address"))) return false;
|
|
84
|
-
if (!JSIConverter<margelo::nitro::nitroark::PaymentTypes>::canConvert(runtime, obj.getProperty(runtime, "payment_type"))) return false;
|
|
85
79
|
return true;
|
|
86
80
|
}
|
|
87
81
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-ark",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.81",
|
|
4
4
|
"description": "Pure C++ Nitro Modules for Ark client",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/module/index.js",
|
|
@@ -84,12 +84,12 @@
|
|
|
84
84
|
"eslint-config-prettier": "^10.1.1",
|
|
85
85
|
"eslint-plugin-prettier": "^5.2.3",
|
|
86
86
|
"jest": "^29.7.0",
|
|
87
|
-
"nitrogen": "^0.31.
|
|
87
|
+
"nitrogen": "^0.31.10",
|
|
88
88
|
"prettier": "^3.0.3",
|
|
89
89
|
"react": "19.1.0",
|
|
90
90
|
"react-native": "0.81.4",
|
|
91
91
|
"react-native-builder-bob": "^0.40.13",
|
|
92
|
-
"react-native-nitro-modules": "^0.31.
|
|
92
|
+
"react-native-nitro-modules": "^0.31.10",
|
|
93
93
|
"release-it": "^17.10.0",
|
|
94
94
|
"turbo": "^1.10.7",
|
|
95
95
|
"typescript": "^5.2.2"
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"peerDependencies": {
|
|
98
98
|
"react": "*",
|
|
99
99
|
"react-native": "*",
|
|
100
|
-
"react-native-nitro-modules": "^0.31.
|
|
100
|
+
"react-native-nitro-modules": "^0.31.10"
|
|
101
101
|
},
|
|
102
102
|
"workspaces": [
|
|
103
103
|
"example"
|
package/src/NitroArk.nitro.ts
CHANGED
|
@@ -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:
|
|
60
|
+
vtxos: string[];
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
export interface Bolt11Invoice {
|
|
@@ -67,39 +66,25 @@ export interface Bolt11Invoice {
|
|
|
67
66
|
payment_hash: string;
|
|
68
67
|
}
|
|
69
68
|
|
|
70
|
-
export type PaymentTypes = 'Bolt11' | 'Bolt12' | 'Lnurl' | 'Arkoor' | 'Onchain';
|
|
71
|
-
|
|
72
69
|
export interface ArkoorPaymentResult {
|
|
73
70
|
amount_sat: number; // u64
|
|
74
71
|
destination_pubkey: string;
|
|
75
72
|
vtxos: BarkVtxo[];
|
|
76
|
-
payment_type: PaymentTypes; // 'Arkoor'
|
|
77
|
-
}
|
|
78
|
-
|
|
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
73
|
}
|
|
90
74
|
|
|
91
|
-
export interface
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
75
|
+
export interface LightningSendResult {
|
|
76
|
+
invoice: string;
|
|
77
|
+
payment_hash: string;
|
|
78
|
+
amount: number; // u64
|
|
79
|
+
htlc_vtxos: BarkVtxo[];
|
|
80
|
+
movement_id: number; // u32
|
|
81
|
+
preimage: string | null;
|
|
96
82
|
}
|
|
97
83
|
|
|
98
84
|
export interface OnchainPaymentResult {
|
|
99
85
|
txid: string; // Transaction ID
|
|
100
86
|
amount_sat: number; // Amount in satoshis
|
|
101
87
|
destination_address: string; // Destination address
|
|
102
|
-
payment_type: PaymentTypes; // 'Onchain'
|
|
103
88
|
}
|
|
104
89
|
|
|
105
90
|
export interface LightningReceiveBalance {
|
|
@@ -112,7 +97,6 @@ export interface LightningReceiveBalance {
|
|
|
112
97
|
export interface OffchainBalanceResult {
|
|
113
98
|
spendable: number; // u64
|
|
114
99
|
pending_lightning_send: number; // u64
|
|
115
|
-
pending_lightning_receive: LightningReceiveBalance;
|
|
116
100
|
pending_in_round: number; // u64
|
|
117
101
|
pending_exit: number; // u64
|
|
118
102
|
pending_board: number; // u64
|
|
@@ -154,6 +138,7 @@ export interface BarkMovementSubsystem {
|
|
|
154
138
|
|
|
155
139
|
export interface BarkMovementDestination {
|
|
156
140
|
destination: string;
|
|
141
|
+
payment_method: string;
|
|
157
142
|
amount_sat: number;
|
|
158
143
|
}
|
|
159
144
|
|
|
@@ -200,13 +185,14 @@ export interface NitroArk extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
|
200
185
|
loadWallet(datadir: string, config: BarkCreateOpts): Promise<void>;
|
|
201
186
|
isWalletLoaded(): Promise<boolean>;
|
|
202
187
|
closeWallet(): Promise<void>;
|
|
203
|
-
|
|
188
|
+
refreshServer(): Promise<void>;
|
|
204
189
|
syncPendingBoards(): Promise<void>;
|
|
205
190
|
maintenance(): Promise<void>;
|
|
206
191
|
maintenanceWithOnchain(): Promise<void>;
|
|
207
192
|
maintenanceRefresh(): Promise<void>;
|
|
208
193
|
sync(): Promise<void>;
|
|
209
194
|
syncExits(): Promise<void>;
|
|
195
|
+
syncPendingRounds(): Promise<void>;
|
|
210
196
|
|
|
211
197
|
// --- Wallet Info ---
|
|
212
198
|
getArkInfo(): Promise<BarkArkInfo>;
|
|
@@ -232,7 +218,7 @@ export interface NitroArk extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
|
232
218
|
signature: string,
|
|
233
219
|
publicKey: string
|
|
234
220
|
): Promise<boolean>;
|
|
235
|
-
|
|
221
|
+
history(): Promise<BarkMovement[]>;
|
|
236
222
|
vtxos(): Promise<BarkVtxo[]>;
|
|
237
223
|
getFirstExpiringVtxoBlockheight(): Promise<number | undefined>;
|
|
238
224
|
getNextRequiredRefreshBlockheight(): Promise<number | undefined>;
|
|
@@ -272,16 +258,16 @@ export interface NitroArk extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
|
272
258
|
payLightningInvoice(
|
|
273
259
|
destination: string,
|
|
274
260
|
amountSat?: number
|
|
275
|
-
): Promise<
|
|
261
|
+
): Promise<LightningSendResult>;
|
|
276
262
|
payLightningOffer(
|
|
277
263
|
offer: string,
|
|
278
264
|
amountSat?: number
|
|
279
|
-
): Promise<
|
|
265
|
+
): Promise<LightningSendResult>;
|
|
280
266
|
payLightningAddress(
|
|
281
267
|
addr: string,
|
|
282
268
|
amountSat: number,
|
|
283
269
|
comment: string
|
|
284
|
-
): Promise<
|
|
270
|
+
): Promise<LightningSendResult>;
|
|
285
271
|
sendRoundOnchainPayment(
|
|
286
272
|
destination: string,
|
|
287
273
|
amountSat: number
|
|
@@ -292,6 +278,10 @@ export interface NitroArk extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
|
292
278
|
lightningReceiveStatus(
|
|
293
279
|
paymentHash: string
|
|
294
280
|
): Promise<LightningReceive | undefined>;
|
|
281
|
+
checkLightningPayment(
|
|
282
|
+
paymentHash: string,
|
|
283
|
+
wait: boolean
|
|
284
|
+
): Promise<string | null>;
|
|
295
285
|
tryClaimLightningReceive(
|
|
296
286
|
paymentHash: string,
|
|
297
287
|
wait: boolean,
|
package/src/index.tsx
CHANGED
|
@@ -6,9 +6,7 @@ import type {
|
|
|
6
6
|
Bolt11Invoice,
|
|
7
7
|
BarkSendManyOutput,
|
|
8
8
|
ArkoorPaymentResult,
|
|
9
|
-
|
|
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
|
-
|
|
89
|
-
|
|
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
|
|
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
|
|
274
|
-
return NitroArkHybridObject.
|
|
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
|
|
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<
|
|
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
|
|
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<
|
|
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
|
|
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<
|
|
515
|
+
): Promise<LightningSendResult> {
|
|
479
516
|
return NitroArkHybridObject.payLightningAddress(addr, amountSat, comment);
|
|
480
517
|
}
|
|
481
518
|
|
|
@@ -567,10 +604,8 @@ export type {
|
|
|
567
604
|
BoardResult,
|
|
568
605
|
BarkSendManyOutput,
|
|
569
606
|
ArkoorPaymentResult,
|
|
570
|
-
|
|
571
|
-
LnurlPaymentResult,
|
|
607
|
+
LightningSendResult,
|
|
572
608
|
OnchainPaymentResult,
|
|
573
|
-
PaymentTypes,
|
|
574
609
|
OffchainBalanceResult,
|
|
575
610
|
OnchainBalanceResult,
|
|
576
611
|
NewAddressResult,
|
|
@@ -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
|