react-native-nitro-ark 0.0.38 → 0.0.39
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/jniLibs/arm64-v8a/libcxxbridge1.a +0 -0
- package/android/src/main/jniLibs/x86_64/libcxxbridge1.a +0 -0
- package/cpp/NitroArk.hpp +195 -165
- package/cpp/generated/ark_cxx.h +55 -23
- package/lib/module/index.js +86 -92
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NitroArk.nitro.d.ts +29 -18
- package/lib/typescript/src/NitroArk.nitro.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +60 -66
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/nitrogen/generated/shared/c++/HybridNitroArkSpec.cpp +15 -15
- package/nitrogen/generated/shared/c++/HybridNitroArkSpec.hpp +31 -22
- package/nitrogen/generated/shared/c++/{Bolt11PaymentResult.hpp → LightningPaymentResult.hpp} +10 -10
- package/nitrogen/generated/shared/c++/OffchainBalanceResult.hpp +77 -0
- package/nitrogen/generated/shared/c++/OnchainBalanceResult.hpp +81 -0
- package/package.json +1 -1
- package/src/NitroArk.nitro.ts +47 -24
- package/src/index.tsx +101 -105
|
Binary file
|
|
Binary file
|
package/cpp/NitroArk.hpp
CHANGED
|
@@ -152,12 +152,12 @@ namespace margelo::nitro::nitroark
|
|
|
152
152
|
} });
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
std::shared_ptr<Promise<void>>
|
|
155
|
+
std::shared_ptr<Promise<void>> syncExits() override
|
|
156
156
|
{
|
|
157
157
|
return Promise<void>::async([]()
|
|
158
158
|
{
|
|
159
159
|
try {
|
|
160
|
-
bark_cxx::
|
|
160
|
+
bark_cxx::sync_exits();
|
|
161
161
|
} catch (const rust::Error &e) {
|
|
162
162
|
throw std::runtime_error(e.what());
|
|
163
163
|
} });
|
|
@@ -196,94 +196,151 @@ namespace margelo::nitro::nitroark
|
|
|
196
196
|
} });
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
std::shared_ptr<Promise<
|
|
199
|
+
std::shared_ptr<Promise<OffchainBalanceResult>> offchainBalance() override
|
|
200
200
|
{
|
|
201
|
-
return Promise<
|
|
202
|
-
|
|
201
|
+
return Promise<OffchainBalanceResult>::async([]()
|
|
202
|
+
{
|
|
203
203
|
try {
|
|
204
|
-
|
|
204
|
+
bark_cxx::OffchainBalance rust_balance = bark_cxx::offchain_balance();
|
|
205
|
+
OffchainBalanceResult balance;
|
|
206
|
+
balance.spendable = static_cast<double>(rust_balance.spendable);
|
|
207
|
+
balance.pending_lightning_send = static_cast<double>(rust_balance.pending_lightning_send);
|
|
208
|
+
balance.pending_exit = static_cast<double>(rust_balance.pending_exit);
|
|
209
|
+
return balance;
|
|
205
210
|
} catch (const rust::Error &e) {
|
|
206
211
|
throw std::runtime_error(e.what());
|
|
207
212
|
} });
|
|
208
213
|
}
|
|
209
214
|
|
|
210
|
-
std::shared_ptr<Promise<
|
|
215
|
+
std::shared_ptr<Promise<std::string>>
|
|
216
|
+
deriveStoreNextKeypair() override
|
|
211
217
|
{
|
|
212
|
-
return Promise<
|
|
213
|
-
|
|
218
|
+
return Promise<std::string>::async([]()
|
|
219
|
+
{
|
|
214
220
|
try {
|
|
215
|
-
|
|
221
|
+
rust::String keypair_rs = bark_cxx::derive_store_next_keypair();
|
|
222
|
+
return std::string(keypair_rs.data(), keypair_rs.length());
|
|
216
223
|
} catch (const rust::Error &e) {
|
|
217
224
|
throw std::runtime_error(e.what());
|
|
218
225
|
} });
|
|
219
226
|
}
|
|
220
227
|
|
|
221
228
|
std::shared_ptr<Promise<std::string>>
|
|
222
|
-
|
|
229
|
+
peakKeyPair(double index) override
|
|
223
230
|
{
|
|
224
|
-
return Promise<std::string>::async([]()
|
|
231
|
+
return Promise<std::string>::async([index]()
|
|
225
232
|
{
|
|
226
233
|
try {
|
|
227
|
-
|
|
228
|
-
|
|
234
|
+
uint32_t index_val = static_cast<uint32_t>(index);
|
|
235
|
+
rust::String keypair_rs = bark_cxx::peak_keypair(index_val);
|
|
236
|
+
return std::string(keypair_rs.data(), keypair_rs.length());
|
|
229
237
|
} catch (const rust::Error &e) {
|
|
230
238
|
throw std::runtime_error(e.what());
|
|
231
239
|
} });
|
|
232
240
|
}
|
|
233
241
|
|
|
234
|
-
std::shared_ptr<Promise<std::
|
|
235
|
-
getOnchainUtxos(bool no_sync) override
|
|
242
|
+
std::shared_ptr<Promise<std::vector<BarkVtxo>>> getVtxos() override
|
|
236
243
|
{
|
|
237
|
-
return Promise<std::
|
|
238
|
-
|
|
244
|
+
return Promise<std::vector<BarkVtxo>>::async([]()
|
|
245
|
+
{
|
|
239
246
|
try {
|
|
240
|
-
rust::
|
|
241
|
-
|
|
247
|
+
rust::Vec<bark_cxx::BarkVtxo> rust_vtxos = bark_cxx::get_vtxos();
|
|
248
|
+
std::vector<BarkVtxo> vtxos;
|
|
249
|
+
for (const auto& rust_vtxo : rust_vtxos) {
|
|
250
|
+
BarkVtxo vtxo;
|
|
251
|
+
vtxo.amount = static_cast<double>(rust_vtxo.amount);
|
|
252
|
+
vtxo.expiry_height = static_cast<double>(rust_vtxo.expiry_height);
|
|
253
|
+
vtxo.exit_delta = static_cast<double>(rust_vtxo.exit_delta);
|
|
254
|
+
vtxo.anchor_point = std::string(rust_vtxo.anchor_point.data(), rust_vtxo.anchor_point.length());
|
|
255
|
+
vtxos.push_back(vtxo);
|
|
256
|
+
}
|
|
257
|
+
return vtxos;
|
|
242
258
|
} catch (const rust::Error &e) {
|
|
243
259
|
throw std::runtime_error(e.what());
|
|
244
260
|
} });
|
|
245
261
|
}
|
|
246
262
|
|
|
247
|
-
|
|
248
|
-
|
|
263
|
+
// --- Onchain Operations ---
|
|
264
|
+
|
|
265
|
+
std::shared_ptr<Promise<OnchainBalanceResult>> onchainBalance() override
|
|
249
266
|
{
|
|
250
|
-
return Promise<
|
|
267
|
+
return Promise<OnchainBalanceResult>::async([]()
|
|
268
|
+
{
|
|
269
|
+
try {
|
|
270
|
+
bark_cxx::OnChainBalance rust_balance = bark_cxx::onchain_balance();
|
|
271
|
+
OnchainBalanceResult balance;
|
|
272
|
+
balance.immature = static_cast<double>(rust_balance.immature);
|
|
273
|
+
balance.trusted_pending = static_cast<double>(rust_balance.trusted_pending);
|
|
274
|
+
balance.untrusted_pending = static_cast<double>(rust_balance.untrusted_pending);
|
|
275
|
+
balance.confirmed = static_cast<double>(rust_balance.confirmed);
|
|
276
|
+
return balance;
|
|
277
|
+
} catch (const rust::Error &e) {
|
|
278
|
+
throw std::runtime_error(e.what());
|
|
279
|
+
} });
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
std::shared_ptr<Promise<void>> onchainSync() override
|
|
283
|
+
{
|
|
284
|
+
return Promise<void>::async([]()
|
|
285
|
+
{
|
|
286
|
+
try {
|
|
287
|
+
bark_cxx::onchain_sync();
|
|
288
|
+
} catch (const rust::Error &e) {
|
|
289
|
+
throw std::runtime_error(e.what());
|
|
290
|
+
} });
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
std::shared_ptr<Promise<std::string>> onchainListUnspent() override
|
|
294
|
+
{
|
|
295
|
+
return Promise<std::string>::async([]()
|
|
251
296
|
{
|
|
252
297
|
try {
|
|
253
|
-
rust::String
|
|
254
|
-
|
|
255
|
-
uint32_t index_val = static_cast<uint32_t>(index.value());
|
|
256
|
-
pubkey_rs = bark_cxx::get_vtxo_pubkey(&index_val);
|
|
257
|
-
} else {
|
|
258
|
-
pubkey_rs = bark_cxx::get_vtxo_pubkey(nullptr);
|
|
259
|
-
}
|
|
260
|
-
return std::string(pubkey_rs.data(), pubkey_rs.length());
|
|
298
|
+
rust::String json_rs = bark_cxx::onchain_list_unspent();
|
|
299
|
+
return std::string(json_rs.data(), json_rs.length());
|
|
261
300
|
} catch (const rust::Error &e) {
|
|
262
301
|
throw std::runtime_error(e.what());
|
|
263
302
|
} });
|
|
264
303
|
}
|
|
265
304
|
|
|
266
|
-
std::shared_ptr<Promise<std::string>>
|
|
305
|
+
std::shared_ptr<Promise<std::string>> onchainUtxos() override
|
|
267
306
|
{
|
|
268
|
-
return Promise<std::string>::async([
|
|
307
|
+
return Promise<std::string>::async([]()
|
|
269
308
|
{
|
|
270
309
|
try {
|
|
271
|
-
rust::String json_rs = bark_cxx::
|
|
310
|
+
rust::String json_rs = bark_cxx::onchain_utxos();
|
|
272
311
|
return std::string(json_rs.data(), json_rs.length());
|
|
273
312
|
} catch (const rust::Error &e) {
|
|
274
313
|
throw std::runtime_error(e.what());
|
|
275
314
|
} });
|
|
276
315
|
}
|
|
277
316
|
|
|
278
|
-
|
|
317
|
+
std::shared_ptr<Promise<std::string>>
|
|
318
|
+
onchainAddress() override
|
|
319
|
+
{
|
|
320
|
+
return Promise<std::string>::async([]()
|
|
321
|
+
{
|
|
322
|
+
try {
|
|
323
|
+
rust::String address_rs = bark_cxx::onchain_address();
|
|
324
|
+
return std::string(address_rs.data(), address_rs.length());
|
|
325
|
+
} catch (const rust::Error &e) {
|
|
326
|
+
throw std::runtime_error(e.what());
|
|
327
|
+
} });
|
|
328
|
+
}
|
|
279
329
|
|
|
280
330
|
std::shared_ptr<Promise<OnchainPaymentResult>>
|
|
281
|
-
|
|
331
|
+
onchainSend(const std::string &destination, double amountSat, std::optional<double> feeRate) override
|
|
282
332
|
{
|
|
283
|
-
return Promise<OnchainPaymentResult>::async([destination, amountSat]()
|
|
333
|
+
return Promise<OnchainPaymentResult>::async([destination, amountSat, feeRate]()
|
|
284
334
|
{
|
|
285
335
|
try {
|
|
286
|
-
|
|
336
|
+
uint64_t feeRate_val;
|
|
337
|
+
bark_cxx::OnchainPaymentResult rust_result;
|
|
338
|
+
if (feeRate.has_value()) {
|
|
339
|
+
feeRate_val = static_cast<uint64_t>(feeRate.value());
|
|
340
|
+
rust_result = bark_cxx::onchain_send(destination, static_cast<uint64_t>(amountSat), &feeRate_val);
|
|
341
|
+
} else {
|
|
342
|
+
rust_result = bark_cxx::onchain_send(destination, static_cast<uint64_t>(amountSat), nullptr);
|
|
343
|
+
}
|
|
287
344
|
|
|
288
345
|
OnchainPaymentResult result;
|
|
289
346
|
result.txid = std::string(rust_result.txid.data(), rust_result.txid.length());
|
|
@@ -298,14 +355,24 @@ namespace margelo::nitro::nitroark
|
|
|
298
355
|
}
|
|
299
356
|
|
|
300
357
|
std::shared_ptr<Promise<std::string>>
|
|
301
|
-
|
|
358
|
+
onchainDrain(const std::string &destination, std::optional<double> feeRate) override
|
|
302
359
|
{
|
|
303
360
|
return Promise<std::string>::async(
|
|
304
|
-
[destination,
|
|
361
|
+
[destination, feeRate]()
|
|
305
362
|
{
|
|
306
363
|
try
|
|
307
364
|
{
|
|
308
|
-
|
|
365
|
+
uint64_t feeRate_val;
|
|
366
|
+
rust::String txid_rs;
|
|
367
|
+
if (feeRate.has_value())
|
|
368
|
+
{
|
|
369
|
+
feeRate_val = static_cast<uint64_t>(feeRate.value());
|
|
370
|
+
txid_rs = bark_cxx::onchain_drain(destination, &feeRate_val);
|
|
371
|
+
}
|
|
372
|
+
else
|
|
373
|
+
{
|
|
374
|
+
txid_rs = bark_cxx::onchain_drain(destination, nullptr);
|
|
375
|
+
}
|
|
309
376
|
return std::string(txid_rs.data(), txid_rs.length());
|
|
310
377
|
}
|
|
311
378
|
catch (const rust::Error &e)
|
|
@@ -316,24 +383,103 @@ namespace margelo::nitro::nitroark
|
|
|
316
383
|
}
|
|
317
384
|
|
|
318
385
|
std::shared_ptr<Promise<std::string>>
|
|
319
|
-
|
|
320
|
-
|
|
386
|
+
onchainSendMany(const std::vector<BarkSendManyOutput> &outputs,
|
|
387
|
+
std::optional<double> feeRate) override
|
|
321
388
|
{
|
|
322
|
-
return Promise<std::string>::async([outputs,
|
|
389
|
+
return Promise<std::string>::async([outputs, feeRate]()
|
|
323
390
|
{
|
|
324
391
|
try {
|
|
325
392
|
rust::Vec<bark_cxx::SendManyOutput> cxx_outputs;
|
|
326
393
|
for (const auto &output : outputs) {
|
|
327
394
|
cxx_outputs.push_back({rust::String(output.destination), static_cast<uint64_t>(output.amountSat)});
|
|
328
395
|
}
|
|
329
|
-
|
|
396
|
+
uint64_t feeRate_val;
|
|
397
|
+
rust::String txid_rs;
|
|
398
|
+
if (feeRate.has_value()) {
|
|
399
|
+
feeRate_val = static_cast<uint64_t>(feeRate.value());
|
|
400
|
+
txid_rs = bark_cxx::onchain_send_many(std::move(cxx_outputs), &feeRate_val);
|
|
401
|
+
} else {
|
|
402
|
+
txid_rs = bark_cxx::onchain_send_many(std::move(cxx_outputs), nullptr);
|
|
403
|
+
}
|
|
330
404
|
return std::string(txid_rs.data(), txid_rs.length());
|
|
331
405
|
} catch (const rust::Error &e) {
|
|
332
406
|
throw std::runtime_error(e.what());
|
|
333
407
|
} });
|
|
334
408
|
}
|
|
335
409
|
|
|
336
|
-
// ---
|
|
410
|
+
// --- Lightning Operations ---
|
|
411
|
+
|
|
412
|
+
std::shared_ptr<Promise<LightningPaymentResult>>
|
|
413
|
+
sendLightningPayment(const std::string &destination, std::optional<double> amountSat) override
|
|
414
|
+
{
|
|
415
|
+
return Promise<LightningPaymentResult>::async([destination, amountSat]()
|
|
416
|
+
{
|
|
417
|
+
try {
|
|
418
|
+
bark_cxx::Bolt11PaymentResult rust_result;
|
|
419
|
+
if (amountSat.has_value()) {
|
|
420
|
+
uint64_t amountSat_val = static_cast<uint64_t>(amountSat.value());
|
|
421
|
+
rust_result = bark_cxx::send_lightning_payment(destination, &amountSat_val);
|
|
422
|
+
} else {
|
|
423
|
+
rust_result = bark_cxx::send_lightning_payment(destination, nullptr);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
LightningPaymentResult result;
|
|
427
|
+
result.bolt11_invoice = std::string(rust_result.bolt11_invoice.data(), rust_result.bolt11_invoice.length());
|
|
428
|
+
result.preimage = std::string(rust_result.preimage.data(), rust_result.preimage.length());
|
|
429
|
+
result.payment_type = convertPaymentType(rust_result.payment_type);
|
|
430
|
+
|
|
431
|
+
return result;
|
|
432
|
+
} catch (const rust::Error &e) {
|
|
433
|
+
throw std::runtime_error(e.what());
|
|
434
|
+
} });
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
std::shared_ptr<Promise<LnurlPaymentResult>>
|
|
438
|
+
sendLnaddr(const std::string &addr, double amountSat, const std::string &comment) override
|
|
439
|
+
{
|
|
440
|
+
return Promise<LnurlPaymentResult>::async([addr, amountSat, comment]()
|
|
441
|
+
{
|
|
442
|
+
try {
|
|
443
|
+
bark_cxx::LnurlPaymentResult rust_result = bark_cxx::send_lnaddr(addr, static_cast<uint64_t>(amountSat), comment);
|
|
444
|
+
|
|
445
|
+
LnurlPaymentResult result;
|
|
446
|
+
result.lnurl = std::string(rust_result.lnurl.data(), rust_result.lnurl.length());
|
|
447
|
+
result.bolt11_invoice = std::string(rust_result.bolt11_invoice.data(), rust_result.bolt11_invoice.length());
|
|
448
|
+
result.preimage = std::string(rust_result.preimage.data(), rust_result.preimage.length());
|
|
449
|
+
result.payment_type = convertPaymentType(rust_result.payment_type);
|
|
450
|
+
|
|
451
|
+
return result;
|
|
452
|
+
} catch (const rust::Error &e) {
|
|
453
|
+
throw std::runtime_error(e.what());
|
|
454
|
+
} });
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
std::shared_ptr<Promise<std::string>>
|
|
458
|
+
bolt11Invoice(double amountMsat) override
|
|
459
|
+
{
|
|
460
|
+
return Promise<std::string>::async([amountMsat]()
|
|
461
|
+
{
|
|
462
|
+
try {
|
|
463
|
+
rust::String invoice_rs = bark_cxx::bolt11_invoice(static_cast<uint64_t>(amountMsat));
|
|
464
|
+
return std::string(invoice_rs.data(), invoice_rs.length());
|
|
465
|
+
} catch (const rust::Error &e) {
|
|
466
|
+
throw std::runtime_error(e.what());
|
|
467
|
+
} });
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
std::shared_ptr<Promise<void>>
|
|
471
|
+
finishLightningReceive(const std::string &bolt11) override
|
|
472
|
+
{
|
|
473
|
+
return Promise<void>::async([bolt11]()
|
|
474
|
+
{
|
|
475
|
+
try {
|
|
476
|
+
bark_cxx::finish_lightning_receive(bolt11);
|
|
477
|
+
} catch (const rust::Error &e) {
|
|
478
|
+
throw std::runtime_error(e.what());
|
|
479
|
+
} });
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// --- Ark Operations ---
|
|
337
483
|
|
|
338
484
|
std::shared_ptr<Promise<std::string>> boardAmount(double amountSat) override
|
|
339
485
|
{
|
|
@@ -389,61 +535,15 @@ namespace margelo::nitro::nitroark
|
|
|
389
535
|
} });
|
|
390
536
|
}
|
|
391
537
|
|
|
392
|
-
std::shared_ptr<Promise<Bolt11PaymentResult>>
|
|
393
|
-
sendBolt11Payment(const std::string &destination, std::optional<double> amountSat) override
|
|
394
|
-
{
|
|
395
|
-
return Promise<Bolt11PaymentResult>::async([destination, amountSat]()
|
|
396
|
-
{
|
|
397
|
-
try {
|
|
398
|
-
bark_cxx::Bolt11PaymentResult rust_result;
|
|
399
|
-
if (amountSat.has_value()) {
|
|
400
|
-
uint64_t amountSat_val = static_cast<uint64_t>(amountSat.value());
|
|
401
|
-
rust_result = bark_cxx::send_bolt11_payment(destination, &amountSat_val);
|
|
402
|
-
} else {
|
|
403
|
-
rust_result = bark_cxx::send_bolt11_payment(destination, nullptr);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
Bolt11PaymentResult result;
|
|
407
|
-
result.bolt11_invoice = std::string(rust_result.bolt11_invoice.data(), rust_result.bolt11_invoice.length());
|
|
408
|
-
result.preimage = std::string(rust_result.preimage.data(), rust_result.preimage.length());
|
|
409
|
-
result.payment_type = convertPaymentType(rust_result.payment_type);
|
|
410
|
-
|
|
411
|
-
return result;
|
|
412
|
-
} catch (const rust::Error &e) {
|
|
413
|
-
throw std::runtime_error(e.what());
|
|
414
|
-
} });
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
std::shared_ptr<Promise<LnurlPaymentResult>>
|
|
418
|
-
sendLnaddr(const std::string &addr, double amountSat, const std::string &comment) override
|
|
419
|
-
{
|
|
420
|
-
return Promise<LnurlPaymentResult>::async([addr, amountSat, comment]()
|
|
421
|
-
{
|
|
422
|
-
try {
|
|
423
|
-
bark_cxx::LnurlPaymentResult rust_result = bark_cxx::send_lnaddr(addr, static_cast<uint64_t>(amountSat), comment);
|
|
424
|
-
|
|
425
|
-
LnurlPaymentResult result;
|
|
426
|
-
result.lnurl = std::string(rust_result.lnurl.data(), rust_result.lnurl.length());
|
|
427
|
-
result.bolt11_invoice = std::string(rust_result.bolt11_invoice.data(), rust_result.bolt11_invoice.length());
|
|
428
|
-
result.preimage = std::string(rust_result.preimage.data(), rust_result.preimage.length());
|
|
429
|
-
result.payment_type = convertPaymentType(rust_result.payment_type);
|
|
430
|
-
|
|
431
|
-
return result;
|
|
432
|
-
} catch (const rust::Error &e) {
|
|
433
|
-
throw std::runtime_error(e.what());
|
|
434
|
-
} });
|
|
435
|
-
}
|
|
436
|
-
|
|
437
538
|
std::shared_ptr<Promise<std::string>>
|
|
438
|
-
|
|
439
|
-
bool no_sync) override
|
|
539
|
+
sendRoundOnchainPayment(const std::string &destination, double amountSat) override
|
|
440
540
|
{
|
|
441
541
|
return Promise<std::string>::async(
|
|
442
|
-
[destination, amountSat
|
|
542
|
+
[destination, amountSat]()
|
|
443
543
|
{
|
|
444
544
|
try
|
|
445
545
|
{
|
|
446
|
-
rust::String status_rs = bark_cxx::
|
|
546
|
+
rust::String status_rs = bark_cxx::send_round_onchain_payment(destination, static_cast<uint64_t>(amountSat));
|
|
447
547
|
return std::string(status_rs.data(), status_rs.length());
|
|
448
548
|
}
|
|
449
549
|
catch (const rust::Error &e)
|
|
@@ -453,33 +553,6 @@ namespace margelo::nitro::nitroark
|
|
|
453
553
|
});
|
|
454
554
|
}
|
|
455
555
|
|
|
456
|
-
// --- Lightning Invoicing ---
|
|
457
|
-
|
|
458
|
-
std::shared_ptr<Promise<std::string>>
|
|
459
|
-
bolt11Invoice(double amountMsat) override
|
|
460
|
-
{
|
|
461
|
-
return Promise<std::string>::async([amountMsat]()
|
|
462
|
-
{
|
|
463
|
-
try {
|
|
464
|
-
rust::String invoice_rs = bark_cxx::bolt11_invoice(static_cast<uint64_t>(amountMsat));
|
|
465
|
-
return std::string(invoice_rs.data(), invoice_rs.length());
|
|
466
|
-
} catch (const rust::Error &e) {
|
|
467
|
-
throw std::runtime_error(e.what());
|
|
468
|
-
} });
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
std::shared_ptr<Promise<void>>
|
|
472
|
-
claimBolt11Payment(const std::string &bolt11) override
|
|
473
|
-
{
|
|
474
|
-
return Promise<void>::async([bolt11]()
|
|
475
|
-
{
|
|
476
|
-
try {
|
|
477
|
-
bark_cxx::claim_bolt11_payment(bolt11);
|
|
478
|
-
} catch (const rust::Error &e) {
|
|
479
|
-
throw std::runtime_error(e.what());
|
|
480
|
-
} });
|
|
481
|
-
}
|
|
482
|
-
|
|
483
556
|
// --- Offboarding / Exiting ---
|
|
484
557
|
|
|
485
558
|
std::shared_ptr<Promise<std::string>>
|
|
@@ -519,49 +592,6 @@ namespace margelo::nitro::nitroark
|
|
|
519
592
|
} });
|
|
520
593
|
}
|
|
521
594
|
|
|
522
|
-
std::shared_ptr<Promise<std::string>> exitStartSpecific(
|
|
523
|
-
const std::vector<std::string> &vtxoIds) override
|
|
524
|
-
{
|
|
525
|
-
return Promise<std::string>::async([vtxoIds]()
|
|
526
|
-
{
|
|
527
|
-
try {
|
|
528
|
-
rust::Vec<rust::String> rust_vtxo_ids;
|
|
529
|
-
for (const auto &id : vtxoIds)
|
|
530
|
-
{
|
|
531
|
-
rust_vtxo_ids.push_back(rust::String(id));
|
|
532
|
-
}
|
|
533
|
-
rust::String status_rs = bark_cxx::start_exit_for_vtxos(std::move(rust_vtxo_ids));
|
|
534
|
-
return std::string(status_rs.data(), status_rs.length());
|
|
535
|
-
} catch (const rust::Error &e) {
|
|
536
|
-
throw std::runtime_error(e.what());
|
|
537
|
-
} });
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
std::shared_ptr<Promise<void>>
|
|
541
|
-
startExitForEntireWallet() override
|
|
542
|
-
{
|
|
543
|
-
return Promise<void>::async([]()
|
|
544
|
-
{
|
|
545
|
-
try {
|
|
546
|
-
bark_cxx::start_exit_for_entire_wallet();
|
|
547
|
-
} catch (const rust::Error &e) {
|
|
548
|
-
throw std::runtime_error(e.what());
|
|
549
|
-
} });
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
std::shared_ptr<Promise<std::string>>
|
|
553
|
-
exitProgressOnce() override
|
|
554
|
-
{
|
|
555
|
-
return Promise<std::string>::async([]()
|
|
556
|
-
{
|
|
557
|
-
try {
|
|
558
|
-
rust::String status_rs = bark_cxx::exit_progress_once();
|
|
559
|
-
return std::string(status_rs.data(), status_rs.length());
|
|
560
|
-
} catch (const rust::Error &e) {
|
|
561
|
-
throw std::runtime_error(e.what());
|
|
562
|
-
} });
|
|
563
|
-
}
|
|
564
|
-
|
|
565
595
|
private:
|
|
566
596
|
// Tag for logging/debugging within Nitro
|
|
567
597
|
static constexpr auto TAG = "NitroArk";
|
package/cpp/generated/ark_cxx.h
CHANGED
|
@@ -808,6 +808,8 @@ namespace bark_cxx {
|
|
|
808
808
|
struct CreateOpts;
|
|
809
809
|
struct SendManyOutput;
|
|
810
810
|
enum class RefreshModeType : ::std::uint8_t;
|
|
811
|
+
struct OffchainBalance;
|
|
812
|
+
struct OnChainBalance;
|
|
811
813
|
}
|
|
812
814
|
|
|
813
815
|
namespace bark_cxx {
|
|
@@ -947,6 +949,36 @@ enum class RefreshModeType : ::std::uint8_t {
|
|
|
947
949
|
};
|
|
948
950
|
#endif // CXXBRIDGE1_ENUM_bark_cxx$RefreshModeType
|
|
949
951
|
|
|
952
|
+
#ifndef CXXBRIDGE1_STRUCT_bark_cxx$OffchainBalance
|
|
953
|
+
#define CXXBRIDGE1_STRUCT_bark_cxx$OffchainBalance
|
|
954
|
+
struct OffchainBalance final {
|
|
955
|
+
// Coins that are spendable in the Ark, either in-round or out-of-round.
|
|
956
|
+
::std::uint64_t spendable CXX_DEFAULT_VALUE(0);
|
|
957
|
+
// Coins that are in the process of being sent over Lightning.
|
|
958
|
+
::std::uint64_t pending_lightning_send CXX_DEFAULT_VALUE(0);
|
|
959
|
+
// Coins that are in the process of unilaterally exiting the Ark.
|
|
960
|
+
::std::uint64_t pending_exit CXX_DEFAULT_VALUE(0);
|
|
961
|
+
|
|
962
|
+
using IsRelocatable = ::std::true_type;
|
|
963
|
+
};
|
|
964
|
+
#endif // CXXBRIDGE1_STRUCT_bark_cxx$OffchainBalance
|
|
965
|
+
|
|
966
|
+
#ifndef CXXBRIDGE1_STRUCT_bark_cxx$OnChainBalance
|
|
967
|
+
#define CXXBRIDGE1_STRUCT_bark_cxx$OnChainBalance
|
|
968
|
+
struct OnChainBalance final {
|
|
969
|
+
// All coinbase outputs not yet matured
|
|
970
|
+
::std::uint64_t immature CXX_DEFAULT_VALUE(0);
|
|
971
|
+
// Unconfirmed UTXOs generated by a wallet tx
|
|
972
|
+
::std::uint64_t trusted_pending CXX_DEFAULT_VALUE(0);
|
|
973
|
+
// Unconfirmed UTXOs received from an external wallet
|
|
974
|
+
::std::uint64_t untrusted_pending CXX_DEFAULT_VALUE(0);
|
|
975
|
+
// Confirmed and immediately spendable balance
|
|
976
|
+
::std::uint64_t confirmed CXX_DEFAULT_VALUE(0);
|
|
977
|
+
|
|
978
|
+
using IsRelocatable = ::std::true_type;
|
|
979
|
+
};
|
|
980
|
+
#endif // CXXBRIDGE1_STRUCT_bark_cxx$OnChainBalance
|
|
981
|
+
|
|
950
982
|
void init_logger() noexcept;
|
|
951
983
|
|
|
952
984
|
::rust::String create_mnemonic();
|
|
@@ -959,57 +991,57 @@ void persist_config(::bark_cxx::ConfigOpts opts);
|
|
|
959
991
|
|
|
960
992
|
::bark_cxx::CxxArkInfo get_ark_info();
|
|
961
993
|
|
|
962
|
-
::
|
|
963
|
-
|
|
964
|
-
::std::uint64_t offchain_balance();
|
|
965
|
-
|
|
966
|
-
::std::uint64_t onchain_balance();
|
|
994
|
+
::bark_cxx::OffchainBalance offchain_balance();
|
|
967
995
|
|
|
968
|
-
::rust::String
|
|
996
|
+
::rust::String derive_store_next_keypair();
|
|
969
997
|
|
|
970
|
-
::rust::String
|
|
998
|
+
::rust::String peak_keypair(::std::uint32_t index);
|
|
971
999
|
|
|
972
|
-
::rust::
|
|
1000
|
+
::rust::Vec<::bark_cxx::BarkVtxo> get_vtxos();
|
|
973
1001
|
|
|
974
1002
|
::rust::String bolt11_invoice(::std::uint64_t amount_msat);
|
|
975
1003
|
|
|
976
|
-
void claim_bolt11_payment(::rust::Str bolt11);
|
|
977
|
-
|
|
978
1004
|
void maintenance();
|
|
979
1005
|
|
|
980
1006
|
void sync();
|
|
981
1007
|
|
|
982
|
-
void sync_ark();
|
|
983
|
-
|
|
984
1008
|
void sync_rounds();
|
|
985
1009
|
|
|
986
1010
|
void load_wallet(::rust::Str datadir, ::bark_cxx::CreateOpts opts);
|
|
987
1011
|
|
|
988
|
-
::bark_cxx::OnchainPaymentResult send_onchain(::rust::Str destination, ::std::uint64_t amount_sat);
|
|
989
|
-
|
|
990
|
-
::rust::String drain_onchain(::rust::Str destination, bool no_sync);
|
|
991
|
-
|
|
992
|
-
::rust::String send_many_onchain(::rust::Vec<::bark_cxx::SendManyOutput> outputs, bool no_sync);
|
|
993
|
-
|
|
994
1012
|
::rust::String board_amount(::std::uint64_t amount_sat);
|
|
995
1013
|
|
|
996
1014
|
::rust::String board_all();
|
|
997
1015
|
|
|
998
1016
|
::bark_cxx::ArkoorPaymentResult send_arkoor_payment(::rust::Str destination, ::std::uint64_t amount_sat);
|
|
999
1017
|
|
|
1000
|
-
::bark_cxx::Bolt11PaymentResult
|
|
1018
|
+
::bark_cxx::Bolt11PaymentResult send_lightning_payment(::rust::Str destination, ::std::uint64_t const *amount_sat);
|
|
1001
1019
|
|
|
1002
1020
|
::bark_cxx::LnurlPaymentResult send_lnaddr(::rust::Str addr, ::std::uint64_t amount_sat, ::rust::Str comment);
|
|
1003
1021
|
|
|
1004
|
-
::rust::String
|
|
1022
|
+
::rust::String send_round_onchain_payment(::rust::Str destination, ::std::uint64_t amount_sat);
|
|
1005
1023
|
|
|
1006
1024
|
::rust::String offboard_specific(::rust::Vec<::rust::String> vtxo_ids, ::rust::Str destination_address);
|
|
1007
1025
|
|
|
1008
1026
|
::rust::String offboard_all(::rust::Str destination_address);
|
|
1009
1027
|
|
|
1010
|
-
|
|
1028
|
+
void finish_lightning_receive(::rust::String bolt11);
|
|
1029
|
+
|
|
1030
|
+
void sync_exits();
|
|
1031
|
+
|
|
1032
|
+
::bark_cxx::OnChainBalance onchain_balance();
|
|
1033
|
+
|
|
1034
|
+
void onchain_sync();
|
|
1035
|
+
|
|
1036
|
+
::rust::String onchain_list_unspent();
|
|
1037
|
+
|
|
1038
|
+
::rust::String onchain_utxos();
|
|
1039
|
+
|
|
1040
|
+
::rust::String onchain_address();
|
|
1041
|
+
|
|
1042
|
+
::bark_cxx::OnchainPaymentResult onchain_send(::rust::Str destination, ::std::uint64_t amount_sat, ::std::uint64_t const *fee_rate);
|
|
1011
1043
|
|
|
1012
|
-
|
|
1044
|
+
::rust::String onchain_drain(::rust::Str destination, ::std::uint64_t const *fee_rate);
|
|
1013
1045
|
|
|
1014
|
-
::rust::String
|
|
1046
|
+
::rust::String onchain_send_many(::rust::Vec<::bark_cxx::SendManyOutput> outputs, ::std::uint64_t const *fee_rate);
|
|
1015
1047
|
} // namespace bark_cxx
|