react-native-nitro-ark 0.0.52 → 0.0.54
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.
|
Binary file
|
|
Binary file
|
package/cpp/HybridArk.cpp
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
#include "NitroArk.hpp"
|
|
2
2
|
|
|
3
|
-
namespace margelo::nitro::nitroark
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// Any additional implementation could go here if needed
|
|
3
|
+
namespace margelo::nitro::nitroark {
|
|
4
|
+
// The original multiply function is implemented in the header file
|
|
5
|
+
// Any additional implementation could go here if needed
|
|
7
6
|
|
|
8
7
|
}
|
package/cpp/NitroArk.hpp
CHANGED
|
@@ -14,16 +14,16 @@ using namespace margelo::nitro;
|
|
|
14
14
|
// Helper function to convert rust cxx payment type to nitrogen payment type
|
|
15
15
|
inline PaymentTypes convertPaymentType(bark_cxx::PaymentTypes type) {
|
|
16
16
|
switch (type) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
case bark_cxx::PaymentTypes::Bolt11:
|
|
18
|
+
return PaymentTypes::BOLT11;
|
|
19
|
+
case bark_cxx::PaymentTypes::Lnurl:
|
|
20
|
+
return PaymentTypes::LNURL;
|
|
21
|
+
case bark_cxx::PaymentTypes::Arkoor:
|
|
22
|
+
return PaymentTypes::ARKOOR;
|
|
23
|
+
case bark_cxx::PaymentTypes::Onchain:
|
|
24
|
+
return PaymentTypes::ONCHAIN;
|
|
25
|
+
default:
|
|
26
|
+
throw std::runtime_error("Invalid payment type");
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -41,15 +41,13 @@ public:
|
|
|
41
41
|
try {
|
|
42
42
|
rust::String mnemonic_rs = bark_cxx::create_mnemonic();
|
|
43
43
|
return std::string(mnemonic_rs.data(), mnemonic_rs.length());
|
|
44
|
-
} catch (const rust::Error
|
|
44
|
+
} catch (const rust::Error& e) {
|
|
45
45
|
throw std::runtime_error(e.what());
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
std::shared_ptr<Promise<void>>
|
|
51
|
-
createWallet(const std::string &datadir,
|
|
52
|
-
const BarkCreateOpts &opts) override {
|
|
50
|
+
std::shared_ptr<Promise<void>> createWallet(const std::string& datadir, const BarkCreateOpts& opts) override {
|
|
53
51
|
return Promise<void>::async([datadir, opts]() {
|
|
54
52
|
try {
|
|
55
53
|
bark_cxx::ConfigOpts config_opts;
|
|
@@ -57,14 +55,12 @@ public:
|
|
|
57
55
|
config_opts.ark = opts.config->ark.value_or("");
|
|
58
56
|
config_opts.esplora = opts.config->esplora.value_or("");
|
|
59
57
|
config_opts.bitcoind = opts.config->bitcoind.value_or("");
|
|
60
|
-
config_opts.bitcoind_cookie =
|
|
61
|
-
opts.config->bitcoind_cookie.value_or("");
|
|
58
|
+
config_opts.bitcoind_cookie = opts.config->bitcoind_cookie.value_or("");
|
|
62
59
|
config_opts.bitcoind_user = opts.config->bitcoind_user.value_or("");
|
|
63
60
|
config_opts.bitcoind_pass = opts.config->bitcoind_pass.value_or("");
|
|
64
|
-
config_opts.vtxo_refresh_expiry_threshold =
|
|
65
|
-
opts.config->vtxo_refresh_expiry_threshold.value_or(0));
|
|
66
|
-
config_opts.fallback_fee_rate =
|
|
67
|
-
static_cast<uint64_t>(opts.config->fallback_fee_rate.value_or(0));
|
|
61
|
+
config_opts.vtxo_refresh_expiry_threshold =
|
|
62
|
+
static_cast<uint32_t>(opts.config->vtxo_refresh_expiry_threshold.value_or(0));
|
|
63
|
+
config_opts.fallback_fee_rate = static_cast<uint64_t>(opts.config->fallback_fee_rate.value_or(0));
|
|
68
64
|
}
|
|
69
65
|
|
|
70
66
|
bark_cxx::CreateOpts create_opts;
|
|
@@ -74,8 +70,7 @@ public:
|
|
|
74
70
|
create_opts.mnemonic = opts.mnemonic;
|
|
75
71
|
uint32_t birthday_height_val;
|
|
76
72
|
if (opts.birthday_height.has_value()) {
|
|
77
|
-
birthday_height_val =
|
|
78
|
-
static_cast<uint32_t>(opts.birthday_height.value());
|
|
73
|
+
birthday_height_val = static_cast<uint32_t>(opts.birthday_height.value());
|
|
79
74
|
create_opts.birthday_height = &birthday_height_val;
|
|
80
75
|
} else {
|
|
81
76
|
create_opts.birthday_height = nullptr;
|
|
@@ -83,18 +78,17 @@ public:
|
|
|
83
78
|
create_opts.config = config_opts;
|
|
84
79
|
|
|
85
80
|
bark_cxx::create_wallet(datadir, create_opts);
|
|
86
|
-
} catch (const rust::Error
|
|
81
|
+
} catch (const rust::Error& e) {
|
|
87
82
|
throw std::runtime_error(e.what());
|
|
88
83
|
}
|
|
89
84
|
});
|
|
90
85
|
}
|
|
91
86
|
|
|
92
|
-
std::shared_ptr<Promise<void>>
|
|
93
|
-
loadWallet(const std::string &datadir, const std::string &mnemonic) override {
|
|
87
|
+
std::shared_ptr<Promise<void>> loadWallet(const std::string& datadir, const std::string& mnemonic) override {
|
|
94
88
|
return Promise<void>::async([datadir, mnemonic]() {
|
|
95
89
|
try {
|
|
96
90
|
bark_cxx::load_wallet(datadir, mnemonic);
|
|
97
|
-
} catch (const rust::Error
|
|
91
|
+
} catch (const rust::Error& e) {
|
|
98
92
|
throw std::runtime_error(e.what());
|
|
99
93
|
}
|
|
100
94
|
});
|
|
@@ -104,7 +98,7 @@ public:
|
|
|
104
98
|
return Promise<void>::async([]() {
|
|
105
99
|
try {
|
|
106
100
|
bark_cxx::close_wallet();
|
|
107
|
-
} catch (const rust::Error
|
|
101
|
+
} catch (const rust::Error& e) {
|
|
108
102
|
throw std::runtime_error(e.what());
|
|
109
103
|
}
|
|
110
104
|
});
|
|
@@ -114,8 +108,7 @@ public:
|
|
|
114
108
|
return Promise<bool>::async([]() { return bark_cxx::is_wallet_loaded(); });
|
|
115
109
|
}
|
|
116
110
|
|
|
117
|
-
std::shared_ptr<Promise<void>>
|
|
118
|
-
persistConfig(const BarkConfigOpts &opts) override {
|
|
111
|
+
std::shared_ptr<Promise<void>> persistConfig(const BarkConfigOpts& opts) override {
|
|
119
112
|
return Promise<void>::async([opts]() {
|
|
120
113
|
try {
|
|
121
114
|
bark_cxx::ConfigOpts config_opts;
|
|
@@ -125,12 +118,11 @@ public:
|
|
|
125
118
|
config_opts.bitcoind_cookie = opts.bitcoind_cookie.value_or("");
|
|
126
119
|
config_opts.bitcoind_user = opts.bitcoind_user.value_or("");
|
|
127
120
|
config_opts.bitcoind_pass = opts.bitcoind_pass.value_or("");
|
|
128
|
-
config_opts.vtxo_refresh_expiry_threshold =
|
|
129
|
-
opts.vtxo_refresh_expiry_threshold.value_or(0));
|
|
130
|
-
config_opts.fallback_fee_rate =
|
|
131
|
-
static_cast<uint64_t>(opts.fallback_fee_rate.value_or(0));
|
|
121
|
+
config_opts.vtxo_refresh_expiry_threshold =
|
|
122
|
+
static_cast<uint32_t>(opts.vtxo_refresh_expiry_threshold.value_or(0));
|
|
123
|
+
config_opts.fallback_fee_rate = static_cast<uint64_t>(opts.fallback_fee_rate.value_or(0));
|
|
132
124
|
bark_cxx::persist_config(config_opts);
|
|
133
|
-
} catch (const rust::Error
|
|
125
|
+
} catch (const rust::Error& e) {
|
|
134
126
|
throw std::runtime_error(e.what());
|
|
135
127
|
}
|
|
136
128
|
});
|
|
@@ -140,7 +132,7 @@ public:
|
|
|
140
132
|
return Promise<void>::async([]() {
|
|
141
133
|
try {
|
|
142
134
|
bark_cxx::maintenance();
|
|
143
|
-
} catch (const rust::Error
|
|
135
|
+
} catch (const rust::Error& e) {
|
|
144
136
|
throw std::runtime_error(e.what());
|
|
145
137
|
}
|
|
146
138
|
});
|
|
@@ -150,7 +142,7 @@ public:
|
|
|
150
142
|
return Promise<void>::async([]() {
|
|
151
143
|
try {
|
|
152
144
|
bark_cxx::maintenance_refresh();
|
|
153
|
-
} catch (const rust::Error
|
|
145
|
+
} catch (const rust::Error& e) {
|
|
154
146
|
throw std::runtime_error(e.what());
|
|
155
147
|
}
|
|
156
148
|
});
|
|
@@ -160,7 +152,7 @@ public:
|
|
|
160
152
|
return Promise<void>::async([]() {
|
|
161
153
|
try {
|
|
162
154
|
bark_cxx::sync();
|
|
163
|
-
} catch (const rust::Error
|
|
155
|
+
} catch (const rust::Error& e) {
|
|
164
156
|
throw std::runtime_error(e.what());
|
|
165
157
|
}
|
|
166
158
|
});
|
|
@@ -170,7 +162,7 @@ public:
|
|
|
170
162
|
return Promise<void>::async([]() {
|
|
171
163
|
try {
|
|
172
164
|
bark_cxx::sync_exits();
|
|
173
|
-
} catch (const rust::Error
|
|
165
|
+
} catch (const rust::Error& e) {
|
|
174
166
|
throw std::runtime_error(e.what());
|
|
175
167
|
}
|
|
176
168
|
});
|
|
@@ -180,7 +172,7 @@ public:
|
|
|
180
172
|
return Promise<void>::async([]() {
|
|
181
173
|
try {
|
|
182
174
|
bark_cxx::sync_rounds();
|
|
183
|
-
} catch (const rust::Error
|
|
175
|
+
} catch (const rust::Error& e) {
|
|
184
176
|
throw std::runtime_error(e.what());
|
|
185
177
|
}
|
|
186
178
|
});
|
|
@@ -193,21 +185,15 @@ public:
|
|
|
193
185
|
try {
|
|
194
186
|
bark_cxx::CxxArkInfo rust_info = bark_cxx::get_ark_info();
|
|
195
187
|
BarkArkInfo info;
|
|
196
|
-
info.network =
|
|
197
|
-
|
|
198
|
-
info.
|
|
199
|
-
rust_info.server_pubkey.length());
|
|
200
|
-
info.round_interval_secs =
|
|
201
|
-
static_cast<double>(rust_info.round_interval_secs);
|
|
188
|
+
info.network = std::string(rust_info.network.data(), rust_info.network.length());
|
|
189
|
+
info.server_pubkey = std::string(rust_info.server_pubkey.data(), rust_info.server_pubkey.length());
|
|
190
|
+
info.round_interval_secs = static_cast<double>(rust_info.round_interval_secs);
|
|
202
191
|
info.vtxo_exit_delta = static_cast<double>(rust_info.vtxo_exit_delta);
|
|
203
|
-
info.vtxo_expiry_delta =
|
|
204
|
-
|
|
205
|
-
info.
|
|
206
|
-
static_cast<double>(rust_info.htlc_expiry_delta);
|
|
207
|
-
info.max_vtxo_amount_sat =
|
|
208
|
-
static_cast<double>(rust_info.max_vtxo_amount_sat);
|
|
192
|
+
info.vtxo_expiry_delta = static_cast<double>(rust_info.vtxo_expiry_delta);
|
|
193
|
+
info.htlc_expiry_delta = static_cast<double>(rust_info.htlc_expiry_delta);
|
|
194
|
+
info.max_vtxo_amount_sat = static_cast<double>(rust_info.max_vtxo_amount_sat);
|
|
209
195
|
return info;
|
|
210
|
-
} catch (const rust::Error
|
|
196
|
+
} catch (const rust::Error& e) {
|
|
211
197
|
throw std::runtime_error(e.what());
|
|
212
198
|
}
|
|
213
199
|
});
|
|
@@ -219,13 +205,11 @@ public:
|
|
|
219
205
|
bark_cxx::OffchainBalance rust_balance = bark_cxx::offchain_balance();
|
|
220
206
|
OffchainBalanceResult balance;
|
|
221
207
|
balance.spendable = static_cast<double>(rust_balance.spendable);
|
|
222
|
-
balance.pending_lightning_send =
|
|
223
|
-
|
|
224
|
-
balance.pending_in_round =
|
|
225
|
-
static_cast<double>(rust_balance.pending_in_round);
|
|
208
|
+
balance.pending_lightning_send = static_cast<double>(rust_balance.pending_lightning_send);
|
|
209
|
+
balance.pending_in_round = static_cast<double>(rust_balance.pending_in_round);
|
|
226
210
|
balance.pending_exit = static_cast<double>(rust_balance.pending_exit);
|
|
227
211
|
return balance;
|
|
228
|
-
} catch (const rust::Error
|
|
212
|
+
} catch (const rust::Error& e) {
|
|
229
213
|
throw std::runtime_error(e.what());
|
|
230
214
|
}
|
|
231
215
|
});
|
|
@@ -234,16 +218,13 @@ public:
|
|
|
234
218
|
std::shared_ptr<Promise<KeyPairResult>> deriveStoreNextKeypair() override {
|
|
235
219
|
return Promise<KeyPairResult>::async([]() {
|
|
236
220
|
try {
|
|
237
|
-
bark_cxx::KeyPairResult keypair_rs =
|
|
238
|
-
bark_cxx::derive_store_next_keypair();
|
|
221
|
+
bark_cxx::KeyPairResult keypair_rs = bark_cxx::derive_store_next_keypair();
|
|
239
222
|
KeyPairResult keypair;
|
|
240
|
-
keypair.public_key = std::string(keypair_rs.public_key.data(),
|
|
241
|
-
|
|
242
|
-
keypair.secret_key = std::string(keypair_rs.secret_key.data(),
|
|
243
|
-
keypair_rs.secret_key.length());
|
|
223
|
+
keypair.public_key = std::string(keypair_rs.public_key.data(), keypair_rs.public_key.length());
|
|
224
|
+
keypair.secret_key = std::string(keypair_rs.secret_key.data(), keypair_rs.secret_key.length());
|
|
244
225
|
|
|
245
226
|
return keypair;
|
|
246
|
-
} catch (const rust::Error
|
|
227
|
+
} catch (const rust::Error& e) {
|
|
247
228
|
throw std::runtime_error(e.what());
|
|
248
229
|
}
|
|
249
230
|
});
|
|
@@ -255,12 +236,10 @@ public:
|
|
|
255
236
|
uint32_t index_val = static_cast<uint32_t>(index);
|
|
256
237
|
bark_cxx::KeyPairResult keypair_rs = bark_cxx::peak_keypair(index_val);
|
|
257
238
|
KeyPairResult keypair;
|
|
258
|
-
keypair.public_key = std::string(keypair_rs.public_key.data(),
|
|
259
|
-
|
|
260
|
-
keypair.secret_key = std::string(keypair_rs.secret_key.data(),
|
|
261
|
-
keypair_rs.secret_key.length());
|
|
239
|
+
keypair.public_key = std::string(keypair_rs.public_key.data(), keypair_rs.public_key.length());
|
|
240
|
+
keypair.secret_key = std::string(keypair_rs.secret_key.data(), keypair_rs.secret_key.length());
|
|
262
241
|
return keypair;
|
|
263
|
-
} catch (const rust::Error
|
|
242
|
+
} catch (const rust::Error& e) {
|
|
264
243
|
throw std::runtime_error(e.what());
|
|
265
244
|
}
|
|
266
245
|
});
|
|
@@ -271,72 +250,65 @@ public:
|
|
|
271
250
|
try {
|
|
272
251
|
bark_cxx::NewAddressResult address_rs = bark_cxx::new_address();
|
|
273
252
|
NewAddressResult address;
|
|
274
|
-
address.user_pubkey = std::string(address_rs.user_pubkey.data(),
|
|
275
|
-
|
|
276
|
-
address.
|
|
277
|
-
std::string(address_rs.ark_id.data(), address_rs.ark_id.length());
|
|
278
|
-
address.address =
|
|
279
|
-
std::string(address_rs.address.data(), address_rs.address.length());
|
|
253
|
+
address.user_pubkey = std::string(address_rs.user_pubkey.data(), address_rs.user_pubkey.length());
|
|
254
|
+
address.ark_id = std::string(address_rs.ark_id.data(), address_rs.ark_id.length());
|
|
255
|
+
address.address = std::string(address_rs.address.data(), address_rs.address.length());
|
|
280
256
|
return address;
|
|
281
257
|
|
|
282
|
-
} catch (const rust::Error
|
|
258
|
+
} catch (const rust::Error& e) {
|
|
283
259
|
throw std::runtime_error(e.what());
|
|
284
260
|
}
|
|
285
261
|
});
|
|
286
262
|
}
|
|
287
263
|
|
|
288
|
-
std::shared_ptr<Promise<std::string>> signMessage(const std::string
|
|
289
|
-
double index) override {
|
|
264
|
+
std::shared_ptr<Promise<std::string>> signMessage(const std::string& message, double index) override {
|
|
290
265
|
return Promise<std::string>::async([message, index]() {
|
|
291
266
|
try {
|
|
292
267
|
uint32_t index_val = static_cast<uint32_t>(index);
|
|
293
268
|
rust::String signature_rs = bark_cxx::sign_message(message, index_val);
|
|
294
269
|
return std::string(signature_rs.data(), signature_rs.length());
|
|
295
|
-
} catch (const rust::Error
|
|
270
|
+
} catch (const rust::Error& e) {
|
|
296
271
|
throw std::runtime_error(e.what());
|
|
297
272
|
}
|
|
298
273
|
});
|
|
299
274
|
}
|
|
300
|
-
|
|
301
|
-
std::shared_ptr<Promise<std::string>>
|
|
302
|
-
|
|
275
|
+
|
|
276
|
+
std::shared_ptr<Promise<std::string>> signMesssageWithMnemonic(const std::string& message,
|
|
277
|
+
const std::string& mnemonic,
|
|
278
|
+
const std::string& network, double index) override {
|
|
303
279
|
return Promise<std::string>::async([message, mnemonic, network, index]() {
|
|
304
280
|
try {
|
|
305
281
|
uint32_t index_val = static_cast<uint32_t>(index);
|
|
306
282
|
rust::String signature_rs = bark_cxx::sign_messsage_with_mnemonic(message, mnemonic, network, index_val);
|
|
307
283
|
return std::string(signature_rs.data(), signature_rs.length());
|
|
308
|
-
} catch (const rust::Error
|
|
284
|
+
} catch (const rust::Error& e) {
|
|
309
285
|
throw std::runtime_error(e.what());
|
|
310
286
|
}
|
|
311
287
|
});
|
|
312
288
|
}
|
|
313
289
|
|
|
314
|
-
std::shared_ptr<Promise<KeyPairResult>>
|
|
315
|
-
|
|
316
|
-
double index) override {
|
|
290
|
+
std::shared_ptr<Promise<KeyPairResult>> deriveKeypairFromMnemonic(const std::string& mnemonic,
|
|
291
|
+
const std::string& network, double index) override {
|
|
317
292
|
return Promise<KeyPairResult>::async([mnemonic, network, index]() {
|
|
318
293
|
try {
|
|
319
294
|
uint32_t index_val = static_cast<uint32_t>(index);
|
|
320
295
|
bark_cxx::KeyPairResult keypair_rs = bark_cxx::derive_keypair_from_mnemonic(mnemonic, network, index_val);
|
|
321
296
|
KeyPairResult keypair;
|
|
322
|
-
keypair.public_key = std::string(keypair_rs.public_key.data(),
|
|
323
|
-
|
|
324
|
-
keypair.secret_key = std::string(keypair_rs.secret_key.data(),
|
|
325
|
-
keypair_rs.secret_key.length());
|
|
297
|
+
keypair.public_key = std::string(keypair_rs.public_key.data(), keypair_rs.public_key.length());
|
|
298
|
+
keypair.secret_key = std::string(keypair_rs.secret_key.data(), keypair_rs.secret_key.length());
|
|
326
299
|
return keypair;
|
|
327
|
-
} catch (const rust::Error
|
|
300
|
+
} catch (const rust::Error& e) {
|
|
328
301
|
throw std::runtime_error(e.what());
|
|
329
302
|
}
|
|
330
303
|
});
|
|
331
304
|
}
|
|
332
305
|
|
|
333
|
-
std::shared_ptr<Promise<bool>>
|
|
334
|
-
|
|
335
|
-
const std::string &publicKey) override {
|
|
306
|
+
std::shared_ptr<Promise<bool>> verifyMessage(const std::string& message, const std::string& signature,
|
|
307
|
+
const std::string& publicKey) override {
|
|
336
308
|
return Promise<bool>::async([message, signature, publicKey]() {
|
|
337
309
|
try {
|
|
338
310
|
return bark_cxx::verify_message(message, signature, publicKey);
|
|
339
|
-
} catch (const rust::Error
|
|
311
|
+
} catch (const rust::Error& e) {
|
|
340
312
|
throw std::runtime_error(e.what());
|
|
341
313
|
}
|
|
342
314
|
});
|
|
@@ -347,48 +319,40 @@ public:
|
|
|
347
319
|
try {
|
|
348
320
|
rust::Vec<bark_cxx::BarkVtxo> rust_vtxos = bark_cxx::get_vtxos();
|
|
349
321
|
std::vector<BarkVtxo> vtxos;
|
|
350
|
-
for (const auto
|
|
322
|
+
for (const auto& rust_vtxo : rust_vtxos) {
|
|
351
323
|
BarkVtxo vtxo;
|
|
352
324
|
vtxo.amount = static_cast<double>(rust_vtxo.amount);
|
|
353
325
|
vtxo.expiry_height = static_cast<double>(rust_vtxo.expiry_height);
|
|
354
|
-
vtxo.server_pubkey = std::string(rust_vtxo.server_pubkey.data(),
|
|
355
|
-
rust_vtxo.server_pubkey.length());
|
|
326
|
+
vtxo.server_pubkey = std::string(rust_vtxo.server_pubkey.data(), rust_vtxo.server_pubkey.length());
|
|
356
327
|
vtxo.exit_delta = static_cast<double>(rust_vtxo.exit_delta);
|
|
357
|
-
vtxo.anchor_point = std::string(rust_vtxo.anchor_point.data(),
|
|
358
|
-
|
|
359
|
-
vtxo.point =
|
|
360
|
-
std::string(rust_vtxo.point.data(), rust_vtxo.point.length());
|
|
328
|
+
vtxo.anchor_point = std::string(rust_vtxo.anchor_point.data(), rust_vtxo.anchor_point.length());
|
|
329
|
+
vtxo.point = std::string(rust_vtxo.point.data(), rust_vtxo.point.length());
|
|
361
330
|
vtxos.push_back(vtxo);
|
|
362
331
|
}
|
|
363
332
|
return vtxos;
|
|
364
|
-
} catch (const rust::Error
|
|
333
|
+
} catch (const rust::Error& e) {
|
|
365
334
|
throw std::runtime_error(e.what());
|
|
366
335
|
}
|
|
367
336
|
});
|
|
368
337
|
}
|
|
369
338
|
|
|
370
|
-
std::shared_ptr<Promise<std::vector<BarkVtxo>>>
|
|
371
|
-
getExpiringVtxos(double threshold) override {
|
|
339
|
+
std::shared_ptr<Promise<std::vector<BarkVtxo>>> getExpiringVtxos(double threshold) override {
|
|
372
340
|
return Promise<std::vector<BarkVtxo>>::async([threshold]() {
|
|
373
341
|
try {
|
|
374
|
-
rust::Vec<bark_cxx::BarkVtxo> rust_vtxos =
|
|
375
|
-
bark_cxx::get_expiring_vtxos(static_cast<uint32_t>(threshold));
|
|
342
|
+
rust::Vec<bark_cxx::BarkVtxo> rust_vtxos = bark_cxx::get_expiring_vtxos(static_cast<uint32_t>(threshold));
|
|
376
343
|
std::vector<BarkVtxo> vtxos;
|
|
377
|
-
for (const auto
|
|
344
|
+
for (const auto& rust_vtxo : rust_vtxos) {
|
|
378
345
|
BarkVtxo vtxo;
|
|
379
346
|
vtxo.amount = static_cast<double>(rust_vtxo.amount);
|
|
380
347
|
vtxo.expiry_height = static_cast<double>(rust_vtxo.expiry_height);
|
|
381
|
-
vtxo.server_pubkey = std::string(rust_vtxo.server_pubkey.data(),
|
|
382
|
-
rust_vtxo.server_pubkey.length());
|
|
348
|
+
vtxo.server_pubkey = std::string(rust_vtxo.server_pubkey.data(), rust_vtxo.server_pubkey.length());
|
|
383
349
|
vtxo.exit_delta = static_cast<double>(rust_vtxo.exit_delta);
|
|
384
|
-
vtxo.anchor_point = std::string(rust_vtxo.anchor_point.data(),
|
|
385
|
-
|
|
386
|
-
vtxo.point =
|
|
387
|
-
std::string(rust_vtxo.point.data(), rust_vtxo.point.length());
|
|
350
|
+
vtxo.anchor_point = std::string(rust_vtxo.anchor_point.data(), rust_vtxo.anchor_point.length());
|
|
351
|
+
vtxo.point = std::string(rust_vtxo.point.data(), rust_vtxo.point.length());
|
|
388
352
|
vtxos.push_back(vtxo);
|
|
389
353
|
}
|
|
390
354
|
return vtxos;
|
|
391
|
-
} catch (const rust::Error
|
|
355
|
+
} catch (const rust::Error& e) {
|
|
392
356
|
throw std::runtime_error(e.what());
|
|
393
357
|
}
|
|
394
358
|
});
|
|
@@ -402,13 +366,11 @@ public:
|
|
|
402
366
|
bark_cxx::OnChainBalance rust_balance = bark_cxx::onchain_balance();
|
|
403
367
|
OnchainBalanceResult balance;
|
|
404
368
|
balance.immature = static_cast<double>(rust_balance.immature);
|
|
405
|
-
balance.trusted_pending =
|
|
406
|
-
|
|
407
|
-
balance.untrusted_pending =
|
|
408
|
-
static_cast<double>(rust_balance.untrusted_pending);
|
|
369
|
+
balance.trusted_pending = static_cast<double>(rust_balance.trusted_pending);
|
|
370
|
+
balance.untrusted_pending = static_cast<double>(rust_balance.untrusted_pending);
|
|
409
371
|
balance.confirmed = static_cast<double>(rust_balance.confirmed);
|
|
410
372
|
return balance;
|
|
411
|
-
} catch (const rust::Error
|
|
373
|
+
} catch (const rust::Error& e) {
|
|
412
374
|
throw std::runtime_error(e.what());
|
|
413
375
|
}
|
|
414
376
|
});
|
|
@@ -418,7 +380,7 @@ public:
|
|
|
418
380
|
return Promise<void>::async([]() {
|
|
419
381
|
try {
|
|
420
382
|
bark_cxx::onchain_sync();
|
|
421
|
-
} catch (const rust::Error
|
|
383
|
+
} catch (const rust::Error& e) {
|
|
422
384
|
throw std::runtime_error(e.what());
|
|
423
385
|
}
|
|
424
386
|
});
|
|
@@ -429,7 +391,7 @@ public:
|
|
|
429
391
|
try {
|
|
430
392
|
rust::String json_rs = bark_cxx::onchain_list_unspent();
|
|
431
393
|
return std::string(json_rs.data(), json_rs.length());
|
|
432
|
-
} catch (const rust::Error
|
|
394
|
+
} catch (const rust::Error& e) {
|
|
433
395
|
throw std::runtime_error(e.what());
|
|
434
396
|
}
|
|
435
397
|
});
|
|
@@ -440,7 +402,7 @@ public:
|
|
|
440
402
|
try {
|
|
441
403
|
rust::String json_rs = bark_cxx::onchain_utxos();
|
|
442
404
|
return std::string(json_rs.data(), json_rs.length());
|
|
443
|
-
} catch (const rust::Error
|
|
405
|
+
} catch (const rust::Error& e) {
|
|
444
406
|
throw std::runtime_error(e.what());
|
|
445
407
|
}
|
|
446
408
|
});
|
|
@@ -451,48 +413,41 @@ public:
|
|
|
451
413
|
try {
|
|
452
414
|
rust::String address_rs = bark_cxx::onchain_address();
|
|
453
415
|
return std::string(address_rs.data(), address_rs.length());
|
|
454
|
-
} catch (const rust::Error
|
|
455
|
-
throw std::runtime_error(e.what());
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
std::shared_ptr<Promise<OnchainPaymentResult>>
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
std::shared_ptr<Promise<std::string>>
|
|
494
|
-
onchainDrain(const std::string &destination,
|
|
495
|
-
std::optional<double> feeRate) override {
|
|
416
|
+
} catch (const rust::Error& e) {
|
|
417
|
+
throw std::runtime_error(e.what());
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
std::shared_ptr<Promise<OnchainPaymentResult>> onchainSend(const std::string& destination, double amountSat,
|
|
423
|
+
std::optional<double> feeRate) override {
|
|
424
|
+
return Promise<OnchainPaymentResult>::async([destination, amountSat, feeRate]() {
|
|
425
|
+
try {
|
|
426
|
+
uint64_t feeRate_val;
|
|
427
|
+
bark_cxx::OnchainPaymentResult rust_result;
|
|
428
|
+
if (feeRate.has_value()) {
|
|
429
|
+
feeRate_val = static_cast<uint64_t>(feeRate.value());
|
|
430
|
+
rust_result = bark_cxx::onchain_send(destination, static_cast<uint64_t>(amountSat), &feeRate_val);
|
|
431
|
+
} else {
|
|
432
|
+
rust_result = bark_cxx::onchain_send(destination, static_cast<uint64_t>(amountSat), nullptr);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
OnchainPaymentResult result;
|
|
436
|
+
result.txid = std::string(rust_result.txid.data(), rust_result.txid.length());
|
|
437
|
+
result.amount_sat = static_cast<double>(rust_result.amount_sat);
|
|
438
|
+
result.destination_address =
|
|
439
|
+
std::string(rust_result.destination_address.data(), rust_result.destination_address.length());
|
|
440
|
+
result.payment_type = convertPaymentType(rust_result.payment_type);
|
|
441
|
+
|
|
442
|
+
return result;
|
|
443
|
+
} catch (const rust::Error& e) {
|
|
444
|
+
throw std::runtime_error(e.what());
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
std::shared_ptr<Promise<std::string>> onchainDrain(const std::string& destination,
|
|
450
|
+
std::optional<double> feeRate) override {
|
|
496
451
|
return Promise<std::string>::async([destination, feeRate]() {
|
|
497
452
|
try {
|
|
498
453
|
uint64_t feeRate_val;
|
|
@@ -504,34 +459,30 @@ public:
|
|
|
504
459
|
txid_rs = bark_cxx::onchain_drain(destination, nullptr);
|
|
505
460
|
}
|
|
506
461
|
return std::string(txid_rs.data(), txid_rs.length());
|
|
507
|
-
} catch (const rust::Error
|
|
462
|
+
} catch (const rust::Error& e) {
|
|
508
463
|
throw std::runtime_error(e.what());
|
|
509
464
|
}
|
|
510
465
|
});
|
|
511
466
|
}
|
|
512
467
|
|
|
513
|
-
std::shared_ptr<Promise<std::string>>
|
|
514
|
-
|
|
515
|
-
std::optional<double> feeRate) override {
|
|
468
|
+
std::shared_ptr<Promise<std::string>> onchainSendMany(const std::vector<BarkSendManyOutput>& outputs,
|
|
469
|
+
std::optional<double> feeRate) override {
|
|
516
470
|
return Promise<std::string>::async([outputs, feeRate]() {
|
|
517
471
|
try {
|
|
518
472
|
rust::Vec<bark_cxx::SendManyOutput> cxx_outputs;
|
|
519
|
-
for (const auto
|
|
520
|
-
cxx_outputs.push_back({rust::String(output.destination),
|
|
521
|
-
static_cast<uint64_t>(output.amountSat)});
|
|
473
|
+
for (const auto& output : outputs) {
|
|
474
|
+
cxx_outputs.push_back({rust::String(output.destination), static_cast<uint64_t>(output.amountSat)});
|
|
522
475
|
}
|
|
523
476
|
uint64_t feeRate_val;
|
|
524
477
|
rust::String txid_rs;
|
|
525
478
|
if (feeRate.has_value()) {
|
|
526
479
|
feeRate_val = static_cast<uint64_t>(feeRate.value());
|
|
527
|
-
txid_rs =
|
|
528
|
-
bark_cxx::onchain_send_many(std::move(cxx_outputs), &feeRate_val);
|
|
480
|
+
txid_rs = bark_cxx::onchain_send_many(std::move(cxx_outputs), &feeRate_val);
|
|
529
481
|
} else {
|
|
530
|
-
txid_rs =
|
|
531
|
-
bark_cxx::onchain_send_many(std::move(cxx_outputs), nullptr);
|
|
482
|
+
txid_rs = bark_cxx::onchain_send_many(std::move(cxx_outputs), nullptr);
|
|
532
483
|
}
|
|
533
484
|
return std::string(txid_rs.data(), txid_rs.length());
|
|
534
|
-
} catch (const rust::Error
|
|
485
|
+
} catch (const rust::Error& e) {
|
|
535
486
|
throw std::runtime_error(e.what());
|
|
536
487
|
}
|
|
537
488
|
});
|
|
@@ -539,90 +490,76 @@ public:
|
|
|
539
490
|
|
|
540
491
|
// --- Lightning Operations ---
|
|
541
492
|
|
|
542
|
-
std::shared_ptr<Promise<LightningPaymentResult>>
|
|
543
|
-
|
|
544
|
-
std::optional<double> amountSat) override {
|
|
493
|
+
std::shared_ptr<Promise<LightningPaymentResult>> sendLightningPayment(const std::string& destination,
|
|
494
|
+
std::optional<double> amountSat) override {
|
|
545
495
|
return Promise<LightningPaymentResult>::async([destination, amountSat]() {
|
|
546
496
|
try {
|
|
547
497
|
bark_cxx::Bolt11PaymentResult rust_result;
|
|
548
498
|
if (amountSat.has_value()) {
|
|
549
499
|
uint64_t amountSat_val = static_cast<uint64_t>(amountSat.value());
|
|
550
|
-
rust_result =
|
|
551
|
-
bark_cxx::send_lightning_payment(destination, &amountSat_val);
|
|
500
|
+
rust_result = bark_cxx::send_lightning_payment(destination, &amountSat_val);
|
|
552
501
|
} else {
|
|
553
502
|
rust_result = bark_cxx::send_lightning_payment(destination, nullptr);
|
|
554
503
|
}
|
|
555
504
|
|
|
556
505
|
LightningPaymentResult result;
|
|
557
|
-
result.bolt11_invoice =
|
|
558
|
-
|
|
559
|
-
rust_result.bolt11_invoice.length());
|
|
560
|
-
result.preimage = std::string(rust_result.preimage.data(),
|
|
561
|
-
rust_result.preimage.length());
|
|
506
|
+
result.bolt11_invoice = std::string(rust_result.bolt11_invoice.data(), rust_result.bolt11_invoice.length());
|
|
507
|
+
result.preimage = std::string(rust_result.preimage.data(), rust_result.preimage.length());
|
|
562
508
|
result.payment_type = convertPaymentType(rust_result.payment_type);
|
|
563
509
|
|
|
564
510
|
return result;
|
|
565
|
-
} catch (const rust::Error
|
|
511
|
+
} catch (const rust::Error& e) {
|
|
566
512
|
throw std::runtime_error(e.what());
|
|
567
513
|
}
|
|
568
514
|
});
|
|
569
515
|
}
|
|
570
516
|
|
|
571
|
-
std::shared_ptr<Promise<LnurlPaymentResult>>
|
|
572
|
-
|
|
573
|
-
const std::string &comment) override {
|
|
517
|
+
std::shared_ptr<Promise<LnurlPaymentResult>> sendLnaddr(const std::string& addr, double amountSat,
|
|
518
|
+
const std::string& comment) override {
|
|
574
519
|
return Promise<LnurlPaymentResult>::async([addr, amountSat, comment]() {
|
|
575
520
|
try {
|
|
576
|
-
bark_cxx::LnurlPaymentResult rust_result =
|
|
577
|
-
addr, static_cast<uint64_t>(amountSat), comment);
|
|
521
|
+
bark_cxx::LnurlPaymentResult rust_result =
|
|
522
|
+
bark_cxx::send_lnaddr(addr, static_cast<uint64_t>(amountSat), comment);
|
|
578
523
|
|
|
579
524
|
LnurlPaymentResult result;
|
|
580
|
-
result.lnurl =
|
|
581
|
-
|
|
582
|
-
result.
|
|
583
|
-
std::string(rust_result.bolt11_invoice.data(),
|
|
584
|
-
rust_result.bolt11_invoice.length());
|
|
585
|
-
result.preimage = std::string(rust_result.preimage.data(),
|
|
586
|
-
rust_result.preimage.length());
|
|
525
|
+
result.lnurl = std::string(rust_result.lnurl.data(), rust_result.lnurl.length());
|
|
526
|
+
result.bolt11_invoice = std::string(rust_result.bolt11_invoice.data(), rust_result.bolt11_invoice.length());
|
|
527
|
+
result.preimage = std::string(rust_result.preimage.data(), rust_result.preimage.length());
|
|
587
528
|
result.payment_type = convertPaymentType(rust_result.payment_type);
|
|
588
529
|
|
|
589
530
|
return result;
|
|
590
|
-
} catch (const rust::Error
|
|
531
|
+
} catch (const rust::Error& e) {
|
|
591
532
|
throw std::runtime_error(e.what());
|
|
592
533
|
}
|
|
593
534
|
});
|
|
594
535
|
}
|
|
595
536
|
|
|
596
|
-
std::shared_ptr<Promise<std::string>>
|
|
597
|
-
bolt11Invoice(double amountMsat) override {
|
|
537
|
+
std::shared_ptr<Promise<std::string>> bolt11Invoice(double amountMsat) override {
|
|
598
538
|
return Promise<std::string>::async([amountMsat]() {
|
|
599
539
|
try {
|
|
600
|
-
rust::String invoice_rs =
|
|
601
|
-
bark_cxx::bolt11_invoice(static_cast<uint64_t>(amountMsat));
|
|
540
|
+
rust::String invoice_rs = bark_cxx::bolt11_invoice(static_cast<uint64_t>(amountMsat));
|
|
602
541
|
return std::string(invoice_rs.data(), invoice_rs.length());
|
|
603
|
-
} catch (const rust::Error
|
|
542
|
+
} catch (const rust::Error& e) {
|
|
604
543
|
throw std::runtime_error(e.what());
|
|
605
544
|
}
|
|
606
545
|
});
|
|
607
546
|
}
|
|
608
547
|
|
|
609
|
-
std::shared_ptr<Promise<void>>
|
|
610
|
-
finishLightningReceive(const std::string &bolt11) override {
|
|
548
|
+
std::shared_ptr<Promise<void>> finishLightningReceive(const std::string& bolt11) override {
|
|
611
549
|
return Promise<void>::async([bolt11]() {
|
|
612
550
|
try {
|
|
613
551
|
bark_cxx::finish_lightning_receive(bolt11);
|
|
614
|
-
} catch (const rust::Error
|
|
552
|
+
} catch (const rust::Error& e) {
|
|
615
553
|
throw std::runtime_error(e.what());
|
|
616
554
|
}
|
|
617
555
|
});
|
|
618
556
|
}
|
|
619
557
|
|
|
620
558
|
std::shared_ptr<Promise<std::optional<LightningReceive>>>
|
|
621
|
-
lightningReceiveStatus(const std::string
|
|
559
|
+
lightningReceiveStatus(const std::string& payment) override {
|
|
622
560
|
return Promise<std::optional<LightningReceive>>::async([payment]() {
|
|
623
561
|
try {
|
|
624
|
-
const bark_cxx::LightningReceive
|
|
625
|
-
bark_cxx::lightning_receive_status(payment);
|
|
562
|
+
const bark_cxx::LightningReceive* status_ptr = bark_cxx::lightning_receive_status(payment);
|
|
626
563
|
|
|
627
564
|
if (status_ptr == nullptr) {
|
|
628
565
|
return std::optional<LightningReceive>();
|
|
@@ -631,22 +568,18 @@ public:
|
|
|
631
568
|
std::unique_ptr<const bark_cxx::LightningReceive> status(status_ptr);
|
|
632
569
|
|
|
633
570
|
LightningReceive result;
|
|
634
|
-
result.payment_hash = std::string(status->payment_hash.data(),
|
|
635
|
-
|
|
636
|
-
result.
|
|
637
|
-
status->payment_preimage.length());
|
|
638
|
-
result.invoice =
|
|
639
|
-
std::string(status->invoice.data(), status->invoice.length());
|
|
571
|
+
result.payment_hash = std::string(status->payment_hash.data(), status->payment_hash.length());
|
|
572
|
+
result.payment_preimage = std::string(status->payment_preimage.data(), status->payment_preimage.length());
|
|
573
|
+
result.invoice = std::string(status->invoice.data(), status->invoice.length());
|
|
640
574
|
|
|
641
575
|
if (status->preimage_revealed_at != nullptr) {
|
|
642
|
-
result.preimage_revealed_at =
|
|
643
|
-
static_cast<double>(*status->preimage_revealed_at);
|
|
576
|
+
result.preimage_revealed_at = static_cast<double>(*status->preimage_revealed_at);
|
|
644
577
|
} else {
|
|
645
578
|
result.preimage_revealed_at = std::nullopt;
|
|
646
579
|
}
|
|
647
580
|
|
|
648
581
|
return std::optional<LightningReceive>(result);
|
|
649
|
-
} catch (const rust::Error
|
|
582
|
+
} catch (const rust::Error& e) {
|
|
650
583
|
throw std::runtime_error(e.what());
|
|
651
584
|
}
|
|
652
585
|
});
|
|
@@ -657,10 +590,9 @@ public:
|
|
|
657
590
|
std::shared_ptr<Promise<std::string>> boardAmount(double amountSat) override {
|
|
658
591
|
return Promise<std::string>::async([amountSat]() {
|
|
659
592
|
try {
|
|
660
|
-
rust::String status_rs =
|
|
661
|
-
bark_cxx::board_amount(static_cast<uint64_t>(amountSat));
|
|
593
|
+
rust::String status_rs = bark_cxx::board_amount(static_cast<uint64_t>(amountSat));
|
|
662
594
|
return std::string(status_rs.data(), status_rs.length());
|
|
663
|
-
} catch (const rust::Error
|
|
595
|
+
} catch (const rust::Error& e) {
|
|
664
596
|
throw std::runtime_error(e.what());
|
|
665
597
|
}
|
|
666
598
|
});
|
|
@@ -671,69 +603,62 @@ public:
|
|
|
671
603
|
try {
|
|
672
604
|
rust::String status_rs = bark_cxx::board_all();
|
|
673
605
|
return std::string(status_rs.data(), status_rs.length());
|
|
674
|
-
} catch (const rust::Error
|
|
606
|
+
} catch (const rust::Error& e) {
|
|
675
607
|
throw std::runtime_error(e.what());
|
|
676
608
|
}
|
|
677
609
|
});
|
|
678
610
|
}
|
|
679
611
|
|
|
680
|
-
std::shared_ptr<Promise<void>> validateArkoorAddress(const std::string
|
|
612
|
+
std::shared_ptr<Promise<void>> validateArkoorAddress(const std::string& address) override {
|
|
681
613
|
return Promise<void>::async([address]() {
|
|
682
614
|
try {
|
|
683
615
|
bark_cxx::validate_arkoor_address(address);
|
|
684
|
-
} catch (const rust::Error
|
|
616
|
+
} catch (const rust::Error& e) {
|
|
685
617
|
throw std::runtime_error(e.what());
|
|
686
618
|
}
|
|
687
619
|
});
|
|
688
620
|
}
|
|
689
621
|
|
|
690
|
-
std::shared_ptr<Promise<ArkoorPaymentResult>>
|
|
691
|
-
|
|
622
|
+
std::shared_ptr<Promise<ArkoorPaymentResult>> sendArkoorPayment(const std::string& destination,
|
|
623
|
+
double amountSat) override {
|
|
692
624
|
return Promise<ArkoorPaymentResult>::async([destination, amountSat]() {
|
|
693
625
|
try {
|
|
694
626
|
bark_cxx::ArkoorPaymentResult rust_result =
|
|
695
|
-
bark_cxx::send_arkoor_payment(destination,
|
|
696
|
-
static_cast<uint64_t>(amountSat));
|
|
627
|
+
bark_cxx::send_arkoor_payment(destination, static_cast<uint64_t>(amountSat));
|
|
697
628
|
|
|
698
629
|
ArkoorPaymentResult result;
|
|
699
630
|
result.amount_sat = static_cast<double>(rust_result.amount_sat);
|
|
700
631
|
result.destination_pubkey =
|
|
701
|
-
std::string(rust_result.destination_pubkey.data(),
|
|
702
|
-
rust_result.destination_pubkey.length());
|
|
632
|
+
std::string(rust_result.destination_pubkey.data(), rust_result.destination_pubkey.length());
|
|
703
633
|
result.payment_type = convertPaymentType(rust_result.payment_type);
|
|
704
634
|
|
|
705
635
|
std::vector<BarkVtxo> vtxos;
|
|
706
|
-
for (const auto
|
|
636
|
+
for (const auto& rust_vtxo : rust_result.vtxos) {
|
|
707
637
|
BarkVtxo vtxo;
|
|
708
638
|
vtxo.amount = static_cast<double>(rust_vtxo.amount);
|
|
709
639
|
vtxo.expiry_height = static_cast<double>(rust_vtxo.expiry_height);
|
|
710
|
-
vtxo.server_pubkey = std::string(rust_vtxo.server_pubkey.data(),
|
|
711
|
-
rust_vtxo.server_pubkey.length());
|
|
640
|
+
vtxo.server_pubkey = std::string(rust_vtxo.server_pubkey.data(), rust_vtxo.server_pubkey.length());
|
|
712
641
|
vtxo.exit_delta = static_cast<double>(rust_vtxo.exit_delta);
|
|
713
|
-
vtxo.anchor_point = std::string(rust_vtxo.anchor_point.data(),
|
|
714
|
-
|
|
715
|
-
vtxo.point =
|
|
716
|
-
std::string(rust_vtxo.point.data(), rust_vtxo.point.length());
|
|
642
|
+
vtxo.anchor_point = std::string(rust_vtxo.anchor_point.data(), rust_vtxo.anchor_point.length());
|
|
643
|
+
vtxo.point = std::string(rust_vtxo.point.data(), rust_vtxo.point.length());
|
|
717
644
|
vtxos.push_back(vtxo);
|
|
718
645
|
}
|
|
719
646
|
result.vtxos = vtxos;
|
|
720
647
|
|
|
721
648
|
return result;
|
|
722
|
-
} catch (const rust::Error
|
|
649
|
+
} catch (const rust::Error& e) {
|
|
723
650
|
throw std::runtime_error(e.what());
|
|
724
651
|
}
|
|
725
652
|
});
|
|
726
653
|
}
|
|
727
654
|
|
|
728
|
-
std::shared_ptr<Promise<std::string>>
|
|
729
|
-
|
|
730
|
-
double amountSat) override {
|
|
655
|
+
std::shared_ptr<Promise<std::string>> sendRoundOnchainPayment(const std::string& destination,
|
|
656
|
+
double amountSat) override {
|
|
731
657
|
return Promise<std::string>::async([destination, amountSat]() {
|
|
732
658
|
try {
|
|
733
|
-
rust::String status_rs = bark_cxx::send_round_onchain_payment(
|
|
734
|
-
destination, static_cast<uint64_t>(amountSat));
|
|
659
|
+
rust::String status_rs = bark_cxx::send_round_onchain_payment(destination, static_cast<uint64_t>(amountSat));
|
|
735
660
|
return std::string(status_rs.data(), status_rs.length());
|
|
736
|
-
} catch (const rust::Error
|
|
661
|
+
} catch (const rust::Error& e) {
|
|
737
662
|
throw std::runtime_error(e.what());
|
|
738
663
|
}
|
|
739
664
|
});
|
|
@@ -741,31 +666,28 @@ public:
|
|
|
741
666
|
|
|
742
667
|
// --- Offboarding / Exiting ---
|
|
743
668
|
|
|
744
|
-
std::shared_ptr<Promise<std::string>>
|
|
745
|
-
|
|
746
|
-
const std::string &destinationAddress) override {
|
|
669
|
+
std::shared_ptr<Promise<std::string>> offboardSpecific(const std::vector<std::string>& vtxoIds,
|
|
670
|
+
const std::string& destinationAddress) override {
|
|
747
671
|
return Promise<std::string>::async([vtxoIds, destinationAddress]() {
|
|
748
672
|
try {
|
|
749
673
|
rust::Vec<rust::String> rust_vtxo_ids;
|
|
750
|
-
for (const auto
|
|
674
|
+
for (const auto& id : vtxoIds) {
|
|
751
675
|
rust_vtxo_ids.push_back(rust::String(id));
|
|
752
676
|
}
|
|
753
|
-
rust::String status_rs = bark_cxx::offboard_specific(
|
|
754
|
-
std::move(rust_vtxo_ids), destinationAddress);
|
|
677
|
+
rust::String status_rs = bark_cxx::offboard_specific(std::move(rust_vtxo_ids), destinationAddress);
|
|
755
678
|
return std::string(status_rs.data(), status_rs.length());
|
|
756
|
-
} catch (const rust::Error
|
|
679
|
+
} catch (const rust::Error& e) {
|
|
757
680
|
throw std::runtime_error(e.what());
|
|
758
681
|
}
|
|
759
682
|
});
|
|
760
683
|
}
|
|
761
684
|
|
|
762
|
-
std::shared_ptr<Promise<std::string>>
|
|
763
|
-
offboardAll(const std::string &destinationAddress) override {
|
|
685
|
+
std::shared_ptr<Promise<std::string>> offboardAll(const std::string& destinationAddress) override {
|
|
764
686
|
return Promise<std::string>::async([destinationAddress]() {
|
|
765
687
|
try {
|
|
766
688
|
rust::String status_rs = bark_cxx::offboard_all(destinationAddress);
|
|
767
689
|
return std::string(status_rs.data(), status_rs.length());
|
|
768
|
-
} catch (const rust::Error
|
|
690
|
+
} catch (const rust::Error& e) {
|
|
769
691
|
throw std::runtime_error(e.what());
|
|
770
692
|
}
|
|
771
693
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-ark",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.54",
|
|
4
4
|
"description": "Pure C++ Nitro Modules for Ark client",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/module/index.js",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@eslint/eslintrc": "^3.3.0",
|
|
73
73
|
"@eslint/js": "^9.22.0",
|
|
74
74
|
"@evilmartians/lefthook": "^1.5.0",
|
|
75
|
-
"@react-native/eslint-config": "^0.
|
|
75
|
+
"@react-native/eslint-config": "^0.81.1",
|
|
76
76
|
"@release-it/conventional-changelog": "^9.0.2",
|
|
77
77
|
"@types/jest": "^29.5.5",
|
|
78
78
|
"@types/react": "^19.0.10",
|
|
@@ -82,12 +82,12 @@
|
|
|
82
82
|
"eslint-config-prettier": "^10.1.1",
|
|
83
83
|
"eslint-plugin-prettier": "^5.2.3",
|
|
84
84
|
"jest": "^29.7.0",
|
|
85
|
-
"nitro-codegen": "^0.
|
|
85
|
+
"nitro-codegen": "^0.29.3",
|
|
86
86
|
"prettier": "^3.0.3",
|
|
87
|
-
"react": "19.
|
|
88
|
-
"react-native": "0.
|
|
87
|
+
"react": "19.1.0",
|
|
88
|
+
"react-native": "0.81.1",
|
|
89
89
|
"react-native-builder-bob": "^0.40.13",
|
|
90
|
-
"react-native-nitro-modules": "^0.
|
|
90
|
+
"react-native-nitro-modules": "^0.29.3",
|
|
91
91
|
"release-it": "^17.10.0",
|
|
92
92
|
"turbo": "^1.10.7",
|
|
93
93
|
"typescript": "^5.2.2"
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"peerDependencies": {
|
|
96
96
|
"react": "*",
|
|
97
97
|
"react-native": "*",
|
|
98
|
-
"react-native-nitro-modules": "^0.
|
|
98
|
+
"react-native-nitro-modules": "^0.29.3"
|
|
99
99
|
},
|
|
100
100
|
"workspaces": [
|
|
101
101
|
"example"
|
|
File without changes
|