react-native-nitro-ark 0.0.29 → 0.0.31
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 +151 -70
- 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,13 @@ 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;
|
|
62
|
+
if (opts.birthday_height.has_value()) {
|
|
63
|
+
birthday_height_val = static_cast<uint32_t>(opts.birthday_height.value());
|
|
64
|
+
create_opts.birthday_height = &birthday_height_val;
|
|
65
|
+
} else {
|
|
66
|
+
create_opts.birthday_height = nullptr;
|
|
67
|
+
}
|
|
62
68
|
create_opts.config = config_opts;
|
|
63
69
|
|
|
64
70
|
bark_cxx::load_wallet(datadir, create_opts);
|
|
@@ -84,18 +90,110 @@ namespace margelo::nitro::nitroark
|
|
|
84
90
|
{ return bark_cxx::is_wallet_loaded(); });
|
|
85
91
|
}
|
|
86
92
|
|
|
93
|
+
std::shared_ptr<Promise<void>>
|
|
94
|
+
persistConfig(const BarkConfigOpts &opts) override
|
|
95
|
+
{
|
|
96
|
+
return Promise<void>::async([opts]()
|
|
97
|
+
{
|
|
98
|
+
try {
|
|
99
|
+
bark_cxx::ConfigOpts config_opts;
|
|
100
|
+
config_opts.asp = opts.asp.value_or("");
|
|
101
|
+
config_opts.esplora = opts.esplora.value_or("");
|
|
102
|
+
config_opts.bitcoind = opts.bitcoind.value_or("");
|
|
103
|
+
config_opts.bitcoind_cookie = opts.bitcoind_cookie.value_or("");
|
|
104
|
+
config_opts.bitcoind_user = opts.bitcoind_user.value_or("");
|
|
105
|
+
config_opts.bitcoind_pass = opts.bitcoind_pass.value_or("");
|
|
106
|
+
config_opts.vtxo_refresh_expiry_threshold = static_cast<uint32_t>(opts.vtxo_refresh_expiry_threshold.value_or(0));
|
|
107
|
+
config_opts.fallback_fee_rate = static_cast<uint64_t>(opts.fallback_fee_rate.value_or(0));
|
|
108
|
+
bark_cxx::persist_config(config_opts);
|
|
109
|
+
} catch (const rust::Error &e) {
|
|
110
|
+
throw std::runtime_error(e.what());
|
|
111
|
+
} });
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
std::shared_ptr<Promise<void>> maintenance() override
|
|
115
|
+
{
|
|
116
|
+
return Promise<void>::async([]()
|
|
117
|
+
{
|
|
118
|
+
try {
|
|
119
|
+
bark_cxx::maintenance();
|
|
120
|
+
} catch (const rust::Error &e) {
|
|
121
|
+
throw std::runtime_error(e.what());
|
|
122
|
+
} });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
std::shared_ptr<Promise<void>> sync() override
|
|
126
|
+
{
|
|
127
|
+
return Promise<void>::async([]()
|
|
128
|
+
{
|
|
129
|
+
try {
|
|
130
|
+
bark_cxx::sync();
|
|
131
|
+
} catch (const rust::Error &e) {
|
|
132
|
+
throw std::runtime_error(e.what());
|
|
133
|
+
} });
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
std::shared_ptr<Promise<void>> syncArk() override
|
|
137
|
+
{
|
|
138
|
+
return Promise<void>::async([]()
|
|
139
|
+
{
|
|
140
|
+
try {
|
|
141
|
+
bark_cxx::sync_ark();
|
|
142
|
+
} catch (const rust::Error &e) {
|
|
143
|
+
throw std::runtime_error(e.what());
|
|
144
|
+
} });
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
std::shared_ptr<Promise<void>> syncRounds() override
|
|
148
|
+
{
|
|
149
|
+
return Promise<void>::async([]()
|
|
150
|
+
{
|
|
151
|
+
try {
|
|
152
|
+
bark_cxx::sync_rounds();
|
|
153
|
+
} catch (const rust::Error &e) {
|
|
154
|
+
throw std::runtime_error(e.what());
|
|
155
|
+
} });
|
|
156
|
+
}
|
|
157
|
+
|
|
87
158
|
// --- Wallet Info ---
|
|
88
159
|
|
|
89
|
-
std::shared_ptr<Promise<
|
|
90
|
-
getBalance(bool no_sync) override
|
|
160
|
+
std::shared_ptr<Promise<BarkArkInfo>> getArkInfo() override
|
|
91
161
|
{
|
|
92
|
-
return Promise<
|
|
162
|
+
return Promise<BarkArkInfo>::async([]()
|
|
93
163
|
{
|
|
94
164
|
try {
|
|
95
|
-
bark_cxx::
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
165
|
+
bark_cxx::CxxArkInfo rust_info = bark_cxx::get_ark_info();
|
|
166
|
+
BarkArkInfo info;
|
|
167
|
+
info.network = std::string(rust_info.network.data(), rust_info.network.length());
|
|
168
|
+
info.asp_pubkey = std::string(rust_info.asp_pubkey.data(), rust_info.asp_pubkey.length());
|
|
169
|
+
info.round_interval_secs = static_cast<double>(rust_info.round_interval_secs);
|
|
170
|
+
info.vtxo_exit_delta = static_cast<double>(rust_info.vtxo_exit_delta);
|
|
171
|
+
info.vtxo_expiry_delta = static_cast<double>(rust_info.vtxo_expiry_delta);
|
|
172
|
+
info.htlc_expiry_delta = static_cast<double>(rust_info.htlc_expiry_delta);
|
|
173
|
+
info.max_vtxo_amount_sat = static_cast<double>(rust_info.max_vtxo_amount_sat);
|
|
174
|
+
return info;
|
|
175
|
+
} catch (const rust::Error &e) {
|
|
176
|
+
throw std::runtime_error(e.what());
|
|
177
|
+
} });
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
std::shared_ptr<Promise<double>> onchainBalance() override
|
|
181
|
+
{
|
|
182
|
+
return Promise<double>::async([]()
|
|
183
|
+
{
|
|
184
|
+
try {
|
|
185
|
+
return static_cast<double>(bark_cxx::onchain_balance());
|
|
186
|
+
} catch (const rust::Error &e) {
|
|
187
|
+
throw std::runtime_error(e.what());
|
|
188
|
+
} });
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
std::shared_ptr<Promise<double>> offchainBalance() override
|
|
192
|
+
{
|
|
193
|
+
return Promise<double>::async([]()
|
|
194
|
+
{
|
|
195
|
+
try {
|
|
196
|
+
return static_cast<double>(bark_cxx::offchain_balance());
|
|
99
197
|
} catch (const rust::Error &e) {
|
|
100
198
|
throw std::runtime_error(e.what());
|
|
101
199
|
} });
|
|
@@ -133,8 +231,13 @@ namespace margelo::nitro::nitroark
|
|
|
133
231
|
return Promise<std::string>::async([index]()
|
|
134
232
|
{
|
|
135
233
|
try {
|
|
136
|
-
|
|
137
|
-
|
|
234
|
+
rust::String pubkey_rs;
|
|
235
|
+
if (index.has_value()) {
|
|
236
|
+
uint32_t index_val = static_cast<uint32_t>(index.value());
|
|
237
|
+
pubkey_rs = bark_cxx::get_vtxo_pubkey(&index_val);
|
|
238
|
+
} else {
|
|
239
|
+
pubkey_rs = bark_cxx::get_vtxo_pubkey(nullptr);
|
|
240
|
+
}
|
|
138
241
|
return std::string(pubkey_rs.data(), pubkey_rs.length());
|
|
139
242
|
} catch (const rust::Error &e) {
|
|
140
243
|
throw std::runtime_error(e.what());
|
|
@@ -205,69 +308,39 @@ namespace margelo::nitro::nitroark
|
|
|
205
308
|
} });
|
|
206
309
|
}
|
|
207
310
|
|
|
208
|
-
// --- Ark
|
|
311
|
+
// --- Ark & Lightning Payments ---
|
|
209
312
|
|
|
210
|
-
std::shared_ptr<Promise<std::string>>
|
|
211
|
-
refreshVtxos(const BarkRefreshOpts &refreshOpts, bool no_sync) override
|
|
313
|
+
std::shared_ptr<Promise<std::string>> boardAmount(double amountSat) override
|
|
212
314
|
{
|
|
213
|
-
return Promise<std::string>::async([
|
|
214
|
-
no_sync]()
|
|
315
|
+
return Promise<std::string>::async([amountSat]()
|
|
215
316
|
{
|
|
216
317
|
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);
|
|
318
|
+
rust::String status_rs = bark_cxx::board_amount(static_cast<uint64_t>(amountSat));
|
|
245
319
|
return std::string(status_rs.data(), status_rs.length());
|
|
246
320
|
} catch (const rust::Error &e) {
|
|
247
321
|
throw std::runtime_error(e.what());
|
|
248
322
|
} });
|
|
249
323
|
}
|
|
250
324
|
|
|
251
|
-
std::shared_ptr<Promise<std::string>>
|
|
252
|
-
bool no_sync) override
|
|
325
|
+
std::shared_ptr<Promise<std::string>> boardAll() override
|
|
253
326
|
{
|
|
254
|
-
return Promise<std::string>::async([
|
|
255
|
-
no_sync]()
|
|
327
|
+
return Promise<std::string>::async([]()
|
|
256
328
|
{
|
|
257
329
|
try {
|
|
258
|
-
rust::String status_rs = bark_cxx::
|
|
330
|
+
rust::String status_rs = bark_cxx::board_all();
|
|
259
331
|
return std::string(status_rs.data(), status_rs.length());
|
|
260
332
|
} catch (const rust::Error &e) {
|
|
261
333
|
throw std::runtime_error(e.what());
|
|
262
334
|
} });
|
|
263
335
|
}
|
|
264
336
|
|
|
265
|
-
std::shared_ptr<Promise<std::string>>
|
|
337
|
+
std::shared_ptr<Promise<std::string>>
|
|
338
|
+
sendArkoorPayment(const std::string &destination, double amountSat) override
|
|
266
339
|
{
|
|
267
|
-
return Promise<std::string>::async([
|
|
340
|
+
return Promise<std::string>::async([destination, amountSat]()
|
|
268
341
|
{
|
|
269
342
|
try {
|
|
270
|
-
rust::String status_rs = bark_cxx::
|
|
343
|
+
rust::String status_rs = bark_cxx::send_arkoor_payment(destination, static_cast<uint64_t>(amountSat));
|
|
271
344
|
return std::string(status_rs.data(), status_rs.length());
|
|
272
345
|
} catch (const rust::Error &e) {
|
|
273
346
|
throw std::runtime_error(e.what());
|
|
@@ -275,21 +348,31 @@ namespace margelo::nitro::nitroark
|
|
|
275
348
|
}
|
|
276
349
|
|
|
277
350
|
std::shared_ptr<Promise<std::string>>
|
|
278
|
-
|
|
279
|
-
const std::optional<std::string> &comment, bool no_sync) override
|
|
351
|
+
sendBolt11Payment(const std::string &destination, std::optional<double> amountSat) override
|
|
280
352
|
{
|
|
281
|
-
return Promise<std::string>::async([destination, amountSat
|
|
353
|
+
return Promise<std::string>::async([destination, amountSat]()
|
|
282
354
|
{
|
|
283
355
|
try {
|
|
284
|
-
|
|
356
|
+
rust::String status_rs;
|
|
285
357
|
if (amountSat.has_value()) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
comment_val = comment.value();
|
|
358
|
+
uint64_t amountSat_val = static_cast<uint64_t>(amountSat.value());
|
|
359
|
+
status_rs = bark_cxx::send_bolt11_payment(destination, &amountSat_val);
|
|
360
|
+
} else {
|
|
361
|
+
status_rs = bark_cxx::send_bolt11_payment(destination, nullptr);
|
|
291
362
|
}
|
|
292
|
-
|
|
363
|
+
return std::string(status_rs.data(), status_rs.length());
|
|
364
|
+
} catch (const rust::Error &e) {
|
|
365
|
+
throw std::runtime_error(e.what());
|
|
366
|
+
} });
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
std::shared_ptr<Promise<std::string>>
|
|
370
|
+
sendLnaddr(const std::string &addr, double amountSat, const std::string &comment) override
|
|
371
|
+
{
|
|
372
|
+
return Promise<std::string>::async([addr, amountSat, comment]()
|
|
373
|
+
{
|
|
374
|
+
try {
|
|
375
|
+
rust::String status_rs = bark_cxx::send_lnaddr(addr, static_cast<uint64_t>(amountSat), comment);
|
|
293
376
|
return std::string(status_rs.data(), status_rs.length());
|
|
294
377
|
} catch (const rust::Error &e) {
|
|
295
378
|
throw std::runtime_error(e.what());
|
|
@@ -315,7 +398,7 @@ namespace margelo::nitro::nitroark
|
|
|
315
398
|
});
|
|
316
399
|
}
|
|
317
400
|
|
|
318
|
-
// --- Lightning
|
|
401
|
+
// --- Lightning Invoicing ---
|
|
319
402
|
|
|
320
403
|
std::shared_ptr<Promise<std::string>>
|
|
321
404
|
bolt11Invoice(double amountMsat) override
|
|
@@ -346,11 +429,11 @@ namespace margelo::nitro::nitroark
|
|
|
346
429
|
|
|
347
430
|
std::shared_ptr<Promise<std::string>>
|
|
348
431
|
offboardSpecific(const std::vector<std::string> &vtxoIds,
|
|
349
|
-
const std::
|
|
432
|
+
const std::string &destinationAddress,
|
|
350
433
|
bool no_sync) override
|
|
351
434
|
{
|
|
352
435
|
return Promise<std::string>::async(
|
|
353
|
-
[vtxoIds,
|
|
436
|
+
[vtxoIds, destinationAddress, no_sync]()
|
|
354
437
|
{
|
|
355
438
|
try
|
|
356
439
|
{
|
|
@@ -359,8 +442,7 @@ namespace margelo::nitro::nitroark
|
|
|
359
442
|
{
|
|
360
443
|
rust_vtxo_ids.push_back(rust::String(id));
|
|
361
444
|
}
|
|
362
|
-
|
|
363
|
-
rust::String status_rs = bark_cxx::offboard_specific(std::move(rust_vtxo_ids), address, no_sync);
|
|
445
|
+
rust::String status_rs = bark_cxx::offboard_specific(std::move(rust_vtxo_ids), destinationAddress, no_sync);
|
|
364
446
|
return std::string(status_rs.data(), status_rs.length());
|
|
365
447
|
}
|
|
366
448
|
catch (const rust::Error &e)
|
|
@@ -371,15 +453,14 @@ namespace margelo::nitro::nitroark
|
|
|
371
453
|
}
|
|
372
454
|
|
|
373
455
|
std::shared_ptr<Promise<std::string>>
|
|
374
|
-
offboardAll(const std::
|
|
456
|
+
offboardAll(const std::string &destinationAddress,
|
|
375
457
|
bool no_sync) override
|
|
376
458
|
{
|
|
377
|
-
return Promise<std::string>::async([
|
|
459
|
+
return Promise<std::string>::async([destinationAddress,
|
|
378
460
|
no_sync]()
|
|
379
461
|
{
|
|
380
462
|
try {
|
|
381
|
-
|
|
382
|
-
rust::String status_rs = bark_cxx::offboard_all(address, no_sync);
|
|
463
|
+
rust::String status_rs = bark_cxx::offboard_all(destinationAddress, no_sync);
|
|
383
464
|
return std::string(status_rs.data(), status_rs.length());
|
|
384
465
|
} catch (const rust::Error &e) {
|
|
385
466
|
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 const *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
|
|