react-native-nitro-ark 0.0.131 → 0.0.133
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/cpp/NitroArk.hpp +65 -85
- package/cpp/generated/ark_cxx.h +17 -10
- package/lib/module/index.js +54 -39
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NitroArk.nitro.d.ts +13 -8
- package/lib/typescript/src/NitroArk.nitro.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +43 -35
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/nitrogen/generated/shared/c++/BarkConfigOpts.hpp +5 -5
- package/nitrogen/generated/shared/c++/HybridNitroArkSpec.cpp +2 -2
- package/nitrogen/generated/shared/c++/HybridNitroArkSpec.hpp +5 -5
- package/nitrogen/generated/shared/c++/LightningReceive.hpp +26 -9
- package/package.json +1 -1
- package/src/NitroArk.nitro.ts +14 -11
- package/src/index.tsx +117 -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
|
}
|
package/cpp/NitroArk.hpp
CHANGED
|
@@ -87,6 +87,32 @@ inline LightningPaymentResult convertRustLightningPaymentResult(const bark_cxx::
|
|
|
87
87
|
return result;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
inline LightningReceive convertRustLightningReceive(const bark_cxx::LightningReceive& rust_result) {
|
|
91
|
+
LightningReceive result;
|
|
92
|
+
result.state = std::string(rust_result.state.data(), rust_result.state.length());
|
|
93
|
+
if (!rust_result.phase.empty()) {
|
|
94
|
+
result.phase = std::string(rust_result.phase.data(), rust_result.phase.length());
|
|
95
|
+
}
|
|
96
|
+
result.payment_hash = std::string(rust_result.payment_hash.data(), rust_result.payment_hash.length());
|
|
97
|
+
result.payment_preimage =
|
|
98
|
+
std::string(rust_result.payment_preimage.data(), rust_result.payment_preimage.length());
|
|
99
|
+
result.invoice = std::string(rust_result.invoice.data(), rust_result.invoice.length());
|
|
100
|
+
result.htlc_vtxo_ids.reserve(rust_result.htlc_vtxo_ids.size());
|
|
101
|
+
for (const auto& id : rust_result.htlc_vtxo_ids) {
|
|
102
|
+
result.htlc_vtxo_ids.emplace_back(std::string(id.data(), id.length()));
|
|
103
|
+
}
|
|
104
|
+
if (rust_result.has_movement_id) {
|
|
105
|
+
result.movement_id = static_cast<double>(rust_result.movement_id);
|
|
106
|
+
}
|
|
107
|
+
if (rust_result.has_amount_sat) {
|
|
108
|
+
result.amount_sat = static_cast<double>(rust_result.amount_sat);
|
|
109
|
+
}
|
|
110
|
+
if (rust_result.has_settled_at) {
|
|
111
|
+
result.settled_at = static_cast<double>(rust_result.settled_at);
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
|
|
90
116
|
inline ExitBlockRefResult convertRustExitBlockRef(const bark_cxx::ExitBlockRefResult& block_rs) {
|
|
91
117
|
ExitBlockRefResult block;
|
|
92
118
|
block.height = static_cast<double>(block_rs.height);
|
|
@@ -342,7 +368,7 @@ private:
|
|
|
342
368
|
bark_cxx::ConfigOpts config_opts;
|
|
343
369
|
if (config.has_value()) {
|
|
344
370
|
config_opts.ark = config->ark;
|
|
345
|
-
config_opts.
|
|
371
|
+
config_opts.user_agent = config->user_agent.value_or("");
|
|
346
372
|
config_opts.esplora = config->esplora.value_or("");
|
|
347
373
|
config_opts.bitcoind = config->bitcoind.value_or("");
|
|
348
374
|
config_opts.bitcoind_cookie = config->bitcoind_cookie.value_or("");
|
|
@@ -370,6 +396,11 @@ public:
|
|
|
370
396
|
|
|
371
397
|
// --- Management ---
|
|
372
398
|
|
|
399
|
+
std::string getBarkVersion() override {
|
|
400
|
+
rust::String version = bark_cxx::bark_version();
|
|
401
|
+
return std::string(version.data(), version.length());
|
|
402
|
+
}
|
|
403
|
+
|
|
373
404
|
std::shared_ptr<Promise<std::string>> createMnemonic() override {
|
|
374
405
|
return Promise<std::string>::async([]() {
|
|
375
406
|
try {
|
|
@@ -524,16 +555,6 @@ public:
|
|
|
524
555
|
});
|
|
525
556
|
}
|
|
526
557
|
|
|
527
|
-
std::shared_ptr<Promise<void>> maintenanceWithOnchain() override {
|
|
528
|
-
return Promise<void>::async([]() {
|
|
529
|
-
try {
|
|
530
|
-
bark_cxx::maintenance_with_onchain();
|
|
531
|
-
} catch (const rust::Error& e) {
|
|
532
|
-
throw std::runtime_error(e.what());
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
|
-
}
|
|
536
|
-
|
|
537
558
|
std::shared_ptr<Promise<void>> maintenanceDelegated() override {
|
|
538
559
|
return Promise<void>::async([]() {
|
|
539
560
|
try {
|
|
@@ -544,16 +565,6 @@ public:
|
|
|
544
565
|
});
|
|
545
566
|
}
|
|
546
567
|
|
|
547
|
-
std::shared_ptr<Promise<void>> maintenanceWithOnchainDelegated() override {
|
|
548
|
-
return Promise<void>::async([]() {
|
|
549
|
-
try {
|
|
550
|
-
bark_cxx::maintenance_with_onchain_delegated();
|
|
551
|
-
} catch (const rust::Error& e) {
|
|
552
|
-
throw std::runtime_error(e.what());
|
|
553
|
-
}
|
|
554
|
-
});
|
|
555
|
-
}
|
|
556
|
-
|
|
557
568
|
std::shared_ptr<Promise<void>> maintenanceRefresh() override {
|
|
558
569
|
return Promise<void>::async([]() {
|
|
559
570
|
try {
|
|
@@ -1103,6 +1114,21 @@ public:
|
|
|
1103
1114
|
});
|
|
1104
1115
|
}
|
|
1105
1116
|
|
|
1117
|
+
std::shared_ptr<Promise<void>> unlockVtxos(const std::vector<std::string>& vtxoIds) override {
|
|
1118
|
+
return Promise<void>::async([vtxoIds]() {
|
|
1119
|
+
try {
|
|
1120
|
+
rust::Vec<rust::String> rust_vtxo_ids;
|
|
1121
|
+
rust_vtxo_ids.reserve(vtxoIds.size());
|
|
1122
|
+
for (const auto& vtxoId : vtxoIds) {
|
|
1123
|
+
rust_vtxo_ids.push_back(vtxoId);
|
|
1124
|
+
}
|
|
1125
|
+
bark_cxx::unlock_vtxos(std::move(rust_vtxo_ids));
|
|
1126
|
+
} catch (const rust::Error& e) {
|
|
1127
|
+
throw std::runtime_error(e.what());
|
|
1128
|
+
}
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1106
1132
|
std::shared_ptr<Promise<std::vector<BarkVtxo>>> getExpiringVtxos(double threshold) override {
|
|
1107
1133
|
return Promise<std::vector<BarkVtxo>>::async([threshold]() {
|
|
1108
1134
|
try {
|
|
@@ -1427,16 +1453,20 @@ public:
|
|
|
1427
1453
|
}
|
|
1428
1454
|
|
|
1429
1455
|
std::shared_ptr<Promise<Bolt11Invoice>> bolt11Invoice(double amountMsat,
|
|
1430
|
-
const std::optional<std::string>& description
|
|
1431
|
-
|
|
1456
|
+
const std::optional<std::string>& description,
|
|
1457
|
+
const std::optional<std::string>& token) override {
|
|
1458
|
+
return Promise<Bolt11Invoice>::async([amountMsat, description, token]() {
|
|
1432
1459
|
try {
|
|
1433
|
-
|
|
1460
|
+
std::unique_ptr<rust::String> description_rs;
|
|
1461
|
+
std::unique_ptr<rust::String> token_rs;
|
|
1434
1462
|
if (description.has_value()) {
|
|
1435
|
-
rust::String
|
|
1436
|
-
invoice_rs = bark_cxx::bolt11_invoice(static_cast<uint64_t>(amountMsat), &description_rs);
|
|
1437
|
-
} else {
|
|
1438
|
-
invoice_rs = bark_cxx::bolt11_invoice(static_cast<uint64_t>(amountMsat), nullptr);
|
|
1463
|
+
description_rs = std::make_unique<rust::String>(description.value());
|
|
1439
1464
|
}
|
|
1465
|
+
if (token.has_value()) {
|
|
1466
|
+
token_rs = std::make_unique<rust::String>(token.value());
|
|
1467
|
+
}
|
|
1468
|
+
const auto invoice_rs = bark_cxx::bolt11_invoice(
|
|
1469
|
+
static_cast<uint64_t>(amountMsat), description_rs.get(), token_rs.get());
|
|
1440
1470
|
return Bolt11Invoice(std::string(invoice_rs.bolt11_invoice.data(), invoice_rs.bolt11_invoice.length()),
|
|
1441
1471
|
std::string(invoice_rs.payment_secret.data(), invoice_rs.payment_secret.length()),
|
|
1442
1472
|
std::string(invoice_rs.payment_hash.data(), invoice_rs.payment_hash.length()));
|
|
@@ -1447,36 +1477,11 @@ public:
|
|
|
1447
1477
|
}
|
|
1448
1478
|
|
|
1449
1479
|
std::shared_ptr<Promise<LightningReceive>>
|
|
1450
|
-
tryClaimLightningReceive(const std::string& paymentHash, bool wait
|
|
1451
|
-
|
|
1452
|
-
return Promise<LightningReceive>::async([paymentHash, wait, token]() -> LightningReceive {
|
|
1480
|
+
tryClaimLightningReceive(const std::string& paymentHash, bool wait) override {
|
|
1481
|
+
return Promise<LightningReceive>::async([paymentHash, wait]() -> LightningReceive {
|
|
1453
1482
|
try {
|
|
1454
|
-
bark_cxx::
|
|
1455
|
-
|
|
1456
|
-
rust::String token_rs(token.value());
|
|
1457
|
-
result = bark_cxx::try_claim_lightning_receive(paymentHash, wait, &token_rs);
|
|
1458
|
-
} else {
|
|
1459
|
-
result = bark_cxx::try_claim_lightning_receive(paymentHash, wait, nullptr);
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
LightningReceive lr;
|
|
1463
|
-
lr.payment_hash = std::string(result.payment_hash.data(), result.payment_hash.length());
|
|
1464
|
-
lr.payment_preimage = std::string(result.payment_preimage.data(), result.payment_preimage.length());
|
|
1465
|
-
lr.invoice = std::string(result.invoice.data(), result.invoice.length());
|
|
1466
|
-
|
|
1467
|
-
if (result.preimage_revealed_at != nullptr) {
|
|
1468
|
-
lr.preimage_revealed_at = static_cast<double>(*result.preimage_revealed_at);
|
|
1469
|
-
} else {
|
|
1470
|
-
lr.preimage_revealed_at = std::nullopt;
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
|
-
if (result.finished_at != nullptr) {
|
|
1474
|
-
lr.finished_at = static_cast<double>(*result.finished_at);
|
|
1475
|
-
} else {
|
|
1476
|
-
lr.finished_at = std::nullopt;
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
|
-
return lr;
|
|
1483
|
+
const auto result = bark_cxx::try_claim_lightning_receive(paymentHash, wait);
|
|
1484
|
+
return convertRustLightningReceive(result);
|
|
1480
1485
|
} catch (const rust::Error& e) {
|
|
1481
1486
|
throw std::runtime_error(e.what());
|
|
1482
1487
|
}
|
|
@@ -1493,36 +1498,11 @@ public:
|
|
|
1493
1498
|
});
|
|
1494
1499
|
}
|
|
1495
1500
|
|
|
1496
|
-
std::shared_ptr<Promise<
|
|
1501
|
+
std::shared_ptr<Promise<LightningReceive>>
|
|
1497
1502
|
lightningReceiveStatus(const std::string& paymentHash) override {
|
|
1498
|
-
return Promise<
|
|
1503
|
+
return Promise<LightningReceive>::async([paymentHash]() {
|
|
1499
1504
|
try {
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
if (status_ptr == nullptr) {
|
|
1503
|
-
return std::optional<LightningReceive>();
|
|
1504
|
-
}
|
|
1505
|
-
|
|
1506
|
-
std::unique_ptr<const bark_cxx::LightningReceive> status(status_ptr);
|
|
1507
|
-
|
|
1508
|
-
LightningReceive result;
|
|
1509
|
-
result.payment_hash = std::string(status->payment_hash.data(), status->payment_hash.length());
|
|
1510
|
-
result.payment_preimage = std::string(status->payment_preimage.data(), status->payment_preimage.length());
|
|
1511
|
-
result.invoice = std::string(status->invoice.data(), status->invoice.length());
|
|
1512
|
-
|
|
1513
|
-
if (status->preimage_revealed_at != nullptr) {
|
|
1514
|
-
result.preimage_revealed_at = static_cast<double>(*status->preimage_revealed_at);
|
|
1515
|
-
} else {
|
|
1516
|
-
result.preimage_revealed_at = std::nullopt;
|
|
1517
|
-
}
|
|
1518
|
-
|
|
1519
|
-
if (status->finished_at != nullptr) {
|
|
1520
|
-
result.finished_at = static_cast<double>(*status->finished_at);
|
|
1521
|
-
} else {
|
|
1522
|
-
result.finished_at = std::nullopt;
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
|
-
return std::optional<LightningReceive>(result);
|
|
1505
|
+
return convertRustLightningReceive(bark_cxx::lightning_receive_status(paymentHash));
|
|
1526
1506
|
} catch (const rust::Error& e) {
|
|
1527
1507
|
throw std::runtime_error(e.what());
|
|
1528
1508
|
}
|
package/cpp/generated/ark_cxx.h
CHANGED
|
@@ -1284,7 +1284,7 @@ struct CxxArkInfo final {
|
|
|
1284
1284
|
#define CXXBRIDGE1_STRUCT_bark_cxx$ConfigOpts
|
|
1285
1285
|
struct ConfigOpts final {
|
|
1286
1286
|
::rust::String ark;
|
|
1287
|
-
::rust::String
|
|
1287
|
+
::rust::String user_agent;
|
|
1288
1288
|
::rust::String esplora;
|
|
1289
1289
|
::rust::String bitcoind;
|
|
1290
1290
|
::rust::String bitcoind_cookie;
|
|
@@ -1339,11 +1339,18 @@ enum class RefreshModeType : ::std::uint8_t {
|
|
|
1339
1339
|
#ifndef CXXBRIDGE1_STRUCT_bark_cxx$LightningReceive
|
|
1340
1340
|
#define CXXBRIDGE1_STRUCT_bark_cxx$LightningReceive
|
|
1341
1341
|
struct LightningReceive final {
|
|
1342
|
+
::rust::String state;
|
|
1343
|
+
::rust::String phase;
|
|
1342
1344
|
::rust::String payment_hash;
|
|
1343
1345
|
::rust::String payment_preimage;
|
|
1344
1346
|
::rust::String invoice;
|
|
1345
|
-
::
|
|
1346
|
-
|
|
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);
|
|
1347
1354
|
|
|
1348
1355
|
using IsRelocatable = ::std::true_type;
|
|
1349
1356
|
};
|
|
@@ -1575,6 +1582,8 @@ private:
|
|
|
1575
1582
|
|
|
1576
1583
|
void init_logger() noexcept;
|
|
1577
1584
|
|
|
1585
|
+
::rust::String bark_version() noexcept;
|
|
1586
|
+
|
|
1578
1587
|
::rust::String create_mnemonic();
|
|
1579
1588
|
|
|
1580
1589
|
bool is_wallet_loaded() noexcept;
|
|
@@ -1615,6 +1624,8 @@ bool verify_message(::rust::Str message, ::rust::Str signature, ::rust::Str publ
|
|
|
1615
1624
|
|
|
1616
1625
|
void dangerous_drop_vtxo(::rust::Str vtxo_id);
|
|
1617
1626
|
|
|
1627
|
+
void unlock_vtxos(::rust::Vec<::rust::String> vtxo_ids);
|
|
1628
|
+
|
|
1618
1629
|
::rust::Vec<::bark_cxx::BarkVtxo> get_expiring_vtxos(::std::uint32_t threshold);
|
|
1619
1630
|
|
|
1620
1631
|
::bark_cxx::DelegatedRoundState refresh_vtxos_delegated(::rust::Vec<::rust::String> vtxo_ids);
|
|
@@ -1623,9 +1634,9 @@ void dangerous_drop_vtxo(::rust::Str vtxo_id);
|
|
|
1623
1634
|
|
|
1624
1635
|
::std::uint32_t const *get_next_required_refresh_blockheight();
|
|
1625
1636
|
|
|
1626
|
-
::bark_cxx::Bolt11Invoice bolt11_invoice(::std::uint64_t amount_msat, ::rust::String const *description);
|
|
1637
|
+
::bark_cxx::Bolt11Invoice bolt11_invoice(::std::uint64_t amount_msat, ::rust::String const *description, ::rust::String const *token);
|
|
1627
1638
|
|
|
1628
|
-
::bark_cxx::LightningReceive
|
|
1639
|
+
::bark_cxx::LightningReceive lightning_receive_status(::rust::String payment_hash);
|
|
1629
1640
|
|
|
1630
1641
|
::bark_cxx::LightningPaymentResult check_lightning_payment(::rust::String payment_hash, bool wait);
|
|
1631
1642
|
|
|
@@ -1635,10 +1646,6 @@ void maintenance();
|
|
|
1635
1646
|
|
|
1636
1647
|
void maintenance_delegated();
|
|
1637
1648
|
|
|
1638
|
-
void maintenance_with_onchain();
|
|
1639
|
-
|
|
1640
|
-
void maintenance_with_onchain_delegated();
|
|
1641
|
-
|
|
1642
1649
|
void maintenance_refresh();
|
|
1643
1650
|
|
|
1644
1651
|
void refresh_server();
|
|
@@ -1701,7 +1708,7 @@ bool has_pending_exits();
|
|
|
1701
1708
|
|
|
1702
1709
|
::bark_cxx::BarkFeeEstimate estimate_offboard_all(::rust::Str destination_address);
|
|
1703
1710
|
|
|
1704
|
-
::bark_cxx::LightningReceive try_claim_lightning_receive(::rust::String payment_hash, bool wait
|
|
1711
|
+
::bark_cxx::LightningReceive try_claim_lightning_receive(::rust::String payment_hash, bool wait);
|
|
1705
1712
|
|
|
1706
1713
|
void try_claim_all_lightning_receives(bool wait);
|
|
1707
1714
|
|
package/lib/module/index.js
CHANGED
|
@@ -5,40 +5,73 @@ export const NitroArkHybridObject = NitroModules.createHybridObject('NitroArk');
|
|
|
5
5
|
function enrichExitProgressStatus(result) {
|
|
6
6
|
const {
|
|
7
7
|
state,
|
|
8
|
+
state_details,
|
|
8
9
|
...rest
|
|
9
10
|
} = result;
|
|
10
11
|
return {
|
|
11
12
|
...rest,
|
|
12
|
-
state: state
|
|
13
|
+
state: state,
|
|
14
|
+
state_details: {
|
|
15
|
+
...state_details,
|
|
16
|
+
kind: state_details.kind
|
|
17
|
+
}
|
|
13
18
|
};
|
|
14
19
|
}
|
|
15
20
|
function enrichExitVtxo(result) {
|
|
16
21
|
const {
|
|
17
22
|
state,
|
|
23
|
+
state_details,
|
|
18
24
|
history: stateHistory,
|
|
25
|
+
history_details,
|
|
19
26
|
...rest
|
|
20
27
|
} = result;
|
|
21
28
|
return {
|
|
22
29
|
...rest,
|
|
23
30
|
state: state,
|
|
24
|
-
|
|
31
|
+
state_details: {
|
|
32
|
+
...state_details,
|
|
33
|
+
kind: state_details.kind
|
|
34
|
+
},
|
|
35
|
+
history: stateHistory,
|
|
36
|
+
history_details: history_details.map(details => ({
|
|
37
|
+
...details,
|
|
38
|
+
kind: details.kind
|
|
39
|
+
}))
|
|
25
40
|
};
|
|
26
41
|
}
|
|
27
42
|
function enrichExitStatus(result) {
|
|
28
43
|
const {
|
|
29
44
|
state,
|
|
45
|
+
state_details,
|
|
30
46
|
history: stateHistory,
|
|
47
|
+
history_details,
|
|
31
48
|
...rest
|
|
32
49
|
} = result;
|
|
33
50
|
return {
|
|
34
51
|
...rest,
|
|
35
52
|
state: state,
|
|
36
|
-
|
|
53
|
+
state_details: {
|
|
54
|
+
...state_details,
|
|
55
|
+
kind: state_details.kind
|
|
56
|
+
},
|
|
57
|
+
history: stateHistory,
|
|
58
|
+
history_details: history_details.map(details => ({
|
|
59
|
+
...details,
|
|
60
|
+
kind: details.kind
|
|
61
|
+
}))
|
|
37
62
|
};
|
|
38
63
|
}
|
|
64
|
+
function enrichLightningReceive(result) {
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
39
67
|
|
|
40
68
|
// --- Management ---
|
|
41
69
|
|
|
70
|
+
/** Returns the semver of the Bark wallet library compiled into the native module. */
|
|
71
|
+
export function getBarkVersion() {
|
|
72
|
+
return NitroArkHybridObject.getBarkVersion();
|
|
73
|
+
}
|
|
74
|
+
|
|
42
75
|
/**
|
|
43
76
|
* Creates a new BIP39 mnemonic phrase.
|
|
44
77
|
* @returns A promise resolving to the mnemonic string.
|
|
@@ -124,42 +157,16 @@ export function syncPendingBoards() {
|
|
|
124
157
|
return NitroArkHybridObject.syncPendingBoards();
|
|
125
158
|
}
|
|
126
159
|
|
|
127
|
-
/**
|
|
128
|
-
* Runs wallet maintenance tasks for offchain.
|
|
129
|
-
* This includes refreshing vtxos that need to be refreshed.
|
|
130
|
-
* @returns A promise that resolves on success.
|
|
131
|
-
*/
|
|
160
|
+
/** Runs wallet maintenance, including on-chain synchronization and exit progression. */
|
|
132
161
|
export function maintenance() {
|
|
133
162
|
return NitroArkHybridObject.maintenance();
|
|
134
163
|
}
|
|
135
164
|
|
|
136
|
-
/**
|
|
137
|
-
* Runs wallet maintenance tasks for both offchain and onchain.
|
|
138
|
-
* This includes refreshing vtxos that need to be refreshed.
|
|
139
|
-
* @returns A promise that resolves on success.
|
|
140
|
-
*/
|
|
141
|
-
export function maintenanceWithOnchain() {
|
|
142
|
-
return NitroArkHybridObject.maintenanceWithOnchain();
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Runs delegated wallet maintenance tasks for offchain.
|
|
147
|
-
* This includes refreshing vtxos that need to be refreshed using delegated signing.
|
|
148
|
-
* @returns A promise that resolves on success.
|
|
149
|
-
*/
|
|
165
|
+
/** Runs delegated wallet maintenance, including on-chain synchronization. */
|
|
150
166
|
export function maintenanceDelegated() {
|
|
151
167
|
return NitroArkHybridObject.maintenanceDelegated();
|
|
152
168
|
}
|
|
153
169
|
|
|
154
|
-
/**
|
|
155
|
-
* Runs delegated wallet maintenance tasks for both offchain and onchain.
|
|
156
|
-
* This includes refreshing vtxos that need to be refreshed using delegated signing.
|
|
157
|
-
* @returns A promise that resolves on success.
|
|
158
|
-
*/
|
|
159
|
-
export function maintenanceWithOnchainDelegated() {
|
|
160
|
-
return NitroArkHybridObject.maintenanceWithOnchainDelegated();
|
|
161
|
-
}
|
|
162
|
-
|
|
163
170
|
/**
|
|
164
171
|
* Refreshes vtxos that need to be refreshed.
|
|
165
172
|
* @returns A promise that resolves on success.
|
|
@@ -496,6 +503,15 @@ export function dangerousDropVtxo(vtxoId) {
|
|
|
496
503
|
return NitroArkHybridObject.dangerousDropVtxo(vtxoId);
|
|
497
504
|
}
|
|
498
505
|
|
|
506
|
+
/**
|
|
507
|
+
* Unlocks locked VTXOs and returns them to the spendable state.
|
|
508
|
+
* Already-spendable VTXOs are left unchanged. Spent, unknown, or malformed IDs reject the batch.
|
|
509
|
+
* @param vtxoIds VTXO IDs to unlock.
|
|
510
|
+
*/
|
|
511
|
+
export function unlockVtxos(vtxoIds) {
|
|
512
|
+
return NitroArkHybridObject.unlockVtxos(vtxoIds);
|
|
513
|
+
}
|
|
514
|
+
|
|
499
515
|
/**
|
|
500
516
|
* Gets the first expiring VTXO blockheight for the loaded wallet.
|
|
501
517
|
* @returns A promise resolving to the first expiring VTXO blockheight.
|
|
@@ -619,8 +635,8 @@ export function onchainSendMany(outputs) {
|
|
|
619
635
|
* @param description Optional invoice description/memo.
|
|
620
636
|
* @returns A promise resolving to Bolt11Invoice object.
|
|
621
637
|
*/
|
|
622
|
-
export function bolt11Invoice(amountMsat, description) {
|
|
623
|
-
return NitroArkHybridObject.bolt11Invoice(amountMsat, description);
|
|
638
|
+
export function bolt11Invoice(amountMsat, description, token) {
|
|
639
|
+
return NitroArkHybridObject.bolt11Invoice(amountMsat, description, token);
|
|
624
640
|
}
|
|
625
641
|
|
|
626
642
|
/**
|
|
@@ -629,7 +645,7 @@ export function bolt11Invoice(amountMsat, description) {
|
|
|
629
645
|
* @returns A promise resolving to the Lightning receive status.
|
|
630
646
|
*/
|
|
631
647
|
export function lightningReceiveStatus(paymentHash) {
|
|
632
|
-
return NitroArkHybridObject.lightningReceiveStatus(paymentHash);
|
|
648
|
+
return NitroArkHybridObject.lightningReceiveStatus(paymentHash).then(enrichLightningReceive);
|
|
633
649
|
}
|
|
634
650
|
|
|
635
651
|
/**
|
|
@@ -646,14 +662,13 @@ export function checkLightningPayment(paymentHash, wait) {
|
|
|
646
662
|
}
|
|
647
663
|
|
|
648
664
|
/**
|
|
649
|
-
* Attempts to claim a Lightning payment
|
|
665
|
+
* Attempts to claim a Lightning payment.
|
|
650
666
|
* @param paymentHash The payment hash of the Lightning payment.
|
|
651
667
|
* @param wait Whether to wait for the claim to complete.
|
|
652
|
-
* @
|
|
653
|
-
* @returns A promise resolving to the claimed LightningReceive if successful, or null if not.
|
|
668
|
+
* @returns A promise resolving to the current Lightning receive state.
|
|
654
669
|
*/
|
|
655
|
-
export function tryClaimLightningReceive(paymentHash, wait
|
|
656
|
-
return NitroArkHybridObject.tryClaimLightningReceive(paymentHash, wait
|
|
670
|
+
export function tryClaimLightningReceive(paymentHash, wait) {
|
|
671
|
+
return NitroArkHybridObject.tryClaimLightningReceive(paymentHash, wait).then(enrichLightningReceive);
|
|
657
672
|
}
|
|
658
673
|
|
|
659
674
|
/**
|