react-native-nitro-ark 0.0.29 → 0.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cpp/NitroArk.hpp +137 -72
- package/cpp/generated/ark_cxx.h +35 -27
- package/lib/module/index.js +101 -47
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NitroArk.nitro.d.ts +23 -17
- package/lib/typescript/src/NitroArk.nitro.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +71 -32
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/nitrogen/generated/shared/c++/BarkArkInfo.hpp +93 -0
- package/nitrogen/generated/shared/c++/HybridNitroArkSpec.cpp +11 -3
- package/nitrogen/generated/shared/c++/HybridNitroArkSpec.hpp +21 -13
- package/package.json +1 -1
- package/src/NitroArk.nitro.ts +29 -39
- package/src/index.tsx +113 -80
- package/nitrogen/generated/shared/c++/BarkBalance.hpp +0 -77
- package/nitrogen/generated/shared/c++/BarkRefreshModeType.hpp +0 -94
- package/nitrogen/generated/shared/c++/BarkRefreshOpts.hpp +0 -81
package/cpp/NitroArk.hpp
CHANGED
|
@@ -58,7 +58,8 @@ namespace margelo::nitro::nitroark
|
|
|
58
58
|
create_opts.signet = opts.signet.value_or(false);
|
|
59
59
|
create_opts.bitcoin = opts.bitcoin.value_or(true);
|
|
60
60
|
create_opts.mnemonic = opts.mnemonic;
|
|
61
|
-
|
|
61
|
+
uint32_t birthday_height_val = opts.birthday_height.value_or(0);
|
|
62
|
+
create_opts.birthday_height = opts.birthday_height.has_value() ? &birthday_height_val : nullptr;
|
|
62
63
|
create_opts.config = config_opts;
|
|
63
64
|
|
|
64
65
|
bark_cxx::load_wallet(datadir, create_opts);
|
|
@@ -84,18 +85,110 @@ namespace margelo::nitro::nitroark
|
|
|
84
85
|
{ return bark_cxx::is_wallet_loaded(); });
|
|
85
86
|
}
|
|
86
87
|
|
|
88
|
+
std::shared_ptr<Promise<void>>
|
|
89
|
+
persistConfig(const BarkConfigOpts &opts) override
|
|
90
|
+
{
|
|
91
|
+
return Promise<void>::async([opts]()
|
|
92
|
+
{
|
|
93
|
+
try {
|
|
94
|
+
bark_cxx::ConfigOpts config_opts;
|
|
95
|
+
config_opts.asp = opts.asp.value_or("");
|
|
96
|
+
config_opts.esplora = opts.esplora.value_or("");
|
|
97
|
+
config_opts.bitcoind = opts.bitcoind.value_or("");
|
|
98
|
+
config_opts.bitcoind_cookie = opts.bitcoind_cookie.value_or("");
|
|
99
|
+
config_opts.bitcoind_user = opts.bitcoind_user.value_or("");
|
|
100
|
+
config_opts.bitcoind_pass = opts.bitcoind_pass.value_or("");
|
|
101
|
+
config_opts.vtxo_refresh_expiry_threshold = static_cast<uint32_t>(opts.vtxo_refresh_expiry_threshold.value_or(0));
|
|
102
|
+
config_opts.fallback_fee_rate = static_cast<uint64_t>(opts.fallback_fee_rate.value_or(0));
|
|
103
|
+
bark_cxx::persist_config(config_opts);
|
|
104
|
+
} catch (const rust::Error &e) {
|
|
105
|
+
throw std::runtime_error(e.what());
|
|
106
|
+
} });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
std::shared_ptr<Promise<void>> maintenance() override
|
|
110
|
+
{
|
|
111
|
+
return Promise<void>::async([]()
|
|
112
|
+
{
|
|
113
|
+
try {
|
|
114
|
+
bark_cxx::maintenance();
|
|
115
|
+
} catch (const rust::Error &e) {
|
|
116
|
+
throw std::runtime_error(e.what());
|
|
117
|
+
} });
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
std::shared_ptr<Promise<void>> sync() override
|
|
121
|
+
{
|
|
122
|
+
return Promise<void>::async([]()
|
|
123
|
+
{
|
|
124
|
+
try {
|
|
125
|
+
bark_cxx::sync();
|
|
126
|
+
} catch (const rust::Error &e) {
|
|
127
|
+
throw std::runtime_error(e.what());
|
|
128
|
+
} });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
std::shared_ptr<Promise<void>> syncArk() override
|
|
132
|
+
{
|
|
133
|
+
return Promise<void>::async([]()
|
|
134
|
+
{
|
|
135
|
+
try {
|
|
136
|
+
bark_cxx::sync_ark();
|
|
137
|
+
} catch (const rust::Error &e) {
|
|
138
|
+
throw std::runtime_error(e.what());
|
|
139
|
+
} });
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
std::shared_ptr<Promise<void>> syncRounds() override
|
|
143
|
+
{
|
|
144
|
+
return Promise<void>::async([]()
|
|
145
|
+
{
|
|
146
|
+
try {
|
|
147
|
+
bark_cxx::sync_rounds();
|
|
148
|
+
} catch (const rust::Error &e) {
|
|
149
|
+
throw std::runtime_error(e.what());
|
|
150
|
+
} });
|
|
151
|
+
}
|
|
152
|
+
|
|
87
153
|
// --- Wallet Info ---
|
|
88
154
|
|
|
89
|
-
std::shared_ptr<Promise<
|
|
90
|
-
getBalance(bool no_sync) override
|
|
155
|
+
std::shared_ptr<Promise<BarkArkInfo>> getArkInfo() override
|
|
91
156
|
{
|
|
92
|
-
return Promise<
|
|
157
|
+
return Promise<BarkArkInfo>::async([]()
|
|
93
158
|
{
|
|
94
159
|
try {
|
|
95
|
-
bark_cxx::
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
160
|
+
bark_cxx::CxxArkInfo rust_info = bark_cxx::get_ark_info();
|
|
161
|
+
BarkArkInfo info;
|
|
162
|
+
info.network = std::string(rust_info.network.data(), rust_info.network.length());
|
|
163
|
+
info.asp_pubkey = std::string(rust_info.asp_pubkey.data(), rust_info.asp_pubkey.length());
|
|
164
|
+
info.round_interval_secs = static_cast<double>(rust_info.round_interval_secs);
|
|
165
|
+
info.vtxo_exit_delta = static_cast<double>(rust_info.vtxo_exit_delta);
|
|
166
|
+
info.vtxo_expiry_delta = static_cast<double>(rust_info.vtxo_expiry_delta);
|
|
167
|
+
info.htlc_expiry_delta = static_cast<double>(rust_info.htlc_expiry_delta);
|
|
168
|
+
info.max_vtxo_amount_sat = static_cast<double>(rust_info.max_vtxo_amount_sat);
|
|
169
|
+
return info;
|
|
170
|
+
} catch (const rust::Error &e) {
|
|
171
|
+
throw std::runtime_error(e.what());
|
|
172
|
+
} });
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
std::shared_ptr<Promise<double>> onchainBalance() override
|
|
176
|
+
{
|
|
177
|
+
return Promise<double>::async([]()
|
|
178
|
+
{
|
|
179
|
+
try {
|
|
180
|
+
return static_cast<double>(bark_cxx::onchain_balance());
|
|
181
|
+
} catch (const rust::Error &e) {
|
|
182
|
+
throw std::runtime_error(e.what());
|
|
183
|
+
} });
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
std::shared_ptr<Promise<double>> offchainBalance() override
|
|
187
|
+
{
|
|
188
|
+
return Promise<double>::async([]()
|
|
189
|
+
{
|
|
190
|
+
try {
|
|
191
|
+
return static_cast<double>(bark_cxx::offchain_balance());
|
|
99
192
|
} catch (const rust::Error &e) {
|
|
100
193
|
throw std::runtime_error(e.what());
|
|
101
194
|
} });
|
|
@@ -133,8 +226,8 @@ namespace margelo::nitro::nitroark
|
|
|
133
226
|
return Promise<std::string>::async([index]()
|
|
134
227
|
{
|
|
135
228
|
try {
|
|
136
|
-
uint32_t index_val = index.has_value() ? static_cast<uint32_t>(index.value()) :
|
|
137
|
-
rust::String pubkey_rs = bark_cxx::get_vtxo_pubkey(index_val);
|
|
229
|
+
uint32_t index_val = index.has_value() ? static_cast<uint32_t>(index.value()) : 0;
|
|
230
|
+
rust::String pubkey_rs = bark_cxx::get_vtxo_pubkey(index.has_value() ? &index_val : nullptr);
|
|
138
231
|
return std::string(pubkey_rs.data(), pubkey_rs.length());
|
|
139
232
|
} catch (const rust::Error &e) {
|
|
140
233
|
throw std::runtime_error(e.what());
|
|
@@ -205,69 +298,39 @@ namespace margelo::nitro::nitroark
|
|
|
205
298
|
} });
|
|
206
299
|
}
|
|
207
300
|
|
|
208
|
-
// --- Ark
|
|
301
|
+
// --- Ark & Lightning Payments ---
|
|
209
302
|
|
|
210
|
-
std::shared_ptr<Promise<std::string>>
|
|
211
|
-
refreshVtxos(const BarkRefreshOpts &refreshOpts, bool no_sync) override
|
|
303
|
+
std::shared_ptr<Promise<std::string>> boardAmount(double amountSat) override
|
|
212
304
|
{
|
|
213
|
-
return Promise<std::string>::async([
|
|
214
|
-
no_sync]()
|
|
305
|
+
return Promise<std::string>::async([amountSat]()
|
|
215
306
|
{
|
|
216
307
|
try {
|
|
217
|
-
bark_cxx::
|
|
218
|
-
switch (refreshOpts.mode_type) {
|
|
219
|
-
case BarkRefreshModeType::DEFAULTTHRESHOLD:
|
|
220
|
-
opts.mode_type = bark_cxx::RefreshModeType::DefaultThreshold;
|
|
221
|
-
break;
|
|
222
|
-
case BarkRefreshModeType::THRESHOLDBLOCKS:
|
|
223
|
-
opts.mode_type = bark_cxx::RefreshModeType::ThresholdBlocks;
|
|
224
|
-
break;
|
|
225
|
-
case BarkRefreshModeType::THRESHOLDHOURS:
|
|
226
|
-
opts.mode_type = bark_cxx::RefreshModeType::ThresholdHours;
|
|
227
|
-
break;
|
|
228
|
-
case BarkRefreshModeType::COUNTERPARTY:
|
|
229
|
-
opts.mode_type = bark_cxx::RefreshModeType::Counterparty;
|
|
230
|
-
break;
|
|
231
|
-
case BarkRefreshModeType::ALL:
|
|
232
|
-
opts.mode_type = bark_cxx::RefreshModeType::All;
|
|
233
|
-
break;
|
|
234
|
-
case BarkRefreshModeType::SPECIFIC:
|
|
235
|
-
opts.mode_type = bark_cxx::RefreshModeType::Specific;
|
|
236
|
-
break;
|
|
237
|
-
}
|
|
238
|
-
opts.threshold_value = static_cast<uint32_t>(refreshOpts.threshold_value.value_or(0));
|
|
239
|
-
if (refreshOpts.specific_vtxo_ids.has_value()) {
|
|
240
|
-
for (const auto &id : refreshOpts.specific_vtxo_ids.value()) {
|
|
241
|
-
opts.specific_vtxo_ids.push_back(id);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
rust::String status_rs = bark_cxx::refresh_vtxos(opts, no_sync);
|
|
308
|
+
rust::String status_rs = bark_cxx::board_amount(static_cast<uint64_t>(amountSat));
|
|
245
309
|
return std::string(status_rs.data(), status_rs.length());
|
|
246
310
|
} catch (const rust::Error &e) {
|
|
247
311
|
throw std::runtime_error(e.what());
|
|
248
312
|
} });
|
|
249
313
|
}
|
|
250
314
|
|
|
251
|
-
std::shared_ptr<Promise<std::string>>
|
|
252
|
-
bool no_sync) override
|
|
315
|
+
std::shared_ptr<Promise<std::string>> boardAll() override
|
|
253
316
|
{
|
|
254
|
-
return Promise<std::string>::async([
|
|
255
|
-
no_sync]()
|
|
317
|
+
return Promise<std::string>::async([]()
|
|
256
318
|
{
|
|
257
319
|
try {
|
|
258
|
-
rust::String status_rs = bark_cxx::
|
|
320
|
+
rust::String status_rs = bark_cxx::board_all();
|
|
259
321
|
return std::string(status_rs.data(), status_rs.length());
|
|
260
322
|
} catch (const rust::Error &e) {
|
|
261
323
|
throw std::runtime_error(e.what());
|
|
262
324
|
} });
|
|
263
325
|
}
|
|
264
326
|
|
|
265
|
-
std::shared_ptr<Promise<std::string>>
|
|
327
|
+
std::shared_ptr<Promise<std::string>>
|
|
328
|
+
sendArkoorPayment(const std::string &destination, double amountSat) override
|
|
266
329
|
{
|
|
267
|
-
return Promise<std::string>::async([
|
|
330
|
+
return Promise<std::string>::async([destination, amountSat]()
|
|
268
331
|
{
|
|
269
332
|
try {
|
|
270
|
-
rust::String status_rs = bark_cxx::
|
|
333
|
+
rust::String status_rs = bark_cxx::send_arkoor_payment(destination, static_cast<uint64_t>(amountSat));
|
|
271
334
|
return std::string(status_rs.data(), status_rs.length());
|
|
272
335
|
} catch (const rust::Error &e) {
|
|
273
336
|
throw std::runtime_error(e.what());
|
|
@@ -275,21 +338,25 @@ namespace margelo::nitro::nitroark
|
|
|
275
338
|
}
|
|
276
339
|
|
|
277
340
|
std::shared_ptr<Promise<std::string>>
|
|
278
|
-
|
|
279
|
-
const std::optional<std::string> &comment, bool no_sync) override
|
|
341
|
+
sendBolt11Payment(const std::string &destination, double amountSat) override
|
|
280
342
|
{
|
|
281
|
-
return Promise<std::string>::async([destination, amountSat
|
|
343
|
+
return Promise<std::string>::async([destination, amountSat]()
|
|
282
344
|
{
|
|
283
345
|
try {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
346
|
+
rust::String status_rs = bark_cxx::send_bolt11_payment(destination, static_cast<uint64_t>(amountSat));
|
|
347
|
+
return std::string(status_rs.data(), status_rs.length());
|
|
348
|
+
} catch (const rust::Error &e) {
|
|
349
|
+
throw std::runtime_error(e.what());
|
|
350
|
+
} });
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
std::shared_ptr<Promise<std::string>>
|
|
354
|
+
sendLnaddr(const std::string &addr, double amountSat, const std::string &comment) override
|
|
355
|
+
{
|
|
356
|
+
return Promise<std::string>::async([addr, amountSat, comment]()
|
|
357
|
+
{
|
|
358
|
+
try {
|
|
359
|
+
rust::String status_rs = bark_cxx::send_lnaddr(addr, static_cast<uint64_t>(amountSat), comment);
|
|
293
360
|
return std::string(status_rs.data(), status_rs.length());
|
|
294
361
|
} catch (const rust::Error &e) {
|
|
295
362
|
throw std::runtime_error(e.what());
|
|
@@ -315,7 +382,7 @@ namespace margelo::nitro::nitroark
|
|
|
315
382
|
});
|
|
316
383
|
}
|
|
317
384
|
|
|
318
|
-
// --- Lightning
|
|
385
|
+
// --- Lightning Invoicing ---
|
|
319
386
|
|
|
320
387
|
std::shared_ptr<Promise<std::string>>
|
|
321
388
|
bolt11Invoice(double amountMsat) override
|
|
@@ -346,11 +413,11 @@ namespace margelo::nitro::nitroark
|
|
|
346
413
|
|
|
347
414
|
std::shared_ptr<Promise<std::string>>
|
|
348
415
|
offboardSpecific(const std::vector<std::string> &vtxoIds,
|
|
349
|
-
const std::
|
|
416
|
+
const std::string &destinationAddress,
|
|
350
417
|
bool no_sync) override
|
|
351
418
|
{
|
|
352
419
|
return Promise<std::string>::async(
|
|
353
|
-
[vtxoIds,
|
|
420
|
+
[vtxoIds, destinationAddress, no_sync]()
|
|
354
421
|
{
|
|
355
422
|
try
|
|
356
423
|
{
|
|
@@ -359,8 +426,7 @@ namespace margelo::nitro::nitroark
|
|
|
359
426
|
{
|
|
360
427
|
rust_vtxo_ids.push_back(rust::String(id));
|
|
361
428
|
}
|
|
362
|
-
|
|
363
|
-
rust::String status_rs = bark_cxx::offboard_specific(std::move(rust_vtxo_ids), address, no_sync);
|
|
429
|
+
rust::String status_rs = bark_cxx::offboard_specific(std::move(rust_vtxo_ids), destinationAddress, no_sync);
|
|
364
430
|
return std::string(status_rs.data(), status_rs.length());
|
|
365
431
|
}
|
|
366
432
|
catch (const rust::Error &e)
|
|
@@ -371,15 +437,14 @@ namespace margelo::nitro::nitroark
|
|
|
371
437
|
}
|
|
372
438
|
|
|
373
439
|
std::shared_ptr<Promise<std::string>>
|
|
374
|
-
offboardAll(const std::
|
|
440
|
+
offboardAll(const std::string &destinationAddress,
|
|
375
441
|
bool no_sync) override
|
|
376
442
|
{
|
|
377
|
-
return Promise<std::string>::async([
|
|
443
|
+
return Promise<std::string>::async([destinationAddress,
|
|
378
444
|
no_sync]()
|
|
379
445
|
{
|
|
380
446
|
try {
|
|
381
|
-
|
|
382
|
-
rust::String status_rs = bark_cxx::offboard_all(address, no_sync);
|
|
447
|
+
rust::String status_rs = bark_cxx::offboard_all(destinationAddress, no_sync);
|
|
383
448
|
return std::string(status_rs.data(), status_rs.length());
|
|
384
449
|
} catch (const rust::Error &e) {
|
|
385
450
|
throw std::runtime_error(e.what());
|
package/cpp/generated/ark_cxx.h
CHANGED
|
@@ -797,25 +797,28 @@ std::size_t align_of() {
|
|
|
797
797
|
#endif
|
|
798
798
|
|
|
799
799
|
namespace bark_cxx {
|
|
800
|
-
struct
|
|
800
|
+
struct CxxArkInfo;
|
|
801
801
|
struct ConfigOpts;
|
|
802
802
|
struct CreateOpts;
|
|
803
803
|
struct SendManyOutput;
|
|
804
804
|
enum class RefreshModeType : ::std::uint8_t;
|
|
805
|
-
struct RefreshOpts;
|
|
806
805
|
}
|
|
807
806
|
|
|
808
807
|
namespace bark_cxx {
|
|
809
|
-
#ifndef CXXBRIDGE1_STRUCT_bark_cxx$
|
|
810
|
-
#define CXXBRIDGE1_STRUCT_bark_cxx$
|
|
811
|
-
struct
|
|
812
|
-
::
|
|
813
|
-
::
|
|
814
|
-
::std::uint64_t
|
|
808
|
+
#ifndef CXXBRIDGE1_STRUCT_bark_cxx$CxxArkInfo
|
|
809
|
+
#define CXXBRIDGE1_STRUCT_bark_cxx$CxxArkInfo
|
|
810
|
+
struct CxxArkInfo final {
|
|
811
|
+
::rust::String network;
|
|
812
|
+
::rust::String asp_pubkey;
|
|
813
|
+
::std::uint64_t round_interval_secs CXX_DEFAULT_VALUE(0);
|
|
814
|
+
::std::uint16_t vtxo_exit_delta CXX_DEFAULT_VALUE(0);
|
|
815
|
+
::std::uint16_t vtxo_expiry_delta CXX_DEFAULT_VALUE(0);
|
|
816
|
+
::std::uint16_t htlc_expiry_delta CXX_DEFAULT_VALUE(0);
|
|
817
|
+
::std::uint64_t max_vtxo_amount_sat CXX_DEFAULT_VALUE(0);
|
|
815
818
|
|
|
816
819
|
using IsRelocatable = ::std::true_type;
|
|
817
820
|
};
|
|
818
|
-
#endif // CXXBRIDGE1_STRUCT_bark_cxx$
|
|
821
|
+
#endif // CXXBRIDGE1_STRUCT_bark_cxx$CxxArkInfo
|
|
819
822
|
|
|
820
823
|
#ifndef CXXBRIDGE1_STRUCT_bark_cxx$ConfigOpts
|
|
821
824
|
#define CXXBRIDGE1_STRUCT_bark_cxx$ConfigOpts
|
|
@@ -840,7 +843,7 @@ struct CreateOpts final {
|
|
|
840
843
|
bool signet CXX_DEFAULT_VALUE(false);
|
|
841
844
|
bool bitcoin CXX_DEFAULT_VALUE(false);
|
|
842
845
|
::rust::String mnemonic;
|
|
843
|
-
::std::uint32_t birthday_height CXX_DEFAULT_VALUE(
|
|
846
|
+
::std::uint32_t const *birthday_height CXX_DEFAULT_VALUE(nullptr);
|
|
844
847
|
::bark_cxx::ConfigOpts config;
|
|
845
848
|
|
|
846
849
|
using IsRelocatable = ::std::true_type;
|
|
@@ -869,17 +872,6 @@ enum class RefreshModeType : ::std::uint8_t {
|
|
|
869
872
|
};
|
|
870
873
|
#endif // CXXBRIDGE1_ENUM_bark_cxx$RefreshModeType
|
|
871
874
|
|
|
872
|
-
#ifndef CXXBRIDGE1_STRUCT_bark_cxx$RefreshOpts
|
|
873
|
-
#define CXXBRIDGE1_STRUCT_bark_cxx$RefreshOpts
|
|
874
|
-
struct RefreshOpts final {
|
|
875
|
-
::bark_cxx::RefreshModeType mode_type;
|
|
876
|
-
::std::uint32_t threshold_value CXX_DEFAULT_VALUE(0);
|
|
877
|
-
::rust::Vec<::rust::String> specific_vtxo_ids;
|
|
878
|
-
|
|
879
|
-
using IsRelocatable = ::std::true_type;
|
|
880
|
-
};
|
|
881
|
-
#endif // CXXBRIDGE1_STRUCT_bark_cxx$RefreshOpts
|
|
882
|
-
|
|
883
875
|
void init_logger() noexcept;
|
|
884
876
|
|
|
885
877
|
::rust::String create_mnemonic();
|
|
@@ -888,13 +880,19 @@ bool is_wallet_loaded() noexcept;
|
|
|
888
880
|
|
|
889
881
|
void close_wallet();
|
|
890
882
|
|
|
883
|
+
void persist_config(::bark_cxx::ConfigOpts opts);
|
|
884
|
+
|
|
885
|
+
::bark_cxx::CxxArkInfo get_ark_info();
|
|
886
|
+
|
|
891
887
|
::rust::String get_onchain_address();
|
|
892
888
|
|
|
893
|
-
::
|
|
889
|
+
::std::uint64_t offchain_balance();
|
|
890
|
+
|
|
891
|
+
::std::uint64_t onchain_balance();
|
|
894
892
|
|
|
895
893
|
::rust::String get_onchain_utxos(bool no_sync);
|
|
896
894
|
|
|
897
|
-
::rust::String get_vtxo_pubkey(::std::uint32_t index);
|
|
895
|
+
::rust::String get_vtxo_pubkey(::std::uint32_t const *index);
|
|
898
896
|
|
|
899
897
|
::rust::String get_vtxos(bool no_sync);
|
|
900
898
|
|
|
@@ -902,6 +900,14 @@ void close_wallet();
|
|
|
902
900
|
|
|
903
901
|
void claim_bolt11_payment(::rust::Str bolt11);
|
|
904
902
|
|
|
903
|
+
void maintenance();
|
|
904
|
+
|
|
905
|
+
void sync();
|
|
906
|
+
|
|
907
|
+
void sync_ark();
|
|
908
|
+
|
|
909
|
+
void sync_rounds();
|
|
910
|
+
|
|
905
911
|
void load_wallet(::rust::Str datadir, ::bark_cxx::CreateOpts opts);
|
|
906
912
|
|
|
907
913
|
::rust::String send_onchain(::rust::Str destination, ::std::uint64_t amount_sat, bool no_sync);
|
|
@@ -910,13 +916,15 @@ void load_wallet(::rust::Str datadir, ::bark_cxx::CreateOpts opts);
|
|
|
910
916
|
|
|
911
917
|
::rust::String send_many_onchain(::rust::Vec<::bark_cxx::SendManyOutput> outputs, bool no_sync);
|
|
912
918
|
|
|
913
|
-
::rust::String
|
|
919
|
+
::rust::String board_amount(::std::uint64_t amount_sat);
|
|
920
|
+
|
|
921
|
+
::rust::String board_all();
|
|
914
922
|
|
|
915
|
-
::rust::String
|
|
923
|
+
::rust::String send_arkoor_payment(::rust::Str destination, ::std::uint64_t amount_sat);
|
|
916
924
|
|
|
917
|
-
::rust::String
|
|
925
|
+
::rust::String send_bolt11_payment(::rust::Str destination, ::std::uint64_t amount_sat);
|
|
918
926
|
|
|
919
|
-
::rust::String
|
|
927
|
+
::rust::String send_lnaddr(::rust::Str addr, ::std::uint64_t amount_sat, ::rust::Str comment);
|
|
920
928
|
|
|
921
929
|
::rust::String send_round_onchain(::rust::Str destination, ::std::uint64_t amount_sat, bool no_sync);
|
|
922
930
|
|
package/lib/module/index.js
CHANGED
|
@@ -41,15 +41,71 @@ export function isWalletLoaded() {
|
|
|
41
41
|
return NitroArkHybridObject.isWalletLoaded();
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Persists wallet configuration.
|
|
46
|
+
* @param opts The configuration options to persist.
|
|
47
|
+
* @returns A promise that resolves on success or rejects on error.
|
|
48
|
+
*/
|
|
49
|
+
export function persistConfig(opts) {
|
|
50
|
+
return NitroArkHybridObject.persistConfig(opts);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Runs wallet maintenance tasks.
|
|
55
|
+
* @returns A promise that resolves on success.
|
|
56
|
+
*/
|
|
57
|
+
export function maintenance() {
|
|
58
|
+
return NitroArkHybridObject.maintenance();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Synchronizes the wallet with the blockchain.
|
|
63
|
+
* @returns A promise that resolves on success.
|
|
64
|
+
*/
|
|
65
|
+
export function sync() {
|
|
66
|
+
return NitroArkHybridObject.sync();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Synchronizes the Ark-specific parts of the wallet.
|
|
71
|
+
* @returns A promise that resolves on success.
|
|
72
|
+
*/
|
|
73
|
+
export function syncArk() {
|
|
74
|
+
return NitroArkHybridObject.syncArk();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Synchronizes the rounds of the wallet.
|
|
79
|
+
* @returns A promise that resolves on success.
|
|
80
|
+
*/
|
|
81
|
+
export function syncRounds() {
|
|
82
|
+
return NitroArkHybridObject.syncRounds();
|
|
83
|
+
}
|
|
84
|
+
|
|
44
85
|
// --- Wallet Info ---
|
|
45
86
|
|
|
46
87
|
/**
|
|
47
|
-
* Gets the
|
|
48
|
-
* @
|
|
49
|
-
* @returns A promise resolving to the BarkBalance object.
|
|
88
|
+
* Gets the Ark-specific information.
|
|
89
|
+
* @returns A promise resolving to the BarkArkInfo object.
|
|
50
90
|
*/
|
|
51
|
-
export function
|
|
52
|
-
return NitroArkHybridObject.
|
|
91
|
+
export function getArkInfo() {
|
|
92
|
+
return NitroArkHybridObject.getArkInfo();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Gets the onchain balance for the loaded wallet.
|
|
97
|
+
* @returns A promise resolving to the onchain balance in satoshis.
|
|
98
|
+
*/
|
|
99
|
+
export function onchainBalance() {
|
|
100
|
+
return NitroArkHybridObject.onchainBalance();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Gets the offchain balance for the loaded wallet.
|
|
105
|
+
* @returns A promise resolving to the offchain balance in satoshis.
|
|
106
|
+
*/
|
|
107
|
+
export function offchainBalance() {
|
|
108
|
+
return NitroArkHybridObject.offchainBalance();
|
|
53
109
|
}
|
|
54
110
|
|
|
55
111
|
/**
|
|
@@ -71,7 +127,7 @@ export function getOnchainUtxos(no_sync = false) {
|
|
|
71
127
|
|
|
72
128
|
/**
|
|
73
129
|
* Gets the wallet's VTXO public key (hex string).
|
|
74
|
-
* @param index
|
|
130
|
+
* @param index Index of the VTXO pubkey to retrieve. Use u32::MAX for a new one.
|
|
75
131
|
* @returns A promise resolving to the hex-encoded public key string.
|
|
76
132
|
*/
|
|
77
133
|
export function getVtxoPubkey(index) {
|
|
@@ -143,53 +199,51 @@ export function claimBolt11Payment(bolt11) {
|
|
|
143
199
|
// --- Ark Operations ---
|
|
144
200
|
|
|
145
201
|
/**
|
|
146
|
-
*
|
|
147
|
-
* @param
|
|
148
|
-
* @param no_sync If true, skips synchronization with the blockchain. Defaults to false.
|
|
202
|
+
* Boards a specific amount from the onchain wallet into Ark.
|
|
203
|
+
* @param amountSat The amount in satoshis to board.
|
|
149
204
|
* @returns A promise resolving to a JSON status string.
|
|
150
205
|
*/
|
|
151
|
-
export function
|
|
152
|
-
|
|
153
|
-
return Promise.reject(new Error('refreshVtxos requires refreshOpts.mode_type'));
|
|
154
|
-
}
|
|
155
|
-
if (refreshOpts.mode_type === 'Specific' && (!refreshOpts.specific_vtxo_ids || refreshOpts.specific_vtxo_ids.length === 0)) {
|
|
156
|
-
return Promise.reject(new Error("refreshVtxos with mode_type 'Specific' requires non-empty specific_vtxo_ids array"));
|
|
157
|
-
}
|
|
158
|
-
if ((refreshOpts.mode_type === 'ThresholdBlocks' || refreshOpts.mode_type === 'ThresholdHours') && (refreshOpts.threshold_value === undefined || refreshOpts.threshold_value <= 0)) {
|
|
159
|
-
return Promise.reject(new Error(`refreshVtxos with mode_type '${refreshOpts.mode_type}' requires a positive threshold_value`));
|
|
160
|
-
}
|
|
161
|
-
return NitroArkHybridObject.refreshVtxos(refreshOpts, no_sync);
|
|
206
|
+
export function boardAmount(amountSat) {
|
|
207
|
+
return NitroArkHybridObject.boardAmount(amountSat);
|
|
162
208
|
}
|
|
163
209
|
|
|
164
210
|
/**
|
|
165
|
-
* Boards
|
|
166
|
-
* @param amountSat The amount in satoshis to board.
|
|
167
|
-
* @param no_sync If true, skips synchronization with the onchain wallet. Defaults to false.
|
|
211
|
+
* Boards all available funds from the onchain wallet into Ark.
|
|
168
212
|
* @returns A promise resolving to a JSON status string.
|
|
169
213
|
*/
|
|
170
|
-
export function
|
|
171
|
-
return NitroArkHybridObject.
|
|
214
|
+
export function boardAll() {
|
|
215
|
+
return NitroArkHybridObject.boardAll();
|
|
172
216
|
}
|
|
173
217
|
|
|
174
218
|
/**
|
|
175
|
-
*
|
|
176
|
-
* @param
|
|
177
|
-
* @
|
|
219
|
+
* Sends an Arkoor payment.
|
|
220
|
+
* @param destination The destination Arkoor address.
|
|
221
|
+
* @param amountSat The amount in satoshis to send.
|
|
222
|
+
* @returns A promise resolving to a result string.
|
|
178
223
|
*/
|
|
179
|
-
export function
|
|
180
|
-
return NitroArkHybridObject.
|
|
224
|
+
export function sendArkoorPayment(destination, amountSat) {
|
|
225
|
+
return NitroArkHybridObject.sendArkoorPayment(destination, amountSat);
|
|
181
226
|
}
|
|
182
227
|
|
|
183
228
|
/**
|
|
184
|
-
* Sends
|
|
185
|
-
* @param destination
|
|
229
|
+
* Sends a Bolt11 payment.
|
|
230
|
+
* @param destination The Bolt11 invoice.
|
|
231
|
+
* @param amountSat The amount in satoshis to send. Use 0 for invoice amount.
|
|
232
|
+
* @returns A promise resolving to a result string.
|
|
233
|
+
*/
|
|
234
|
+
export function sendBolt11Payment(destination, amountSat) {
|
|
235
|
+
return NitroArkHybridObject.sendBolt11Payment(destination, amountSat);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Sends a payment to a Lightning Address.
|
|
240
|
+
* @param addr The Lightning Address.
|
|
186
241
|
* @param amountSat The amount in satoshis to send.
|
|
187
|
-
* @param comment
|
|
188
|
-
* @
|
|
189
|
-
* @returns A promise resolving to a JSON status string.
|
|
242
|
+
* @param comment An optional comment.
|
|
243
|
+
* @returns A promise resolving to a result string.
|
|
190
244
|
*/
|
|
191
|
-
export function
|
|
192
|
-
return NitroArkHybridObject.
|
|
245
|
+
export function sendLnaddr(addr, amountSat, comment) {
|
|
246
|
+
return NitroArkHybridObject.sendLnaddr(addr, amountSat, comment);
|
|
193
247
|
}
|
|
194
248
|
|
|
195
249
|
/**
|
|
@@ -206,24 +260,24 @@ export function sendRoundOnchain(destination, amountSat, no_sync = false) {
|
|
|
206
260
|
// --- Offboarding / Exiting ---
|
|
207
261
|
|
|
208
262
|
/**
|
|
209
|
-
* Offboards specific VTXOs to
|
|
263
|
+
* Offboards specific VTXOs to a destination address.
|
|
210
264
|
* @param vtxoIds Array of VtxoId strings to offboard.
|
|
211
|
-
* @param
|
|
265
|
+
* @param destinationAddress Destination Bitcoin address (if empty, sends to internal wallet).
|
|
212
266
|
* @param no_sync If true, skips synchronization with the wallet. Defaults to false.
|
|
213
267
|
* @returns A promise resolving to a JSON result string.
|
|
214
268
|
*/
|
|
215
|
-
export function offboardSpecific(vtxoIds,
|
|
216
|
-
return NitroArkHybridObject.offboardSpecific(vtxoIds,
|
|
269
|
+
export function offboardSpecific(vtxoIds, destinationAddress, no_sync = false) {
|
|
270
|
+
return NitroArkHybridObject.offboardSpecific(vtxoIds, destinationAddress, no_sync);
|
|
217
271
|
}
|
|
218
272
|
|
|
219
273
|
/**
|
|
220
|
-
* Offboards all VTXOs to
|
|
221
|
-
* @param
|
|
274
|
+
* Offboards all VTXOs to a destination address.
|
|
275
|
+
* @param destinationAddress Destination Bitcoin address (if empty, sends to internal wallet).
|
|
222
276
|
* @param no_sync If true, skips synchronization with the wallet. Defaults to false.
|
|
223
277
|
* @returns A promise resolving to a JSON result string.
|
|
224
278
|
*/
|
|
225
|
-
export function offboardAll(
|
|
226
|
-
return NitroArkHybridObject.offboardAll(
|
|
279
|
+
export function offboardAll(destinationAddress, no_sync = false) {
|
|
280
|
+
return NitroArkHybridObject.offboardAll(destinationAddress, no_sync);
|
|
227
281
|
}
|
|
228
282
|
|
|
229
283
|
/**
|
|
@@ -231,7 +285,7 @@ export function offboardAll(optionalAddress = null, no_sync = false) {
|
|
|
231
285
|
* @param vtxoIds Array of VtxoId strings to start exiting.
|
|
232
286
|
* @returns A promise resolving to a JSON status string.
|
|
233
287
|
*/
|
|
234
|
-
export function
|
|
288
|
+
export function startExitForVtxos(vtxoIds) {
|
|
235
289
|
return NitroArkHybridObject.exitStartSpecific(vtxoIds);
|
|
236
290
|
}
|
|
237
291
|
|
|
@@ -239,7 +293,7 @@ export function exitStartSpecific(vtxoIds) {
|
|
|
239
293
|
* Starts the exit process for all VTXOs in the wallet.
|
|
240
294
|
* @returns A promise resolving to a JSON status string.
|
|
241
295
|
*/
|
|
242
|
-
export function
|
|
296
|
+
export function startExitForEntireWallet() {
|
|
243
297
|
return NitroArkHybridObject.exitStartAll();
|
|
244
298
|
}
|
|
245
299
|
|