react-native-nitro-ark 0.0.132 → 0.0.134
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/cpp/NitroArkJni.cpp +22 -22
- package/android/src/main/java/com/margelo/nitro/nitroark/NitroArkNative.kt +12 -8
- 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 +106 -85
- package/cpp/generated/ark_cxx.h +18 -10
- package/lib/module/index.js +102 -39
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NitroArk.nitro.d.ts +26 -8
- package/lib/typescript/src/NitroArk.nitro.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +90 -35
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/nitrogen/generated/shared/c++/BarkConfigOpts.hpp +1 -5
- package/nitrogen/generated/shared/c++/HybridNitroArkSpec.cpp +3 -2
- package/nitrogen/generated/shared/c++/HybridNitroArkSpec.hpp +9 -5
- package/nitrogen/generated/shared/c++/LightningPaymentOrigin.hpp +89 -0
- package/nitrogen/generated/shared/c++/LightningPaymentOriginMethod.hpp +80 -0
- package/nitrogen/generated/shared/c++/LightningReceive.hpp +26 -9
- package/package.json +3 -2
- package/src/NitroArk.nitro.ts +36 -11
- package/src/index.tsx +185 -51
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#include <cstdint>
|
|
3
3
|
#include <exception>
|
|
4
4
|
#include <jni.h>
|
|
5
|
+
#include <memory>
|
|
5
6
|
#include <optional>
|
|
6
7
|
#include <stdexcept>
|
|
7
8
|
#include <string>
|
|
@@ -226,8 +227,8 @@ JNIEXPORT void JNICALL Java_com_margelo_nitro_nitroark_NitroArkNative_closeWalle
|
|
|
226
227
|
|
|
227
228
|
JNIEXPORT void JNICALL Java_com_margelo_nitro_nitroark_NitroArkNative_loadWalletNative(
|
|
228
229
|
JNIEnv* env, jobject /*thiz*/, jstring jDatadir, jstring jMnemonic, jboolean jRegtest, jboolean jSignet,
|
|
229
|
-
jboolean jBitcoin, jobject jBirthdayHeight, jstring jArk, jstring
|
|
230
|
-
jstring
|
|
230
|
+
jboolean jBitcoin, jobject jBirthdayHeight, jstring jArk, jstring jUserAgent, jstring jEsplora, jstring jBitcoind,
|
|
231
|
+
jstring jBitcoindCookie, jstring jBitcoindUser, jstring jBitcoindPass,
|
|
231
232
|
jint jVtxoRefreshExpiryThreshold, jlong jFallbackFeeRate, jobject jHtlcRecvClaimDelta, jobject jVtxoExitMargin,
|
|
232
233
|
jobject jRoundTxRequiredConfirmations) {
|
|
233
234
|
try {
|
|
@@ -251,7 +252,7 @@ JNIEXPORT void JNICALL Java_com_margelo_nitro_nitroark_NitroArkNative_loadWallet
|
|
|
251
252
|
|
|
252
253
|
bark_cxx::ConfigOpts config{};
|
|
253
254
|
config.ark = JStringToString(env, jArk);
|
|
254
|
-
config.
|
|
255
|
+
config.user_agent = JStringToString(env, jUserAgent);
|
|
255
256
|
config.esplora = JStringToString(env, jEsplora);
|
|
256
257
|
config.bitcoind = JStringToString(env, jBitcoind);
|
|
257
258
|
config.bitcoind_cookie = JStringToString(env, jBitcoindCookie);
|
|
@@ -284,10 +285,10 @@ JNIEXPORT void JNICALL Java_com_margelo_nitro_nitroark_NitroArkNative_loadWallet
|
|
|
284
285
|
}
|
|
285
286
|
}
|
|
286
287
|
|
|
287
|
-
JNIEXPORT void JNICALL
|
|
288
|
-
|
|
288
|
+
JNIEXPORT void JNICALL Java_com_margelo_nitro_nitroark_NitroArkNative_maintenance(JNIEnv* env,
|
|
289
|
+
jobject /*thiz*/) {
|
|
289
290
|
try {
|
|
290
|
-
bark_cxx::
|
|
291
|
+
bark_cxx::maintenance();
|
|
291
292
|
} catch (const std::exception& e) {
|
|
292
293
|
HandleException(env, e);
|
|
293
294
|
} catch (...) {
|
|
@@ -295,10 +296,10 @@ JNIEXPORT void JNICALL Java_com_margelo_nitro_nitroark_NitroArkNative_maintenanc
|
|
|
295
296
|
}
|
|
296
297
|
}
|
|
297
298
|
|
|
298
|
-
JNIEXPORT void JNICALL
|
|
299
|
-
|
|
299
|
+
JNIEXPORT void JNICALL Java_com_margelo_nitro_nitroark_NitroArkNative_maintenanceDelegated(JNIEnv* env,
|
|
300
|
+
jobject /*thiz*/) {
|
|
300
301
|
try {
|
|
301
|
-
bark_cxx::
|
|
302
|
+
bark_cxx::maintenance_delegated();
|
|
302
303
|
} catch (const std::exception& e) {
|
|
303
304
|
HandleException(env, e);
|
|
304
305
|
} catch (...) {
|
|
@@ -307,16 +308,11 @@ JNIEXPORT void JNICALL Java_com_margelo_nitro_nitroark_NitroArkNative_maintenanc
|
|
|
307
308
|
}
|
|
308
309
|
|
|
309
310
|
JNIEXPORT void JNICALL Java_com_margelo_nitro_nitroark_NitroArkNative_tryClaimLightningReceive(
|
|
310
|
-
JNIEnv* env, jobject /*thiz*/, jstring jPaymentHash, jboolean jWait
|
|
311
|
+
JNIEnv* env, jobject /*thiz*/, jstring jPaymentHash, jboolean jWait) {
|
|
311
312
|
try {
|
|
312
313
|
const std::string payment_hash = JStringToString(env, jPaymentHash);
|
|
313
|
-
const std::string token_str = JStringToString(env, jToken);
|
|
314
|
-
|
|
315
314
|
rust::String payment_hash_rs(payment_hash);
|
|
316
|
-
|
|
317
|
-
const rust::String* token_ptr = token_str.empty() ? nullptr : &token_rs;
|
|
318
|
-
|
|
319
|
-
bark_cxx::try_claim_lightning_receive(payment_hash_rs, jWait == JNI_TRUE, token_ptr);
|
|
315
|
+
bark_cxx::try_claim_lightning_receive(payment_hash_rs, jWait == JNI_TRUE);
|
|
320
316
|
} catch (const std::exception& e) {
|
|
321
317
|
HandleException(env, e);
|
|
322
318
|
} catch (...) {
|
|
@@ -359,15 +355,19 @@ JNIEXPORT jboolean JNICALL Java_com_margelo_nitro_nitroark_NitroArkNative_verify
|
|
|
359
355
|
JNIEXPORT jobject JNICALL Java_com_margelo_nitro_nitroark_NitroArkNative_bolt11InvoiceNative(JNIEnv* env,
|
|
360
356
|
jobject /*thiz*/,
|
|
361
357
|
jlong jAmountMsat,
|
|
362
|
-
jstring jDescription
|
|
358
|
+
jstring jDescription,
|
|
359
|
+
jstring jToken) {
|
|
363
360
|
try {
|
|
364
|
-
|
|
361
|
+
std::unique_ptr<rust::String> description;
|
|
362
|
+
std::unique_ptr<rust::String> token;
|
|
365
363
|
if (jDescription != nullptr) {
|
|
366
|
-
rust::String
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
364
|
+
description = std::make_unique<rust::String>(JStringToString(env, jDescription));
|
|
365
|
+
}
|
|
366
|
+
if (jToken != nullptr) {
|
|
367
|
+
token = std::make_unique<rust::String>(JStringToString(env, jToken));
|
|
370
368
|
}
|
|
369
|
+
const auto invoice =
|
|
370
|
+
bark_cxx::bolt11_invoice(static_cast<uint64_t>(jAmountMsat), description.get(), token.get());
|
|
371
371
|
return MakeBolt11Invoice(env, invoice);
|
|
372
372
|
} catch (const std::exception& e) {
|
|
373
373
|
HandleException(env, e);
|
|
@@ -11,7 +11,7 @@ object NitroArkNative {
|
|
|
11
11
|
val ark: String,
|
|
12
12
|
val vtxoRefreshExpiryThreshold: Int,
|
|
13
13
|
val fallbackFeeRate: Long,
|
|
14
|
-
val
|
|
14
|
+
val userAgent: String? = null,
|
|
15
15
|
val esplora: String? = null,
|
|
16
16
|
val bitcoind: String? = null,
|
|
17
17
|
val bitcoindCookie: String? = null,
|
|
@@ -48,7 +48,7 @@ object NitroArkNative {
|
|
|
48
48
|
bitcoin,
|
|
49
49
|
birthdayHeight,
|
|
50
50
|
config.ark,
|
|
51
|
-
config.
|
|
51
|
+
config.userAgent,
|
|
52
52
|
config.esplora,
|
|
53
53
|
config.bitcoind,
|
|
54
54
|
config.bitcoindCookie,
|
|
@@ -73,7 +73,7 @@ object NitroArkNative {
|
|
|
73
73
|
bitcoin: Boolean,
|
|
74
74
|
birthdayHeight: Int?,
|
|
75
75
|
ark: String,
|
|
76
|
-
|
|
76
|
+
userAgent: String?,
|
|
77
77
|
esplora: String?,
|
|
78
78
|
bitcoind: String?,
|
|
79
79
|
bitcoindCookie: String?,
|
|
@@ -88,19 +88,23 @@ object NitroArkNative {
|
|
|
88
88
|
|
|
89
89
|
// Additional helpers
|
|
90
90
|
external fun maintenance()
|
|
91
|
+
external fun maintenanceDelegated()
|
|
91
92
|
external fun maintenanceRefresh()
|
|
92
93
|
external fun tryClaimLightningReceive(
|
|
93
94
|
paymentHash: String,
|
|
94
|
-
wait: Boolean
|
|
95
|
-
token: String?
|
|
95
|
+
wait: Boolean
|
|
96
96
|
)
|
|
97
97
|
external fun offboardAll(destinationAddress: String): RoundStatusResult
|
|
98
98
|
external fun peekKeyPair(index: Int): KeyPairResultAndroid
|
|
99
99
|
external fun verifyMessage(message: String, signature: String, publicKey: String): Boolean
|
|
100
|
-
fun bolt11Invoice(amountMsat: Long, description: String? = null): Bolt11InvoiceResult =
|
|
101
|
-
bolt11InvoiceNative(amountMsat, description)
|
|
100
|
+
fun bolt11Invoice(amountMsat: Long, description: String? = null, token: String? = null): Bolt11InvoiceResult =
|
|
101
|
+
bolt11InvoiceNative(amountMsat, description, token)
|
|
102
102
|
|
|
103
|
-
private external fun bolt11InvoiceNative(
|
|
103
|
+
private external fun bolt11InvoiceNative(
|
|
104
|
+
amountMsat: Long,
|
|
105
|
+
description: String?,
|
|
106
|
+
token: String?
|
|
107
|
+
): Bolt11InvoiceResult
|
|
104
108
|
external fun signMessage(message: String, index: Int): String
|
|
105
109
|
external fun sync()
|
|
106
110
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/cpp/NitroArk.hpp
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
#include "HybridNitroArkSpec.hpp"
|
|
6
6
|
#include "generated/ark_cxx.h"
|
|
7
7
|
#include "generated/cxx.h"
|
|
8
|
+
#include <cmath>
|
|
9
|
+
#include <cstdint>
|
|
10
|
+
#include <limits>
|
|
8
11
|
#include <memory>
|
|
9
12
|
#include <mutex>
|
|
10
13
|
#include <optional>
|
|
@@ -16,6 +19,19 @@
|
|
|
16
19
|
namespace margelo::nitro::nitroark {
|
|
17
20
|
|
|
18
21
|
using namespace margelo::nitro;
|
|
22
|
+
|
|
23
|
+
inline std::string lightningPaymentOriginMethodToString(LightningPaymentOriginMethod method) {
|
|
24
|
+
switch (method) {
|
|
25
|
+
case LightningPaymentOriginMethod::LIGHTNING_ADDRESS:
|
|
26
|
+
return "lightning-address";
|
|
27
|
+
case LightningPaymentOriginMethod::LNURL:
|
|
28
|
+
return "lnurl";
|
|
29
|
+
case LightningPaymentOriginMethod::CUSTOM:
|
|
30
|
+
return "custom";
|
|
31
|
+
}
|
|
32
|
+
throw std::invalid_argument("Unsupported Lightning payment origin method");
|
|
33
|
+
}
|
|
34
|
+
|
|
19
35
|
// Helper functions to convert rust vtxos to C++ values
|
|
20
36
|
inline BarkVtxo convertRustVtxo(const bark_cxx::BarkVtxo& vtxo_rs) {
|
|
21
37
|
BarkVtxo vtxo;
|
|
@@ -87,6 +103,32 @@ inline LightningPaymentResult convertRustLightningPaymentResult(const bark_cxx::
|
|
|
87
103
|
return result;
|
|
88
104
|
}
|
|
89
105
|
|
|
106
|
+
inline LightningReceive convertRustLightningReceive(const bark_cxx::LightningReceive& rust_result) {
|
|
107
|
+
LightningReceive result;
|
|
108
|
+
result.state = std::string(rust_result.state.data(), rust_result.state.length());
|
|
109
|
+
if (!rust_result.phase.empty()) {
|
|
110
|
+
result.phase = std::string(rust_result.phase.data(), rust_result.phase.length());
|
|
111
|
+
}
|
|
112
|
+
result.payment_hash = std::string(rust_result.payment_hash.data(), rust_result.payment_hash.length());
|
|
113
|
+
result.payment_preimage =
|
|
114
|
+
std::string(rust_result.payment_preimage.data(), rust_result.payment_preimage.length());
|
|
115
|
+
result.invoice = std::string(rust_result.invoice.data(), rust_result.invoice.length());
|
|
116
|
+
result.htlc_vtxo_ids.reserve(rust_result.htlc_vtxo_ids.size());
|
|
117
|
+
for (const auto& id : rust_result.htlc_vtxo_ids) {
|
|
118
|
+
result.htlc_vtxo_ids.emplace_back(std::string(id.data(), id.length()));
|
|
119
|
+
}
|
|
120
|
+
if (rust_result.has_movement_id) {
|
|
121
|
+
result.movement_id = static_cast<double>(rust_result.movement_id);
|
|
122
|
+
}
|
|
123
|
+
if (rust_result.has_amount_sat) {
|
|
124
|
+
result.amount_sat = static_cast<double>(rust_result.amount_sat);
|
|
125
|
+
}
|
|
126
|
+
if (rust_result.has_settled_at) {
|
|
127
|
+
result.settled_at = static_cast<double>(rust_result.settled_at);
|
|
128
|
+
}
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
|
|
90
132
|
inline ExitBlockRefResult convertRustExitBlockRef(const bark_cxx::ExitBlockRefResult& block_rs) {
|
|
91
133
|
ExitBlockRefResult block;
|
|
92
134
|
block.height = static_cast<double>(block_rs.height);
|
|
@@ -342,7 +384,6 @@ private:
|
|
|
342
384
|
bark_cxx::ConfigOpts config_opts;
|
|
343
385
|
if (config.has_value()) {
|
|
344
386
|
config_opts.ark = config->ark;
|
|
345
|
-
config_opts.server_access_token = config->server_access_token.value_or("");
|
|
346
387
|
config_opts.user_agent = config->user_agent.value_or("");
|
|
347
388
|
config_opts.esplora = config->esplora.value_or("");
|
|
348
389
|
config_opts.bitcoind = config->bitcoind.value_or("");
|
|
@@ -530,16 +571,6 @@ public:
|
|
|
530
571
|
});
|
|
531
572
|
}
|
|
532
573
|
|
|
533
|
-
std::shared_ptr<Promise<void>> maintenanceWithOnchain() override {
|
|
534
|
-
return Promise<void>::async([]() {
|
|
535
|
-
try {
|
|
536
|
-
bark_cxx::maintenance_with_onchain();
|
|
537
|
-
} catch (const rust::Error& e) {
|
|
538
|
-
throw std::runtime_error(e.what());
|
|
539
|
-
}
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
|
|
543
574
|
std::shared_ptr<Promise<void>> maintenanceDelegated() override {
|
|
544
575
|
return Promise<void>::async([]() {
|
|
545
576
|
try {
|
|
@@ -550,16 +581,6 @@ public:
|
|
|
550
581
|
});
|
|
551
582
|
}
|
|
552
583
|
|
|
553
|
-
std::shared_ptr<Promise<void>> maintenanceWithOnchainDelegated() override {
|
|
554
|
-
return Promise<void>::async([]() {
|
|
555
|
-
try {
|
|
556
|
-
bark_cxx::maintenance_with_onchain_delegated();
|
|
557
|
-
} catch (const rust::Error& e) {
|
|
558
|
-
throw std::runtime_error(e.what());
|
|
559
|
-
}
|
|
560
|
-
});
|
|
561
|
-
}
|
|
562
|
-
|
|
563
584
|
std::shared_ptr<Promise<void>> maintenanceRefresh() override {
|
|
564
585
|
return Promise<void>::async([]() {
|
|
565
586
|
try {
|
|
@@ -1066,6 +1087,21 @@ public:
|
|
|
1066
1087
|
});
|
|
1067
1088
|
}
|
|
1068
1089
|
|
|
1090
|
+
std::shared_ptr<Promise<void>> updateHistoryMetadata(double movementId, const std::string& patchJson) override {
|
|
1091
|
+
return Promise<void>::async([movementId, patchJson]() {
|
|
1092
|
+
if (!std::isfinite(movementId) || std::trunc(movementId) != movementId || movementId < 0 ||
|
|
1093
|
+
movementId > static_cast<double>(std::numeric_limits<uint32_t>::max())) {
|
|
1094
|
+
throw std::invalid_argument("movementId must be a finite unsigned 32-bit integer");
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
try {
|
|
1098
|
+
bark_cxx::update_history_metadata(static_cast<uint32_t>(movementId), patchJson);
|
|
1099
|
+
} catch (const rust::Error& e) {
|
|
1100
|
+
throw std::runtime_error(e.what());
|
|
1101
|
+
}
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1069
1105
|
std::shared_ptr<Promise<std::vector<BarkVtxo>>> vtxos() override {
|
|
1070
1106
|
return Promise<std::vector<BarkVtxo>>::async([]() {
|
|
1071
1107
|
try {
|
|
@@ -1109,6 +1145,21 @@ public:
|
|
|
1109
1145
|
});
|
|
1110
1146
|
}
|
|
1111
1147
|
|
|
1148
|
+
std::shared_ptr<Promise<void>> unlockVtxos(const std::vector<std::string>& vtxoIds) override {
|
|
1149
|
+
return Promise<void>::async([vtxoIds]() {
|
|
1150
|
+
try {
|
|
1151
|
+
rust::Vec<rust::String> rust_vtxo_ids;
|
|
1152
|
+
rust_vtxo_ids.reserve(vtxoIds.size());
|
|
1153
|
+
for (const auto& vtxoId : vtxoIds) {
|
|
1154
|
+
rust_vtxo_ids.push_back(vtxoId);
|
|
1155
|
+
}
|
|
1156
|
+
bark_cxx::unlock_vtxos(std::move(rust_vtxo_ids));
|
|
1157
|
+
} catch (const rust::Error& e) {
|
|
1158
|
+
throw std::runtime_error(e.what());
|
|
1159
|
+
}
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1112
1163
|
std::shared_ptr<Promise<std::vector<BarkVtxo>>> getExpiringVtxos(double threshold) override {
|
|
1113
1164
|
return Promise<std::vector<BarkVtxo>>::async([threshold]() {
|
|
1114
1165
|
try {
|
|
@@ -1375,6 +1426,22 @@ public:
|
|
|
1375
1426
|
});
|
|
1376
1427
|
}
|
|
1377
1428
|
|
|
1429
|
+
// Pay an invoice resolved by the caller while preserving the durable,
|
|
1430
|
+
// user-facing origin in Bark instead of storing only the one-time invoice.
|
|
1431
|
+
std::shared_ptr<Promise<LightningPaymentResult>>
|
|
1432
|
+
payLightningInvoiceWithOrigin(const std::string& invoice, const LightningPaymentOrigin& origin, bool wait) override {
|
|
1433
|
+
return Promise<LightningPaymentResult>::async([invoice, origin, wait]() {
|
|
1434
|
+
try {
|
|
1435
|
+
bark_cxx::LightningPaymentResult rust_result = bark_cxx::pay_lightning_invoice_with_origin(
|
|
1436
|
+
invoice, lightningPaymentOriginMethodToString(origin.method), origin.value, wait);
|
|
1437
|
+
|
|
1438
|
+
return convertRustLightningPaymentResult(rust_result);
|
|
1439
|
+
} catch (const rust::Error& e) {
|
|
1440
|
+
throw std::runtime_error(e.what());
|
|
1441
|
+
}
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1378
1445
|
std::shared_ptr<Promise<LightningPaymentResult>> payLightningOffer(const std::string& offer, bool wait,
|
|
1379
1446
|
std::optional<double> amountSat) override {
|
|
1380
1447
|
return Promise<LightningPaymentResult>::async([offer, wait, amountSat]() {
|
|
@@ -1433,16 +1500,20 @@ public:
|
|
|
1433
1500
|
}
|
|
1434
1501
|
|
|
1435
1502
|
std::shared_ptr<Promise<Bolt11Invoice>> bolt11Invoice(double amountMsat,
|
|
1436
|
-
const std::optional<std::string>& description
|
|
1437
|
-
|
|
1503
|
+
const std::optional<std::string>& description,
|
|
1504
|
+
const std::optional<std::string>& token) override {
|
|
1505
|
+
return Promise<Bolt11Invoice>::async([amountMsat, description, token]() {
|
|
1438
1506
|
try {
|
|
1439
|
-
|
|
1507
|
+
std::unique_ptr<rust::String> description_rs;
|
|
1508
|
+
std::unique_ptr<rust::String> token_rs;
|
|
1440
1509
|
if (description.has_value()) {
|
|
1441
|
-
rust::String
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1510
|
+
description_rs = std::make_unique<rust::String>(description.value());
|
|
1511
|
+
}
|
|
1512
|
+
if (token.has_value()) {
|
|
1513
|
+
token_rs = std::make_unique<rust::String>(token.value());
|
|
1445
1514
|
}
|
|
1515
|
+
const auto invoice_rs = bark_cxx::bolt11_invoice(
|
|
1516
|
+
static_cast<uint64_t>(amountMsat), description_rs.get(), token_rs.get());
|
|
1446
1517
|
return Bolt11Invoice(std::string(invoice_rs.bolt11_invoice.data(), invoice_rs.bolt11_invoice.length()),
|
|
1447
1518
|
std::string(invoice_rs.payment_secret.data(), invoice_rs.payment_secret.length()),
|
|
1448
1519
|
std::string(invoice_rs.payment_hash.data(), invoice_rs.payment_hash.length()));
|
|
@@ -1453,36 +1524,11 @@ public:
|
|
|
1453
1524
|
}
|
|
1454
1525
|
|
|
1455
1526
|
std::shared_ptr<Promise<LightningReceive>>
|
|
1456
|
-
tryClaimLightningReceive(const std::string& paymentHash, bool wait
|
|
1457
|
-
|
|
1458
|
-
return Promise<LightningReceive>::async([paymentHash, wait, token]() -> LightningReceive {
|
|
1527
|
+
tryClaimLightningReceive(const std::string& paymentHash, bool wait) override {
|
|
1528
|
+
return Promise<LightningReceive>::async([paymentHash, wait]() -> LightningReceive {
|
|
1459
1529
|
try {
|
|
1460
|
-
bark_cxx::
|
|
1461
|
-
|
|
1462
|
-
rust::String token_rs(token.value());
|
|
1463
|
-
result = bark_cxx::try_claim_lightning_receive(paymentHash, wait, &token_rs);
|
|
1464
|
-
} else {
|
|
1465
|
-
result = bark_cxx::try_claim_lightning_receive(paymentHash, wait, nullptr);
|
|
1466
|
-
}
|
|
1467
|
-
|
|
1468
|
-
LightningReceive lr;
|
|
1469
|
-
lr.payment_hash = std::string(result.payment_hash.data(), result.payment_hash.length());
|
|
1470
|
-
lr.payment_preimage = std::string(result.payment_preimage.data(), result.payment_preimage.length());
|
|
1471
|
-
lr.invoice = std::string(result.invoice.data(), result.invoice.length());
|
|
1472
|
-
|
|
1473
|
-
if (result.preimage_revealed_at != nullptr) {
|
|
1474
|
-
lr.preimage_revealed_at = static_cast<double>(*result.preimage_revealed_at);
|
|
1475
|
-
} else {
|
|
1476
|
-
lr.preimage_revealed_at = std::nullopt;
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
|
-
if (result.finished_at != nullptr) {
|
|
1480
|
-
lr.finished_at = static_cast<double>(*result.finished_at);
|
|
1481
|
-
} else {
|
|
1482
|
-
lr.finished_at = std::nullopt;
|
|
1483
|
-
}
|
|
1484
|
-
|
|
1485
|
-
return lr;
|
|
1530
|
+
const auto result = bark_cxx::try_claim_lightning_receive(paymentHash, wait);
|
|
1531
|
+
return convertRustLightningReceive(result);
|
|
1486
1532
|
} catch (const rust::Error& e) {
|
|
1487
1533
|
throw std::runtime_error(e.what());
|
|
1488
1534
|
}
|
|
@@ -1499,36 +1545,11 @@ public:
|
|
|
1499
1545
|
});
|
|
1500
1546
|
}
|
|
1501
1547
|
|
|
1502
|
-
std::shared_ptr<Promise<
|
|
1548
|
+
std::shared_ptr<Promise<LightningReceive>>
|
|
1503
1549
|
lightningReceiveStatus(const std::string& paymentHash) override {
|
|
1504
|
-
return Promise<
|
|
1550
|
+
return Promise<LightningReceive>::async([paymentHash]() {
|
|
1505
1551
|
try {
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
if (status_ptr == nullptr) {
|
|
1509
|
-
return std::optional<LightningReceive>();
|
|
1510
|
-
}
|
|
1511
|
-
|
|
1512
|
-
std::unique_ptr<const bark_cxx::LightningReceive> status(status_ptr);
|
|
1513
|
-
|
|
1514
|
-
LightningReceive result;
|
|
1515
|
-
result.payment_hash = std::string(status->payment_hash.data(), status->payment_hash.length());
|
|
1516
|
-
result.payment_preimage = std::string(status->payment_preimage.data(), status->payment_preimage.length());
|
|
1517
|
-
result.invoice = std::string(status->invoice.data(), status->invoice.length());
|
|
1518
|
-
|
|
1519
|
-
if (status->preimage_revealed_at != nullptr) {
|
|
1520
|
-
result.preimage_revealed_at = static_cast<double>(*status->preimage_revealed_at);
|
|
1521
|
-
} else {
|
|
1522
|
-
result.preimage_revealed_at = std::nullopt;
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
|
-
if (status->finished_at != nullptr) {
|
|
1526
|
-
result.finished_at = static_cast<double>(*status->finished_at);
|
|
1527
|
-
} else {
|
|
1528
|
-
result.finished_at = std::nullopt;
|
|
1529
|
-
}
|
|
1530
|
-
|
|
1531
|
-
return std::optional<LightningReceive>(result);
|
|
1552
|
+
return convertRustLightningReceive(bark_cxx::lightning_receive_status(paymentHash));
|
|
1532
1553
|
} catch (const rust::Error& e) {
|
|
1533
1554
|
throw std::runtime_error(e.what());
|
|
1534
1555
|
}
|
package/cpp/generated/ark_cxx.h
CHANGED
|
@@ -1284,7 +1284,6 @@ struct CxxArkInfo final {
|
|
|
1284
1284
|
#define CXXBRIDGE1_STRUCT_bark_cxx$ConfigOpts
|
|
1285
1285
|
struct ConfigOpts final {
|
|
1286
1286
|
::rust::String ark;
|
|
1287
|
-
::rust::String server_access_token;
|
|
1288
1287
|
::rust::String user_agent;
|
|
1289
1288
|
::rust::String esplora;
|
|
1290
1289
|
::rust::String bitcoind;
|
|
@@ -1340,11 +1339,18 @@ enum class RefreshModeType : ::std::uint8_t {
|
|
|
1340
1339
|
#ifndef CXXBRIDGE1_STRUCT_bark_cxx$LightningReceive
|
|
1341
1340
|
#define CXXBRIDGE1_STRUCT_bark_cxx$LightningReceive
|
|
1342
1341
|
struct LightningReceive final {
|
|
1342
|
+
::rust::String state;
|
|
1343
|
+
::rust::String phase;
|
|
1343
1344
|
::rust::String payment_hash;
|
|
1344
1345
|
::rust::String payment_preimage;
|
|
1345
1346
|
::rust::String invoice;
|
|
1346
|
-
::
|
|
1347
|
-
|
|
1347
|
+
::rust::Vec<::rust::String> htlc_vtxo_ids;
|
|
1348
|
+
bool has_movement_id CXX_DEFAULT_VALUE(false);
|
|
1349
|
+
::std::uint32_t movement_id CXX_DEFAULT_VALUE(0);
|
|
1350
|
+
bool has_amount_sat CXX_DEFAULT_VALUE(false);
|
|
1351
|
+
::std::uint64_t amount_sat CXX_DEFAULT_VALUE(0);
|
|
1352
|
+
bool has_settled_at CXX_DEFAULT_VALUE(false);
|
|
1353
|
+
::std::uint64_t settled_at CXX_DEFAULT_VALUE(0);
|
|
1348
1354
|
|
|
1349
1355
|
using IsRelocatable = ::std::true_type;
|
|
1350
1356
|
};
|
|
@@ -1612,12 +1618,16 @@ bool verify_message(::rust::Str message, ::rust::Str signature, ::rust::Str publ
|
|
|
1612
1618
|
|
|
1613
1619
|
::rust::Vec<::bark_cxx::BarkVtxo> vtxos();
|
|
1614
1620
|
|
|
1621
|
+
void update_history_metadata(::std::uint32_t movement_id, ::rust::Str patch_json);
|
|
1622
|
+
|
|
1615
1623
|
::bark_cxx::BarkVtxo decode_vtxo_hex(::rust::Str vtxo_hex);
|
|
1616
1624
|
|
|
1617
1625
|
::bark_cxx::BarkVtxo import_vtxo(::rust::Str vtxo_hex);
|
|
1618
1626
|
|
|
1619
1627
|
void dangerous_drop_vtxo(::rust::Str vtxo_id);
|
|
1620
1628
|
|
|
1629
|
+
void unlock_vtxos(::rust::Vec<::rust::String> vtxo_ids);
|
|
1630
|
+
|
|
1621
1631
|
::rust::Vec<::bark_cxx::BarkVtxo> get_expiring_vtxos(::std::uint32_t threshold);
|
|
1622
1632
|
|
|
1623
1633
|
::bark_cxx::DelegatedRoundState refresh_vtxos_delegated(::rust::Vec<::rust::String> vtxo_ids);
|
|
@@ -1626,9 +1636,9 @@ void dangerous_drop_vtxo(::rust::Str vtxo_id);
|
|
|
1626
1636
|
|
|
1627
1637
|
::std::uint32_t const *get_next_required_refresh_blockheight();
|
|
1628
1638
|
|
|
1629
|
-
::bark_cxx::Bolt11Invoice bolt11_invoice(::std::uint64_t amount_msat, ::rust::String const *description);
|
|
1639
|
+
::bark_cxx::Bolt11Invoice bolt11_invoice(::std::uint64_t amount_msat, ::rust::String const *description, ::rust::String const *token);
|
|
1630
1640
|
|
|
1631
|
-
::bark_cxx::LightningReceive
|
|
1641
|
+
::bark_cxx::LightningReceive lightning_receive_status(::rust::String payment_hash);
|
|
1632
1642
|
|
|
1633
1643
|
::bark_cxx::LightningPaymentResult check_lightning_payment(::rust::String payment_hash, bool wait);
|
|
1634
1644
|
|
|
@@ -1638,10 +1648,6 @@ void maintenance();
|
|
|
1638
1648
|
|
|
1639
1649
|
void maintenance_delegated();
|
|
1640
1650
|
|
|
1641
|
-
void maintenance_with_onchain();
|
|
1642
|
-
|
|
1643
|
-
void maintenance_with_onchain_delegated();
|
|
1644
|
-
|
|
1645
1651
|
void maintenance_refresh();
|
|
1646
1652
|
|
|
1647
1653
|
void refresh_server();
|
|
@@ -1670,6 +1676,8 @@ void validate_arkoor_address(::rust::Str address);
|
|
|
1670
1676
|
|
|
1671
1677
|
::bark_cxx::LightningPaymentResult pay_lightning_invoice(::rust::Str destination, ::std::uint64_t const *amount_sat, bool wait);
|
|
1672
1678
|
|
|
1679
|
+
::bark_cxx::LightningPaymentResult pay_lightning_invoice_with_origin(::rust::Str invoice, ::rust::Str origin_method, ::rust::Str origin_value, bool wait);
|
|
1680
|
+
|
|
1673
1681
|
::bark_cxx::LightningPaymentResult pay_lightning_offer(::rust::Str offer, ::std::uint64_t const *amount_sat, bool wait);
|
|
1674
1682
|
|
|
1675
1683
|
::bark_cxx::LightningPaymentResult pay_lightning_address(::rust::Str addr, ::std::uint64_t amount_sat, ::rust::Str comment, bool wait);
|
|
@@ -1704,7 +1712,7 @@ bool has_pending_exits();
|
|
|
1704
1712
|
|
|
1705
1713
|
::bark_cxx::BarkFeeEstimate estimate_offboard_all(::rust::Str destination_address);
|
|
1706
1714
|
|
|
1707
|
-
::bark_cxx::LightningReceive try_claim_lightning_receive(::rust::String payment_hash, bool wait
|
|
1715
|
+
::bark_cxx::LightningReceive try_claim_lightning_receive(::rust::String payment_hash, bool wait);
|
|
1708
1716
|
|
|
1709
1717
|
void try_claim_all_lightning_receives(bool wait);
|
|
1710
1718
|
|