react-native-nitro-ark 0.0.132 → 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.
@@ -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 jServerAccessToken, jstring jEsplora,
230
- jstring jBitcoind, jstring jBitcoindCookie, jstring jBitcoindUser, jstring jBitcoindPass,
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.server_access_token = JStringToString(env, jServerAccessToken);
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 Java_com_margelo_nitro_nitroark_NitroArkNative_maintenanceDelegated(JNIEnv* env,
288
- jobject /*thiz*/) {
288
+ JNIEXPORT void JNICALL Java_com_margelo_nitro_nitroark_NitroArkNative_maintenance(JNIEnv* env,
289
+ jobject /*thiz*/) {
289
290
  try {
290
- bark_cxx::maintenance_delegated();
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 Java_com_margelo_nitro_nitroark_NitroArkNative_maintenanceWithOnchainDelegated(
299
- JNIEnv* env, jobject /*thiz*/) {
299
+ JNIEXPORT void JNICALL Java_com_margelo_nitro_nitroark_NitroArkNative_maintenanceDelegated(JNIEnv* env,
300
+ jobject /*thiz*/) {
300
301
  try {
301
- bark_cxx::maintenance_with_onchain_delegated();
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, jstring jToken) {
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
- rust::String token_rs(token_str);
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
- bark_cxx::Bolt11Invoice invoice;
361
+ std::unique_ptr<rust::String> description;
362
+ std::unique_ptr<rust::String> token;
365
363
  if (jDescription != nullptr) {
366
- rust::String description(JStringToString(env, jDescription));
367
- invoice = bark_cxx::bolt11_invoice(static_cast<uint64_t>(jAmountMsat), &description);
368
- } else {
369
- invoice = bark_cxx::bolt11_invoice(static_cast<uint64_t>(jAmountMsat), nullptr);
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 serverAccessToken: String? = null,
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.serverAccessToken,
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
- serverAccessToken: String?,
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(amountMsat: Long, description: String?): Bolt11InvoiceResult
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,6 @@ private:
342
368
  bark_cxx::ConfigOpts config_opts;
343
369
  if (config.has_value()) {
344
370
  config_opts.ark = config->ark;
345
- config_opts.server_access_token = config->server_access_token.value_or("");
346
371
  config_opts.user_agent = config->user_agent.value_or("");
347
372
  config_opts.esplora = config->esplora.value_or("");
348
373
  config_opts.bitcoind = config->bitcoind.value_or("");
@@ -530,16 +555,6 @@ public:
530
555
  });
531
556
  }
532
557
 
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
558
  std::shared_ptr<Promise<void>> maintenanceDelegated() override {
544
559
  return Promise<void>::async([]() {
545
560
  try {
@@ -550,16 +565,6 @@ public:
550
565
  });
551
566
  }
552
567
 
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
568
  std::shared_ptr<Promise<void>> maintenanceRefresh() override {
564
569
  return Promise<void>::async([]() {
565
570
  try {
@@ -1109,6 +1114,21 @@ public:
1109
1114
  });
1110
1115
  }
1111
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
+
1112
1132
  std::shared_ptr<Promise<std::vector<BarkVtxo>>> getExpiringVtxos(double threshold) override {
1113
1133
  return Promise<std::vector<BarkVtxo>>::async([threshold]() {
1114
1134
  try {
@@ -1433,16 +1453,20 @@ public:
1433
1453
  }
1434
1454
 
1435
1455
  std::shared_ptr<Promise<Bolt11Invoice>> bolt11Invoice(double amountMsat,
1436
- const std::optional<std::string>& description) override {
1437
- return Promise<Bolt11Invoice>::async([amountMsat, description]() {
1456
+ const std::optional<std::string>& description,
1457
+ const std::optional<std::string>& token) override {
1458
+ return Promise<Bolt11Invoice>::async([amountMsat, description, token]() {
1438
1459
  try {
1439
- bark_cxx::Bolt11Invoice invoice_rs;
1460
+ std::unique_ptr<rust::String> description_rs;
1461
+ std::unique_ptr<rust::String> token_rs;
1440
1462
  if (description.has_value()) {
1441
- rust::String description_rs(description.value());
1442
- invoice_rs = bark_cxx::bolt11_invoice(static_cast<uint64_t>(amountMsat), &description_rs);
1443
- } else {
1444
- invoice_rs = bark_cxx::bolt11_invoice(static_cast<uint64_t>(amountMsat), nullptr);
1463
+ description_rs = std::make_unique<rust::String>(description.value());
1464
+ }
1465
+ if (token.has_value()) {
1466
+ token_rs = std::make_unique<rust::String>(token.value());
1445
1467
  }
1468
+ const auto invoice_rs = bark_cxx::bolt11_invoice(
1469
+ static_cast<uint64_t>(amountMsat), description_rs.get(), token_rs.get());
1446
1470
  return Bolt11Invoice(std::string(invoice_rs.bolt11_invoice.data(), invoice_rs.bolt11_invoice.length()),
1447
1471
  std::string(invoice_rs.payment_secret.data(), invoice_rs.payment_secret.length()),
1448
1472
  std::string(invoice_rs.payment_hash.data(), invoice_rs.payment_hash.length()));
@@ -1453,36 +1477,11 @@ public:
1453
1477
  }
1454
1478
 
1455
1479
  std::shared_ptr<Promise<LightningReceive>>
1456
- tryClaimLightningReceive(const std::string& paymentHash, bool wait,
1457
- const std::optional<std::string>& token) override {
1458
- 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 {
1459
1482
  try {
1460
- bark_cxx::LightningReceive result;
1461
- if (token.has_value()) {
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;
1483
+ const auto result = bark_cxx::try_claim_lightning_receive(paymentHash, wait);
1484
+ return convertRustLightningReceive(result);
1486
1485
  } catch (const rust::Error& e) {
1487
1486
  throw std::runtime_error(e.what());
1488
1487
  }
@@ -1499,36 +1498,11 @@ public:
1499
1498
  });
1500
1499
  }
1501
1500
 
1502
- std::shared_ptr<Promise<std::optional<LightningReceive>>>
1501
+ std::shared_ptr<Promise<LightningReceive>>
1503
1502
  lightningReceiveStatus(const std::string& paymentHash) override {
1504
- return Promise<std::optional<LightningReceive>>::async([paymentHash]() {
1503
+ return Promise<LightningReceive>::async([paymentHash]() {
1505
1504
  try {
1506
- const bark_cxx::LightningReceive* status_ptr = bark_cxx::lightning_receive_status(paymentHash);
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);
1505
+ return convertRustLightningReceive(bark_cxx::lightning_receive_status(paymentHash));
1532
1506
  } catch (const rust::Error& e) {
1533
1507
  throw std::runtime_error(e.what());
1534
1508
  }
@@ -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
- ::std::uint64_t const *preimage_revealed_at CXX_DEFAULT_VALUE(nullptr);
1347
- ::std::uint64_t const *finished_at CXX_DEFAULT_VALUE(nullptr);
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
  };
@@ -1618,6 +1624,8 @@ bool verify_message(::rust::Str message, ::rust::Str signature, ::rust::Str publ
1618
1624
 
1619
1625
  void dangerous_drop_vtxo(::rust::Str vtxo_id);
1620
1626
 
1627
+ void unlock_vtxos(::rust::Vec<::rust::String> vtxo_ids);
1628
+
1621
1629
  ::rust::Vec<::bark_cxx::BarkVtxo> get_expiring_vtxos(::std::uint32_t threshold);
1622
1630
 
1623
1631
  ::bark_cxx::DelegatedRoundState refresh_vtxos_delegated(::rust::Vec<::rust::String> vtxo_ids);
@@ -1626,9 +1634,9 @@ void dangerous_drop_vtxo(::rust::Str vtxo_id);
1626
1634
 
1627
1635
  ::std::uint32_t const *get_next_required_refresh_blockheight();
1628
1636
 
1629
- ::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);
1630
1638
 
1631
- ::bark_cxx::LightningReceive const *lightning_receive_status(::rust::String payment_hash);
1639
+ ::bark_cxx::LightningReceive lightning_receive_status(::rust::String payment_hash);
1632
1640
 
1633
1641
  ::bark_cxx::LightningPaymentResult check_lightning_payment(::rust::String payment_hash, bool wait);
1634
1642
 
@@ -1638,10 +1646,6 @@ void maintenance();
1638
1646
 
1639
1647
  void maintenance_delegated();
1640
1648
 
1641
- void maintenance_with_onchain();
1642
-
1643
- void maintenance_with_onchain_delegated();
1644
-
1645
1649
  void maintenance_refresh();
1646
1650
 
1647
1651
  void refresh_server();
@@ -1704,7 +1708,7 @@ bool has_pending_exits();
1704
1708
 
1705
1709
  ::bark_cxx::BarkFeeEstimate estimate_offboard_all(::rust::Str destination_address);
1706
1710
 
1707
- ::bark_cxx::LightningReceive try_claim_lightning_receive(::rust::String payment_hash, bool wait, ::rust::String const *token);
1711
+ ::bark_cxx::LightningReceive try_claim_lightning_receive(::rust::String payment_hash, bool wait);
1708
1712
 
1709
1713
  void try_claim_all_lightning_receives(bool wait);
1710
1714
 
@@ -5,37 +5,65 @@ 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
- history: stateHistory
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
- history: stateHistory
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
 
@@ -129,42 +157,16 @@ export function syncPendingBoards() {
129
157
  return NitroArkHybridObject.syncPendingBoards();
130
158
  }
131
159
 
132
- /**
133
- * Runs wallet maintenance tasks for offchain.
134
- * This includes refreshing vtxos that need to be refreshed.
135
- * @returns A promise that resolves on success.
136
- */
160
+ /** Runs wallet maintenance, including on-chain synchronization and exit progression. */
137
161
  export function maintenance() {
138
162
  return NitroArkHybridObject.maintenance();
139
163
  }
140
164
 
141
- /**
142
- * Runs wallet maintenance tasks for both offchain and onchain.
143
- * This includes refreshing vtxos that need to be refreshed.
144
- * @returns A promise that resolves on success.
145
- */
146
- export function maintenanceWithOnchain() {
147
- return NitroArkHybridObject.maintenanceWithOnchain();
148
- }
149
-
150
- /**
151
- * Runs delegated wallet maintenance tasks for offchain.
152
- * This includes refreshing vtxos that need to be refreshed using delegated signing.
153
- * @returns A promise that resolves on success.
154
- */
165
+ /** Runs delegated wallet maintenance, including on-chain synchronization. */
155
166
  export function maintenanceDelegated() {
156
167
  return NitroArkHybridObject.maintenanceDelegated();
157
168
  }
158
169
 
159
- /**
160
- * Runs delegated wallet maintenance tasks for both offchain and onchain.
161
- * This includes refreshing vtxos that need to be refreshed using delegated signing.
162
- * @returns A promise that resolves on success.
163
- */
164
- export function maintenanceWithOnchainDelegated() {
165
- return NitroArkHybridObject.maintenanceWithOnchainDelegated();
166
- }
167
-
168
170
  /**
169
171
  * Refreshes vtxos that need to be refreshed.
170
172
  * @returns A promise that resolves on success.
@@ -501,6 +503,15 @@ export function dangerousDropVtxo(vtxoId) {
501
503
  return NitroArkHybridObject.dangerousDropVtxo(vtxoId);
502
504
  }
503
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
+
504
515
  /**
505
516
  * Gets the first expiring VTXO blockheight for the loaded wallet.
506
517
  * @returns A promise resolving to the first expiring VTXO blockheight.
@@ -624,8 +635,8 @@ export function onchainSendMany(outputs) {
624
635
  * @param description Optional invoice description/memo.
625
636
  * @returns A promise resolving to Bolt11Invoice object.
626
637
  */
627
- export function bolt11Invoice(amountMsat, description) {
628
- return NitroArkHybridObject.bolt11Invoice(amountMsat, description);
638
+ export function bolt11Invoice(amountMsat, description, token) {
639
+ return NitroArkHybridObject.bolt11Invoice(amountMsat, description, token);
629
640
  }
630
641
 
631
642
  /**
@@ -634,7 +645,7 @@ export function bolt11Invoice(amountMsat, description) {
634
645
  * @returns A promise resolving to the Lightning receive status.
635
646
  */
636
647
  export function lightningReceiveStatus(paymentHash) {
637
- return NitroArkHybridObject.lightningReceiveStatus(paymentHash);
648
+ return NitroArkHybridObject.lightningReceiveStatus(paymentHash).then(enrichLightningReceive);
638
649
  }
639
650
 
640
651
  /**
@@ -651,14 +662,13 @@ export function checkLightningPayment(paymentHash, wait) {
651
662
  }
652
663
 
653
664
  /**
654
- * Attempts to claim a Lightning payment, optionally using a claim token.
665
+ * Attempts to claim a Lightning payment.
655
666
  * @param paymentHash The payment hash of the Lightning payment.
656
667
  * @param wait Whether to wait for the claim to complete.
657
- * @param token Optional claim token used when no spendable VTXOs are owned.
658
- * @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.
659
669
  */
660
- export function tryClaimLightningReceive(paymentHash, wait, token) {
661
- return NitroArkHybridObject.tryClaimLightningReceive(paymentHash, wait, token);
670
+ export function tryClaimLightningReceive(paymentHash, wait) {
671
+ return NitroArkHybridObject.tryClaimLightningReceive(paymentHash, wait).then(enrichLightningReceive);
662
672
  }
663
673
 
664
674
  /**