react-native-nitro-ark 0.0.51 → 0.0.53
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/HybridArk.cpp +3 -4
- package/cpp/NitroArk.hpp +212 -243
- package/cpp/generated/ark_cxx.h +22 -3
- package/lib/module/index.js +19 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NitroArk.nitro.d.ts +12 -3
- package/lib/typescript/src/NitroArk.nitro.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +14 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/nitrogen/generated/shared/c++/BarkArkInfo.hpp +5 -5
- package/nitrogen/generated/shared/c++/BarkConfigOpts.hpp +5 -5
- package/nitrogen/generated/shared/c++/BarkVtxo.hpp +5 -5
- package/nitrogen/generated/shared/c++/HybridNitroArkSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridNitroArkSpec.hpp +5 -0
- package/nitrogen/generated/shared/c++/LightningReceive.hpp +80 -0
- package/nitrogen/generated/shared/c++/OffchainBalanceResult.hpp +5 -1
- package/package.json +4 -4
- package/src/NitroArk.nitro.ts +15 -3
- package/src/index.tsx +23 -0
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,30 +41,26 @@ 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;
|
|
56
54
|
if (opts.config.has_value()) {
|
|
57
|
-
config_opts.
|
|
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,23 +108,21 @@ 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;
|
|
122
|
-
config_opts.
|
|
115
|
+
config_opts.ark = opts.ark.value_or("");
|
|
123
116
|
config_opts.esplora = opts.esplora.value_or("");
|
|
124
117
|
config_opts.bitcoind = opts.bitcoind.value_or("");
|
|
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.asp_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,11 +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
|
-
|
|
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);
|
|
224
210
|
balance.pending_exit = static_cast<double>(rust_balance.pending_exit);
|
|
225
211
|
return balance;
|
|
226
|
-
} catch (const rust::Error
|
|
212
|
+
} catch (const rust::Error& e) {
|
|
227
213
|
throw std::runtime_error(e.what());
|
|
228
214
|
}
|
|
229
215
|
});
|
|
@@ -232,16 +218,13 @@ public:
|
|
|
232
218
|
std::shared_ptr<Promise<KeyPairResult>> deriveStoreNextKeypair() override {
|
|
233
219
|
return Promise<KeyPairResult>::async([]() {
|
|
234
220
|
try {
|
|
235
|
-
bark_cxx::KeyPairResult keypair_rs =
|
|
236
|
-
bark_cxx::derive_store_next_keypair();
|
|
221
|
+
bark_cxx::KeyPairResult keypair_rs = bark_cxx::derive_store_next_keypair();
|
|
237
222
|
KeyPairResult keypair;
|
|
238
|
-
keypair.public_key = std::string(keypair_rs.public_key.data(),
|
|
239
|
-
|
|
240
|
-
keypair.secret_key = std::string(keypair_rs.secret_key.data(),
|
|
241
|
-
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());
|
|
242
225
|
|
|
243
226
|
return keypair;
|
|
244
|
-
} catch (const rust::Error
|
|
227
|
+
} catch (const rust::Error& e) {
|
|
245
228
|
throw std::runtime_error(e.what());
|
|
246
229
|
}
|
|
247
230
|
});
|
|
@@ -253,12 +236,10 @@ public:
|
|
|
253
236
|
uint32_t index_val = static_cast<uint32_t>(index);
|
|
254
237
|
bark_cxx::KeyPairResult keypair_rs = bark_cxx::peak_keypair(index_val);
|
|
255
238
|
KeyPairResult keypair;
|
|
256
|
-
keypair.public_key = std::string(keypair_rs.public_key.data(),
|
|
257
|
-
|
|
258
|
-
keypair.secret_key = std::string(keypair_rs.secret_key.data(),
|
|
259
|
-
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());
|
|
260
241
|
return keypair;
|
|
261
|
-
} catch (const rust::Error
|
|
242
|
+
} catch (const rust::Error& e) {
|
|
262
243
|
throw std::runtime_error(e.what());
|
|
263
244
|
}
|
|
264
245
|
});
|
|
@@ -269,72 +250,65 @@ public:
|
|
|
269
250
|
try {
|
|
270
251
|
bark_cxx::NewAddressResult address_rs = bark_cxx::new_address();
|
|
271
252
|
NewAddressResult address;
|
|
272
|
-
address.user_pubkey = std::string(address_rs.user_pubkey.data(),
|
|
273
|
-
|
|
274
|
-
address.
|
|
275
|
-
std::string(address_rs.ark_id.data(), address_rs.ark_id.length());
|
|
276
|
-
address.address =
|
|
277
|
-
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());
|
|
278
256
|
return address;
|
|
279
257
|
|
|
280
|
-
} catch (const rust::Error
|
|
258
|
+
} catch (const rust::Error& e) {
|
|
281
259
|
throw std::runtime_error(e.what());
|
|
282
260
|
}
|
|
283
261
|
});
|
|
284
262
|
}
|
|
285
263
|
|
|
286
|
-
std::shared_ptr<Promise<std::string>> signMessage(const std::string
|
|
287
|
-
double index) override {
|
|
264
|
+
std::shared_ptr<Promise<std::string>> signMessage(const std::string& message, double index) override {
|
|
288
265
|
return Promise<std::string>::async([message, index]() {
|
|
289
266
|
try {
|
|
290
267
|
uint32_t index_val = static_cast<uint32_t>(index);
|
|
291
268
|
rust::String signature_rs = bark_cxx::sign_message(message, index_val);
|
|
292
269
|
return std::string(signature_rs.data(), signature_rs.length());
|
|
293
|
-
} catch (const rust::Error
|
|
270
|
+
} catch (const rust::Error& e) {
|
|
294
271
|
throw std::runtime_error(e.what());
|
|
295
272
|
}
|
|
296
273
|
});
|
|
297
274
|
}
|
|
298
|
-
|
|
299
|
-
std::shared_ptr<Promise<std::string>>
|
|
300
|
-
|
|
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 {
|
|
301
279
|
return Promise<std::string>::async([message, mnemonic, network, index]() {
|
|
302
280
|
try {
|
|
303
281
|
uint32_t index_val = static_cast<uint32_t>(index);
|
|
304
282
|
rust::String signature_rs = bark_cxx::sign_messsage_with_mnemonic(message, mnemonic, network, index_val);
|
|
305
283
|
return std::string(signature_rs.data(), signature_rs.length());
|
|
306
|
-
} catch (const rust::Error
|
|
284
|
+
} catch (const rust::Error& e) {
|
|
307
285
|
throw std::runtime_error(e.what());
|
|
308
286
|
}
|
|
309
287
|
});
|
|
310
288
|
}
|
|
311
289
|
|
|
312
|
-
std::shared_ptr<Promise<KeyPairResult>>
|
|
313
|
-
|
|
314
|
-
double index) override {
|
|
290
|
+
std::shared_ptr<Promise<KeyPairResult>> deriveKeypairFromMnemonic(const std::string& mnemonic,
|
|
291
|
+
const std::string& network, double index) override {
|
|
315
292
|
return Promise<KeyPairResult>::async([mnemonic, network, index]() {
|
|
316
293
|
try {
|
|
317
294
|
uint32_t index_val = static_cast<uint32_t>(index);
|
|
318
295
|
bark_cxx::KeyPairResult keypair_rs = bark_cxx::derive_keypair_from_mnemonic(mnemonic, network, index_val);
|
|
319
296
|
KeyPairResult keypair;
|
|
320
|
-
keypair.public_key = std::string(keypair_rs.public_key.data(),
|
|
321
|
-
|
|
322
|
-
keypair.secret_key = std::string(keypair_rs.secret_key.data(),
|
|
323
|
-
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());
|
|
324
299
|
return keypair;
|
|
325
|
-
} catch (const rust::Error
|
|
300
|
+
} catch (const rust::Error& e) {
|
|
326
301
|
throw std::runtime_error(e.what());
|
|
327
302
|
}
|
|
328
303
|
});
|
|
329
304
|
}
|
|
330
305
|
|
|
331
|
-
std::shared_ptr<Promise<bool>>
|
|
332
|
-
|
|
333
|
-
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 {
|
|
334
308
|
return Promise<bool>::async([message, signature, publicKey]() {
|
|
335
309
|
try {
|
|
336
310
|
return bark_cxx::verify_message(message, signature, publicKey);
|
|
337
|
-
} catch (const rust::Error
|
|
311
|
+
} catch (const rust::Error& e) {
|
|
338
312
|
throw std::runtime_error(e.what());
|
|
339
313
|
}
|
|
340
314
|
});
|
|
@@ -345,48 +319,40 @@ public:
|
|
|
345
319
|
try {
|
|
346
320
|
rust::Vec<bark_cxx::BarkVtxo> rust_vtxos = bark_cxx::get_vtxos();
|
|
347
321
|
std::vector<BarkVtxo> vtxos;
|
|
348
|
-
for (const auto
|
|
322
|
+
for (const auto& rust_vtxo : rust_vtxos) {
|
|
349
323
|
BarkVtxo vtxo;
|
|
350
324
|
vtxo.amount = static_cast<double>(rust_vtxo.amount);
|
|
351
325
|
vtxo.expiry_height = static_cast<double>(rust_vtxo.expiry_height);
|
|
352
|
-
vtxo.
|
|
353
|
-
rust_vtxo.asp_pubkey.length());
|
|
326
|
+
vtxo.server_pubkey = std::string(rust_vtxo.server_pubkey.data(), rust_vtxo.server_pubkey.length());
|
|
354
327
|
vtxo.exit_delta = static_cast<double>(rust_vtxo.exit_delta);
|
|
355
|
-
vtxo.anchor_point = std::string(rust_vtxo.anchor_point.data(),
|
|
356
|
-
|
|
357
|
-
vtxo.point =
|
|
358
|
-
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());
|
|
359
330
|
vtxos.push_back(vtxo);
|
|
360
331
|
}
|
|
361
332
|
return vtxos;
|
|
362
|
-
} catch (const rust::Error
|
|
333
|
+
} catch (const rust::Error& e) {
|
|
363
334
|
throw std::runtime_error(e.what());
|
|
364
335
|
}
|
|
365
336
|
});
|
|
366
337
|
}
|
|
367
338
|
|
|
368
|
-
std::shared_ptr<Promise<std::vector<BarkVtxo>>>
|
|
369
|
-
getExpiringVtxos(double threshold) override {
|
|
339
|
+
std::shared_ptr<Promise<std::vector<BarkVtxo>>> getExpiringVtxos(double threshold) override {
|
|
370
340
|
return Promise<std::vector<BarkVtxo>>::async([threshold]() {
|
|
371
341
|
try {
|
|
372
|
-
rust::Vec<bark_cxx::BarkVtxo> rust_vtxos =
|
|
373
|
-
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));
|
|
374
343
|
std::vector<BarkVtxo> vtxos;
|
|
375
|
-
for (const auto
|
|
344
|
+
for (const auto& rust_vtxo : rust_vtxos) {
|
|
376
345
|
BarkVtxo vtxo;
|
|
377
346
|
vtxo.amount = static_cast<double>(rust_vtxo.amount);
|
|
378
347
|
vtxo.expiry_height = static_cast<double>(rust_vtxo.expiry_height);
|
|
379
|
-
vtxo.
|
|
380
|
-
rust_vtxo.asp_pubkey.length());
|
|
348
|
+
vtxo.server_pubkey = std::string(rust_vtxo.server_pubkey.data(), rust_vtxo.server_pubkey.length());
|
|
381
349
|
vtxo.exit_delta = static_cast<double>(rust_vtxo.exit_delta);
|
|
382
|
-
vtxo.anchor_point = std::string(rust_vtxo.anchor_point.data(),
|
|
383
|
-
|
|
384
|
-
vtxo.point =
|
|
385
|
-
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());
|
|
386
352
|
vtxos.push_back(vtxo);
|
|
387
353
|
}
|
|
388
354
|
return vtxos;
|
|
389
|
-
} catch (const rust::Error
|
|
355
|
+
} catch (const rust::Error& e) {
|
|
390
356
|
throw std::runtime_error(e.what());
|
|
391
357
|
}
|
|
392
358
|
});
|
|
@@ -400,13 +366,11 @@ public:
|
|
|
400
366
|
bark_cxx::OnChainBalance rust_balance = bark_cxx::onchain_balance();
|
|
401
367
|
OnchainBalanceResult balance;
|
|
402
368
|
balance.immature = static_cast<double>(rust_balance.immature);
|
|
403
|
-
balance.trusted_pending =
|
|
404
|
-
|
|
405
|
-
balance.untrusted_pending =
|
|
406
|
-
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);
|
|
407
371
|
balance.confirmed = static_cast<double>(rust_balance.confirmed);
|
|
408
372
|
return balance;
|
|
409
|
-
} catch (const rust::Error
|
|
373
|
+
} catch (const rust::Error& e) {
|
|
410
374
|
throw std::runtime_error(e.what());
|
|
411
375
|
}
|
|
412
376
|
});
|
|
@@ -416,7 +380,7 @@ public:
|
|
|
416
380
|
return Promise<void>::async([]() {
|
|
417
381
|
try {
|
|
418
382
|
bark_cxx::onchain_sync();
|
|
419
|
-
} catch (const rust::Error
|
|
383
|
+
} catch (const rust::Error& e) {
|
|
420
384
|
throw std::runtime_error(e.what());
|
|
421
385
|
}
|
|
422
386
|
});
|
|
@@ -427,7 +391,7 @@ public:
|
|
|
427
391
|
try {
|
|
428
392
|
rust::String json_rs = bark_cxx::onchain_list_unspent();
|
|
429
393
|
return std::string(json_rs.data(), json_rs.length());
|
|
430
|
-
} catch (const rust::Error
|
|
394
|
+
} catch (const rust::Error& e) {
|
|
431
395
|
throw std::runtime_error(e.what());
|
|
432
396
|
}
|
|
433
397
|
});
|
|
@@ -438,7 +402,7 @@ public:
|
|
|
438
402
|
try {
|
|
439
403
|
rust::String json_rs = bark_cxx::onchain_utxos();
|
|
440
404
|
return std::string(json_rs.data(), json_rs.length());
|
|
441
|
-
} catch (const rust::Error
|
|
405
|
+
} catch (const rust::Error& e) {
|
|
442
406
|
throw std::runtime_error(e.what());
|
|
443
407
|
}
|
|
444
408
|
});
|
|
@@ -449,48 +413,41 @@ public:
|
|
|
449
413
|
try {
|
|
450
414
|
rust::String address_rs = bark_cxx::onchain_address();
|
|
451
415
|
return std::string(address_rs.data(), address_rs.length());
|
|
452
|
-
} catch (const rust::Error
|
|
453
|
-
throw std::runtime_error(e.what());
|
|
454
|
-
}
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
std::shared_ptr<Promise<OnchainPaymentResult>>
|
|
459
|
-
|
|
460
|
-
|
|
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
|
-
std::shared_ptr<Promise<std::string>>
|
|
492
|
-
onchainDrain(const std::string &destination,
|
|
493
|
-
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 {
|
|
494
451
|
return Promise<std::string>::async([destination, feeRate]() {
|
|
495
452
|
try {
|
|
496
453
|
uint64_t feeRate_val;
|
|
@@ -502,34 +459,30 @@ public:
|
|
|
502
459
|
txid_rs = bark_cxx::onchain_drain(destination, nullptr);
|
|
503
460
|
}
|
|
504
461
|
return std::string(txid_rs.data(), txid_rs.length());
|
|
505
|
-
} catch (const rust::Error
|
|
462
|
+
} catch (const rust::Error& e) {
|
|
506
463
|
throw std::runtime_error(e.what());
|
|
507
464
|
}
|
|
508
465
|
});
|
|
509
466
|
}
|
|
510
467
|
|
|
511
|
-
std::shared_ptr<Promise<std::string>>
|
|
512
|
-
|
|
513
|
-
std::optional<double> feeRate) override {
|
|
468
|
+
std::shared_ptr<Promise<std::string>> onchainSendMany(const std::vector<BarkSendManyOutput>& outputs,
|
|
469
|
+
std::optional<double> feeRate) override {
|
|
514
470
|
return Promise<std::string>::async([outputs, feeRate]() {
|
|
515
471
|
try {
|
|
516
472
|
rust::Vec<bark_cxx::SendManyOutput> cxx_outputs;
|
|
517
|
-
for (const auto
|
|
518
|
-
cxx_outputs.push_back({rust::String(output.destination),
|
|
519
|
-
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)});
|
|
520
475
|
}
|
|
521
476
|
uint64_t feeRate_val;
|
|
522
477
|
rust::String txid_rs;
|
|
523
478
|
if (feeRate.has_value()) {
|
|
524
479
|
feeRate_val = static_cast<uint64_t>(feeRate.value());
|
|
525
|
-
txid_rs =
|
|
526
|
-
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);
|
|
527
481
|
} else {
|
|
528
|
-
txid_rs =
|
|
529
|
-
bark_cxx::onchain_send_many(std::move(cxx_outputs), nullptr);
|
|
482
|
+
txid_rs = bark_cxx::onchain_send_many(std::move(cxx_outputs), nullptr);
|
|
530
483
|
}
|
|
531
484
|
return std::string(txid_rs.data(), txid_rs.length());
|
|
532
|
-
} catch (const rust::Error
|
|
485
|
+
} catch (const rust::Error& e) {
|
|
533
486
|
throw std::runtime_error(e.what());
|
|
534
487
|
}
|
|
535
488
|
});
|
|
@@ -537,79 +490,96 @@ public:
|
|
|
537
490
|
|
|
538
491
|
// --- Lightning Operations ---
|
|
539
492
|
|
|
540
|
-
std::shared_ptr<Promise<LightningPaymentResult>>
|
|
541
|
-
|
|
542
|
-
std::optional<double> amountSat) override {
|
|
493
|
+
std::shared_ptr<Promise<LightningPaymentResult>> sendLightningPayment(const std::string& destination,
|
|
494
|
+
std::optional<double> amountSat) override {
|
|
543
495
|
return Promise<LightningPaymentResult>::async([destination, amountSat]() {
|
|
544
496
|
try {
|
|
545
497
|
bark_cxx::Bolt11PaymentResult rust_result;
|
|
546
498
|
if (amountSat.has_value()) {
|
|
547
499
|
uint64_t amountSat_val = static_cast<uint64_t>(amountSat.value());
|
|
548
|
-
rust_result =
|
|
549
|
-
bark_cxx::send_lightning_payment(destination, &amountSat_val);
|
|
500
|
+
rust_result = bark_cxx::send_lightning_payment(destination, &amountSat_val);
|
|
550
501
|
} else {
|
|
551
502
|
rust_result = bark_cxx::send_lightning_payment(destination, nullptr);
|
|
552
503
|
}
|
|
553
504
|
|
|
554
505
|
LightningPaymentResult result;
|
|
555
|
-
result.bolt11_invoice =
|
|
556
|
-
|
|
557
|
-
rust_result.bolt11_invoice.length());
|
|
558
|
-
result.preimage = std::string(rust_result.preimage.data(),
|
|
559
|
-
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());
|
|
560
508
|
result.payment_type = convertPaymentType(rust_result.payment_type);
|
|
561
509
|
|
|
562
510
|
return result;
|
|
563
|
-
} catch (const rust::Error
|
|
511
|
+
} catch (const rust::Error& e) {
|
|
564
512
|
throw std::runtime_error(e.what());
|
|
565
513
|
}
|
|
566
514
|
});
|
|
567
515
|
}
|
|
568
516
|
|
|
569
|
-
std::shared_ptr<Promise<LnurlPaymentResult>>
|
|
570
|
-
|
|
571
|
-
const std::string &comment) override {
|
|
517
|
+
std::shared_ptr<Promise<LnurlPaymentResult>> sendLnaddr(const std::string& addr, double amountSat,
|
|
518
|
+
const std::string& comment) override {
|
|
572
519
|
return Promise<LnurlPaymentResult>::async([addr, amountSat, comment]() {
|
|
573
520
|
try {
|
|
574
|
-
bark_cxx::LnurlPaymentResult rust_result =
|
|
575
|
-
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);
|
|
576
523
|
|
|
577
524
|
LnurlPaymentResult result;
|
|
578
|
-
result.lnurl =
|
|
579
|
-
|
|
580
|
-
result.
|
|
581
|
-
std::string(rust_result.bolt11_invoice.data(),
|
|
582
|
-
rust_result.bolt11_invoice.length());
|
|
583
|
-
result.preimage = std::string(rust_result.preimage.data(),
|
|
584
|
-
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());
|
|
585
528
|
result.payment_type = convertPaymentType(rust_result.payment_type);
|
|
586
529
|
|
|
587
530
|
return result;
|
|
588
|
-
} catch (const rust::Error
|
|
531
|
+
} catch (const rust::Error& e) {
|
|
589
532
|
throw std::runtime_error(e.what());
|
|
590
533
|
}
|
|
591
534
|
});
|
|
592
535
|
}
|
|
593
536
|
|
|
594
|
-
std::shared_ptr<Promise<std::string>>
|
|
595
|
-
bolt11Invoice(double amountMsat) override {
|
|
537
|
+
std::shared_ptr<Promise<std::string>> bolt11Invoice(double amountMsat) override {
|
|
596
538
|
return Promise<std::string>::async([amountMsat]() {
|
|
597
539
|
try {
|
|
598
|
-
rust::String invoice_rs =
|
|
599
|
-
bark_cxx::bolt11_invoice(static_cast<uint64_t>(amountMsat));
|
|
540
|
+
rust::String invoice_rs = bark_cxx::bolt11_invoice(static_cast<uint64_t>(amountMsat));
|
|
600
541
|
return std::string(invoice_rs.data(), invoice_rs.length());
|
|
601
|
-
} catch (const rust::Error
|
|
542
|
+
} catch (const rust::Error& e) {
|
|
602
543
|
throw std::runtime_error(e.what());
|
|
603
544
|
}
|
|
604
545
|
});
|
|
605
546
|
}
|
|
606
547
|
|
|
607
|
-
std::shared_ptr<Promise<void>>
|
|
608
|
-
finishLightningReceive(const std::string &bolt11) override {
|
|
548
|
+
std::shared_ptr<Promise<void>> finishLightningReceive(const std::string& bolt11) override {
|
|
609
549
|
return Promise<void>::async([bolt11]() {
|
|
610
550
|
try {
|
|
611
551
|
bark_cxx::finish_lightning_receive(bolt11);
|
|
612
|
-
} catch (const rust::Error
|
|
552
|
+
} catch (const rust::Error& e) {
|
|
553
|
+
throw std::runtime_error(e.what());
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
std::shared_ptr<Promise<std::optional<LightningReceive>>>
|
|
559
|
+
lightningReceiveStatus(const std::string& payment) override {
|
|
560
|
+
return Promise<std::optional<LightningReceive>>::async([payment]() {
|
|
561
|
+
try {
|
|
562
|
+
const bark_cxx::LightningReceive* status_ptr = bark_cxx::lightning_receive_status(payment);
|
|
563
|
+
|
|
564
|
+
if (status_ptr == nullptr) {
|
|
565
|
+
return std::optional<LightningReceive>();
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
std::unique_ptr<const bark_cxx::LightningReceive> status(status_ptr);
|
|
569
|
+
|
|
570
|
+
LightningReceive result;
|
|
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());
|
|
574
|
+
|
|
575
|
+
if (status->preimage_revealed_at != nullptr) {
|
|
576
|
+
result.preimage_revealed_at = static_cast<double>(*status->preimage_revealed_at);
|
|
577
|
+
} else {
|
|
578
|
+
result.preimage_revealed_at = std::nullopt;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
return std::optional<LightningReceive>(result);
|
|
582
|
+
} catch (const rust::Error& e) {
|
|
613
583
|
throw std::runtime_error(e.what());
|
|
614
584
|
}
|
|
615
585
|
});
|
|
@@ -620,10 +590,9 @@ public:
|
|
|
620
590
|
std::shared_ptr<Promise<std::string>> boardAmount(double amountSat) override {
|
|
621
591
|
return Promise<std::string>::async([amountSat]() {
|
|
622
592
|
try {
|
|
623
|
-
rust::String status_rs =
|
|
624
|
-
bark_cxx::board_amount(static_cast<uint64_t>(amountSat));
|
|
593
|
+
rust::String status_rs = bark_cxx::board_amount(static_cast<uint64_t>(amountSat));
|
|
625
594
|
return std::string(status_rs.data(), status_rs.length());
|
|
626
|
-
} catch (const rust::Error
|
|
595
|
+
} catch (const rust::Error& e) {
|
|
627
596
|
throw std::runtime_error(e.what());
|
|
628
597
|
}
|
|
629
598
|
});
|
|
@@ -634,59 +603,62 @@ public:
|
|
|
634
603
|
try {
|
|
635
604
|
rust::String status_rs = bark_cxx::board_all();
|
|
636
605
|
return std::string(status_rs.data(), status_rs.length());
|
|
637
|
-
} catch (const rust::Error
|
|
606
|
+
} catch (const rust::Error& e) {
|
|
607
|
+
throw std::runtime_error(e.what());
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
std::shared_ptr<Promise<void>> validateArkoorAddress(const std::string& address) override {
|
|
613
|
+
return Promise<void>::async([address]() {
|
|
614
|
+
try {
|
|
615
|
+
bark_cxx::validate_arkoor_address(address);
|
|
616
|
+
} catch (const rust::Error& e) {
|
|
638
617
|
throw std::runtime_error(e.what());
|
|
639
618
|
}
|
|
640
619
|
});
|
|
641
620
|
}
|
|
642
621
|
|
|
643
|
-
std::shared_ptr<Promise<ArkoorPaymentResult>>
|
|
644
|
-
|
|
622
|
+
std::shared_ptr<Promise<ArkoorPaymentResult>> sendArkoorPayment(const std::string& destination,
|
|
623
|
+
double amountSat) override {
|
|
645
624
|
return Promise<ArkoorPaymentResult>::async([destination, amountSat]() {
|
|
646
625
|
try {
|
|
647
626
|
bark_cxx::ArkoorPaymentResult rust_result =
|
|
648
|
-
bark_cxx::send_arkoor_payment(destination,
|
|
649
|
-
static_cast<uint64_t>(amountSat));
|
|
627
|
+
bark_cxx::send_arkoor_payment(destination, static_cast<uint64_t>(amountSat));
|
|
650
628
|
|
|
651
629
|
ArkoorPaymentResult result;
|
|
652
630
|
result.amount_sat = static_cast<double>(rust_result.amount_sat);
|
|
653
631
|
result.destination_pubkey =
|
|
654
|
-
std::string(rust_result.destination_pubkey.data(),
|
|
655
|
-
rust_result.destination_pubkey.length());
|
|
632
|
+
std::string(rust_result.destination_pubkey.data(), rust_result.destination_pubkey.length());
|
|
656
633
|
result.payment_type = convertPaymentType(rust_result.payment_type);
|
|
657
634
|
|
|
658
635
|
std::vector<BarkVtxo> vtxos;
|
|
659
|
-
for (const auto
|
|
636
|
+
for (const auto& rust_vtxo : rust_result.vtxos) {
|
|
660
637
|
BarkVtxo vtxo;
|
|
661
638
|
vtxo.amount = static_cast<double>(rust_vtxo.amount);
|
|
662
639
|
vtxo.expiry_height = static_cast<double>(rust_vtxo.expiry_height);
|
|
663
|
-
vtxo.
|
|
664
|
-
rust_vtxo.asp_pubkey.length());
|
|
640
|
+
vtxo.server_pubkey = std::string(rust_vtxo.server_pubkey.data(), rust_vtxo.server_pubkey.length());
|
|
665
641
|
vtxo.exit_delta = static_cast<double>(rust_vtxo.exit_delta);
|
|
666
|
-
vtxo.anchor_point = std::string(rust_vtxo.anchor_point.data(),
|
|
667
|
-
|
|
668
|
-
vtxo.point =
|
|
669
|
-
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());
|
|
670
644
|
vtxos.push_back(vtxo);
|
|
671
645
|
}
|
|
672
646
|
result.vtxos = vtxos;
|
|
673
647
|
|
|
674
648
|
return result;
|
|
675
|
-
} catch (const rust::Error
|
|
649
|
+
} catch (const rust::Error& e) {
|
|
676
650
|
throw std::runtime_error(e.what());
|
|
677
651
|
}
|
|
678
652
|
});
|
|
679
653
|
}
|
|
680
654
|
|
|
681
|
-
std::shared_ptr<Promise<std::string>>
|
|
682
|
-
|
|
683
|
-
double amountSat) override {
|
|
655
|
+
std::shared_ptr<Promise<std::string>> sendRoundOnchainPayment(const std::string& destination,
|
|
656
|
+
double amountSat) override {
|
|
684
657
|
return Promise<std::string>::async([destination, amountSat]() {
|
|
685
658
|
try {
|
|
686
|
-
rust::String status_rs = bark_cxx::send_round_onchain_payment(
|
|
687
|
-
destination, static_cast<uint64_t>(amountSat));
|
|
659
|
+
rust::String status_rs = bark_cxx::send_round_onchain_payment(destination, static_cast<uint64_t>(amountSat));
|
|
688
660
|
return std::string(status_rs.data(), status_rs.length());
|
|
689
|
-
} catch (const rust::Error
|
|
661
|
+
} catch (const rust::Error& e) {
|
|
690
662
|
throw std::runtime_error(e.what());
|
|
691
663
|
}
|
|
692
664
|
});
|
|
@@ -694,31 +666,28 @@ public:
|
|
|
694
666
|
|
|
695
667
|
// --- Offboarding / Exiting ---
|
|
696
668
|
|
|
697
|
-
std::shared_ptr<Promise<std::string>>
|
|
698
|
-
|
|
699
|
-
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 {
|
|
700
671
|
return Promise<std::string>::async([vtxoIds, destinationAddress]() {
|
|
701
672
|
try {
|
|
702
673
|
rust::Vec<rust::String> rust_vtxo_ids;
|
|
703
|
-
for (const auto
|
|
674
|
+
for (const auto& id : vtxoIds) {
|
|
704
675
|
rust_vtxo_ids.push_back(rust::String(id));
|
|
705
676
|
}
|
|
706
|
-
rust::String status_rs = bark_cxx::offboard_specific(
|
|
707
|
-
std::move(rust_vtxo_ids), destinationAddress);
|
|
677
|
+
rust::String status_rs = bark_cxx::offboard_specific(std::move(rust_vtxo_ids), destinationAddress);
|
|
708
678
|
return std::string(status_rs.data(), status_rs.length());
|
|
709
|
-
} catch (const rust::Error
|
|
679
|
+
} catch (const rust::Error& e) {
|
|
710
680
|
throw std::runtime_error(e.what());
|
|
711
681
|
}
|
|
712
682
|
});
|
|
713
683
|
}
|
|
714
684
|
|
|
715
|
-
std::shared_ptr<Promise<std::string>>
|
|
716
|
-
offboardAll(const std::string &destinationAddress) override {
|
|
685
|
+
std::shared_ptr<Promise<std::string>> offboardAll(const std::string& destinationAddress) override {
|
|
717
686
|
return Promise<std::string>::async([destinationAddress]() {
|
|
718
687
|
try {
|
|
719
688
|
rust::String status_rs = bark_cxx::offboard_all(destinationAddress);
|
|
720
689
|
return std::string(status_rs.data(), status_rs.length());
|
|
721
|
-
} catch (const rust::Error
|
|
690
|
+
} catch (const rust::Error& e) {
|
|
722
691
|
throw std::runtime_error(e.what());
|
|
723
692
|
}
|
|
724
693
|
});
|