react-native-nitro-ark 0.0.132 → 0.0.134
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/cpp/NitroArkJni.cpp +22 -22
- package/android/src/main/java/com/margelo/nitro/nitroark/NitroArkNative.kt +12 -8
- package/android/src/main/jniLibs/arm64-v8a/libcxxbridge1.a +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libcxxbridge1.a +0 -0
- package/android/src/main/jniLibs/x86_64/libcxxbridge1.a +0 -0
- package/cpp/NitroArk.hpp +106 -85
- package/cpp/generated/ark_cxx.h +18 -10
- package/lib/module/index.js +102 -39
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NitroArk.nitro.d.ts +26 -8
- package/lib/typescript/src/NitroArk.nitro.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +90 -35
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/nitrogen/generated/shared/c++/BarkConfigOpts.hpp +1 -5
- package/nitrogen/generated/shared/c++/HybridNitroArkSpec.cpp +3 -2
- package/nitrogen/generated/shared/c++/HybridNitroArkSpec.hpp +9 -5
- package/nitrogen/generated/shared/c++/LightningPaymentOrigin.hpp +89 -0
- package/nitrogen/generated/shared/c++/LightningPaymentOriginMethod.hpp +80 -0
- package/nitrogen/generated/shared/c++/LightningReceive.hpp +26 -9
- package/package.json +3 -2
- package/src/NitroArk.nitro.ts +36 -11
- package/src/index.tsx +185 -51
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
|
|
33
33
|
#include <string>
|
|
34
34
|
#include <optional>
|
|
35
|
+
#include <vector>
|
|
35
36
|
|
|
36
37
|
namespace margelo::nitro::nitroark {
|
|
37
38
|
|
|
@@ -40,15 +41,19 @@ namespace margelo::nitro::nitroark {
|
|
|
40
41
|
*/
|
|
41
42
|
struct LightningReceive final {
|
|
42
43
|
public:
|
|
44
|
+
std::string state SWIFT_PRIVATE;
|
|
45
|
+
std::optional<std::string> phase SWIFT_PRIVATE;
|
|
43
46
|
std::string payment_hash SWIFT_PRIVATE;
|
|
44
47
|
std::string payment_preimage SWIFT_PRIVATE;
|
|
45
48
|
std::string invoice SWIFT_PRIVATE;
|
|
46
|
-
std::
|
|
47
|
-
std::optional<double>
|
|
49
|
+
std::vector<std::string> htlc_vtxo_ids SWIFT_PRIVATE;
|
|
50
|
+
std::optional<double> movement_id SWIFT_PRIVATE;
|
|
51
|
+
std::optional<double> amount_sat SWIFT_PRIVATE;
|
|
52
|
+
std::optional<double> settled_at SWIFT_PRIVATE;
|
|
48
53
|
|
|
49
54
|
public:
|
|
50
55
|
LightningReceive() = default;
|
|
51
|
-
explicit LightningReceive(std::string payment_hash, std::string payment_preimage, std::string invoice, std::optional<double>
|
|
56
|
+
explicit LightningReceive(std::string state, std::optional<std::string> phase, std::string payment_hash, std::string payment_preimage, std::string invoice, std::vector<std::string> htlc_vtxo_ids, std::optional<double> movement_id, std::optional<double> amount_sat, std::optional<double> settled_at): state(state), phase(phase), payment_hash(payment_hash), payment_preimage(payment_preimage), invoice(invoice), htlc_vtxo_ids(htlc_vtxo_ids), movement_id(movement_id), amount_sat(amount_sat), settled_at(settled_at) {}
|
|
52
57
|
|
|
53
58
|
public:
|
|
54
59
|
friend bool operator==(const LightningReceive& lhs, const LightningReceive& rhs) = default;
|
|
@@ -64,20 +69,28 @@ namespace margelo::nitro {
|
|
|
64
69
|
static inline margelo::nitro::nitroark::LightningReceive fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
65
70
|
jsi::Object obj = arg.asObject(runtime);
|
|
66
71
|
return margelo::nitro::nitroark::LightningReceive(
|
|
72
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "state"))),
|
|
73
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "phase"))),
|
|
67
74
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "payment_hash"))),
|
|
68
75
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "payment_preimage"))),
|
|
69
76
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "invoice"))),
|
|
70
|
-
JSIConverter<std::
|
|
71
|
-
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "
|
|
77
|
+
JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "htlc_vtxo_ids"))),
|
|
78
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "movement_id"))),
|
|
79
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "amount_sat"))),
|
|
80
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "settled_at")))
|
|
72
81
|
);
|
|
73
82
|
}
|
|
74
83
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroark::LightningReceive& arg) {
|
|
75
84
|
jsi::Object obj(runtime);
|
|
85
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "state"), JSIConverter<std::string>::toJSI(runtime, arg.state));
|
|
86
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "phase"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.phase));
|
|
76
87
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "payment_hash"), JSIConverter<std::string>::toJSI(runtime, arg.payment_hash));
|
|
77
88
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "payment_preimage"), JSIConverter<std::string>::toJSI(runtime, arg.payment_preimage));
|
|
78
89
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "invoice"), JSIConverter<std::string>::toJSI(runtime, arg.invoice));
|
|
79
|
-
obj.setProperty(runtime, PropNameIDCache::get(runtime, "
|
|
80
|
-
obj.setProperty(runtime, PropNameIDCache::get(runtime, "
|
|
90
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "htlc_vtxo_ids"), JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.htlc_vtxo_ids));
|
|
91
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "movement_id"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.movement_id));
|
|
92
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "amount_sat"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.amount_sat));
|
|
93
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "settled_at"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.settled_at));
|
|
81
94
|
return obj;
|
|
82
95
|
}
|
|
83
96
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -88,11 +101,15 @@ namespace margelo::nitro {
|
|
|
88
101
|
if (!nitro::isPlainObject(runtime, obj)) {
|
|
89
102
|
return false;
|
|
90
103
|
}
|
|
104
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "state")))) return false;
|
|
105
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "phase")))) return false;
|
|
91
106
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "payment_hash")))) return false;
|
|
92
107
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "payment_preimage")))) return false;
|
|
93
108
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "invoice")))) return false;
|
|
94
|
-
if (!JSIConverter<std::
|
|
95
|
-
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "
|
|
109
|
+
if (!JSIConverter<std::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "htlc_vtxo_ids")))) return false;
|
|
110
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "movement_id")))) return false;
|
|
111
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "amount_sat")))) return false;
|
|
112
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "settled_at")))) return false;
|
|
96
113
|
return true;
|
|
97
114
|
}
|
|
98
115
|
};
|
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.134",
|
|
4
4
|
"description": "Pure C++ Nitro Modules for Ark client",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/module/index.js",
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"@eslint/js": "^9.22.0",
|
|
76
76
|
"@evilmartians/lefthook": "^1.5.0",
|
|
77
77
|
"@react-native/eslint-config": "^0.81.4",
|
|
78
|
+
"@react-native/jest-preset": "0.86.0",
|
|
78
79
|
"@release-it/conventional-changelog": "^9.0.2",
|
|
79
80
|
"@types/jest": "^29.5.5",
|
|
80
81
|
"@types/react": "^19.2.0",
|
|
@@ -104,7 +105,7 @@
|
|
|
104
105
|
],
|
|
105
106
|
"packageManager": "yarn@3.6.1",
|
|
106
107
|
"jest": {
|
|
107
|
-
"preset": "react-native",
|
|
108
|
+
"preset": "@react-native/jest-preset",
|
|
108
109
|
"modulePathIgnorePatterns": [
|
|
109
110
|
"<rootDir>/example/node_modules",
|
|
110
111
|
"<rootDir>/lib/"
|
package/src/NitroArk.nitro.ts
CHANGED
|
@@ -6,7 +6,6 @@ import type { HybridObject } from 'react-native-nitro-modules';
|
|
|
6
6
|
|
|
7
7
|
export interface BarkConfigOpts {
|
|
8
8
|
ark: string;
|
|
9
|
-
server_access_token?: string;
|
|
10
9
|
/** Client identifier sent as `x-user-agent`, formatted as `<name>/<version>`. */
|
|
11
10
|
user_agent?: string;
|
|
12
11
|
esplora?: string;
|
|
@@ -185,6 +184,21 @@ export interface LightningPaymentResult {
|
|
|
185
184
|
preimage?: string;
|
|
186
185
|
}
|
|
187
186
|
|
|
187
|
+
export type LightningPaymentOriginMethod =
|
|
188
|
+
| 'lightning-address'
|
|
189
|
+
| 'lnurl'
|
|
190
|
+
| 'custom';
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* The original user-facing destination that was resolved to a Lightning
|
|
194
|
+
* invoice outside Bark. Only origin kinds that Bark can persist through this
|
|
195
|
+
* API are accepted; Rust validates the value again at the native boundary.
|
|
196
|
+
*/
|
|
197
|
+
export interface LightningPaymentOrigin {
|
|
198
|
+
method: LightningPaymentOriginMethod;
|
|
199
|
+
value: string;
|
|
200
|
+
}
|
|
201
|
+
|
|
188
202
|
export interface OnchainPaymentResult {
|
|
189
203
|
txid: string; // Transaction ID
|
|
190
204
|
amount_sat: number; // Amount in satoshis
|
|
@@ -229,11 +243,15 @@ export interface MailboxAuthorizationResult {
|
|
|
229
243
|
}
|
|
230
244
|
|
|
231
245
|
export interface LightningReceive {
|
|
246
|
+
state: string;
|
|
247
|
+
phase?: string;
|
|
232
248
|
payment_hash: string;
|
|
233
249
|
payment_preimage: string;
|
|
234
250
|
invoice: string;
|
|
235
|
-
|
|
236
|
-
|
|
251
|
+
htlc_vtxo_ids: string[];
|
|
252
|
+
movement_id?: number;
|
|
253
|
+
amount_sat?: number;
|
|
254
|
+
settled_at?: number;
|
|
237
255
|
}
|
|
238
256
|
|
|
239
257
|
export interface BarkMovementSubsystem {
|
|
@@ -339,9 +357,7 @@ export interface NitroArk extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
|
339
357
|
refreshServer(): Promise<void>;
|
|
340
358
|
syncPendingBoards(): Promise<void>;
|
|
341
359
|
maintenance(): Promise<void>;
|
|
342
|
-
maintenanceWithOnchain(): Promise<void>;
|
|
343
360
|
maintenanceDelegated(): Promise<void>;
|
|
344
|
-
maintenanceWithOnchainDelegated(): Promise<void>;
|
|
345
361
|
maintenanceRefresh(): Promise<void>;
|
|
346
362
|
sync(): Promise<void>;
|
|
347
363
|
|
|
@@ -410,9 +426,11 @@ export interface NitroArk extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
|
410
426
|
): BarkNotificationSubscription;
|
|
411
427
|
history(): Promise<BarkMovement[]>;
|
|
412
428
|
vtxos(): Promise<BarkVtxo[]>;
|
|
429
|
+
updateHistoryMetadata(movementId: number, patchJson: string): Promise<void>;
|
|
413
430
|
decodeVtxoHex(vtxoHex: string): Promise<BarkVtxo>;
|
|
414
431
|
importVtxo(vtxoHex: string): Promise<BarkVtxo>;
|
|
415
432
|
dangerousDropVtxo(vtxoId: string): Promise<void>;
|
|
433
|
+
unlockVtxos(vtxoIds: string[]): Promise<void>;
|
|
416
434
|
refreshVtxosDelegated(
|
|
417
435
|
vtxoIds: string[]
|
|
418
436
|
): Promise<DelegatedRoundState | undefined>;
|
|
@@ -462,6 +480,15 @@ export interface NitroArk extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
|
462
480
|
wait: boolean,
|
|
463
481
|
amountSat?: number
|
|
464
482
|
): Promise<LightningPaymentResult>;
|
|
483
|
+
/**
|
|
484
|
+
* Pays an invoice already resolved by the caller while preserving the
|
|
485
|
+
* original user-facing destination in Bark's movement history.
|
|
486
|
+
*/
|
|
487
|
+
payLightningInvoiceWithOrigin(
|
|
488
|
+
invoice: string,
|
|
489
|
+
origin: LightningPaymentOrigin,
|
|
490
|
+
wait: boolean
|
|
491
|
+
): Promise<LightningPaymentResult>;
|
|
465
492
|
payLightningOffer(
|
|
466
493
|
offer: string,
|
|
467
494
|
wait: boolean,
|
|
@@ -483,19 +510,17 @@ export interface NitroArk extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
|
483
510
|
// --- Lightning Invoicing ---
|
|
484
511
|
bolt11Invoice(
|
|
485
512
|
amountMsat: number,
|
|
486
|
-
description?: string
|
|
513
|
+
description?: string,
|
|
514
|
+
token?: string
|
|
487
515
|
): Promise<Bolt11Invoice>;
|
|
488
|
-
lightningReceiveStatus(
|
|
489
|
-
paymentHash: string
|
|
490
|
-
): Promise<LightningReceive | undefined>;
|
|
516
|
+
lightningReceiveStatus(paymentHash: string): Promise<LightningReceive>;
|
|
491
517
|
checkLightningPayment(
|
|
492
518
|
paymentHash: string,
|
|
493
519
|
wait: boolean
|
|
494
520
|
): Promise<LightningPaymentResult>;
|
|
495
521
|
tryClaimLightningReceive(
|
|
496
522
|
paymentHash: string,
|
|
497
|
-
wait: boolean
|
|
498
|
-
token?: string
|
|
523
|
+
wait: boolean
|
|
499
524
|
): Promise<LightningReceive>; // Throws on error
|
|
500
525
|
tryClaimAllLightningReceives(wait: boolean): Promise<void>; // Throws on error
|
|
501
526
|
|
package/src/index.tsx
CHANGED
|
@@ -25,7 +25,7 @@ import type {
|
|
|
25
25
|
NewAddressResult,
|
|
26
26
|
KeyPairResult,
|
|
27
27
|
MailboxAuthorizationResult,
|
|
28
|
-
LightningReceive,
|
|
28
|
+
LightningReceive as NitroLightningReceive,
|
|
29
29
|
BarkNotificationEvent as NitroBarkNotificationEvent,
|
|
30
30
|
BarkNotificationSubscription,
|
|
31
31
|
BarkMovement as NitroBarkMovement,
|
|
@@ -61,37 +61,79 @@ export type ExitProgressState =
|
|
|
61
61
|
| 'Claimable'
|
|
62
62
|
| 'ClaimInProgress'
|
|
63
63
|
| 'Claimed'
|
|
64
|
-
| 'VtxoAlreadySpent'
|
|
64
|
+
| 'VtxoAlreadySpent'
|
|
65
|
+
| 'Canceled';
|
|
66
|
+
|
|
67
|
+
export type ExitStateKind =
|
|
68
|
+
| 'start'
|
|
69
|
+
| 'processing'
|
|
70
|
+
| 'awaiting-delta'
|
|
71
|
+
| 'claimable'
|
|
72
|
+
| 'claim-in-progress'
|
|
73
|
+
| 'claimed'
|
|
74
|
+
| 'vtxo-already-spent'
|
|
75
|
+
| 'canceled';
|
|
65
76
|
|
|
66
77
|
export type BlockRef = NitroExitBlockRefResult;
|
|
67
78
|
export type ExitTxOrigin = NitroExitTxOriginResult;
|
|
68
79
|
export type ExitTxStatus = NitroExitTxStatusResult;
|
|
69
80
|
export type ExitTx = NitroExitTxResult;
|
|
70
|
-
export type ExitStateDetails = NitroExitStateDetailsResult
|
|
81
|
+
export type ExitStateDetails = Omit<NitroExitStateDetailsResult, 'kind'> & {
|
|
82
|
+
kind: ExitStateKind;
|
|
83
|
+
};
|
|
71
84
|
|
|
72
85
|
export type ExitProgressStatusResult = Omit<
|
|
73
86
|
NitroExitProgressStatusResult,
|
|
74
|
-
'state'
|
|
87
|
+
'state' | 'state_details'
|
|
75
88
|
> & {
|
|
76
89
|
state: ExitProgressState;
|
|
90
|
+
state_details: ExitStateDetails;
|
|
77
91
|
};
|
|
78
92
|
|
|
79
|
-
export type ExitVtxoResult = Omit<
|
|
93
|
+
export type ExitVtxoResult = Omit<
|
|
94
|
+
NitroExitVtxoResult,
|
|
95
|
+
'state' | 'state_details' | 'history' | 'history_details'
|
|
96
|
+
> & {
|
|
80
97
|
state: ExitProgressState;
|
|
98
|
+
state_details: ExitStateDetails;
|
|
81
99
|
history: ExitProgressState[];
|
|
100
|
+
history_details: ExitStateDetails[];
|
|
82
101
|
};
|
|
83
102
|
|
|
84
103
|
export type ExitTransactionPackageResult = NitroExitTransactionPackageResult;
|
|
85
104
|
|
|
86
105
|
export type ExitStatusResult = Omit<
|
|
87
106
|
NitroExitStatusResult,
|
|
88
|
-
'state' | 'history'
|
|
107
|
+
'state' | 'state_details' | 'history' | 'history_details'
|
|
89
108
|
> & {
|
|
90
109
|
state: ExitProgressState;
|
|
110
|
+
state_details: ExitStateDetails;
|
|
91
111
|
history: ExitProgressState[];
|
|
112
|
+
history_details: ExitStateDetails[];
|
|
92
113
|
transactions: ExitTransactionPackageResult[];
|
|
93
114
|
};
|
|
94
115
|
|
|
116
|
+
export type LightningReceivePhase =
|
|
117
|
+
| 'awaiting_payment'
|
|
118
|
+
| 'htlcs_ready'
|
|
119
|
+
| 'preimage_revealed';
|
|
120
|
+
|
|
121
|
+
type LightningReceiveBase = Omit<NitroLightningReceive, 'state' | 'phase'>;
|
|
122
|
+
|
|
123
|
+
export type LightningReceive =
|
|
124
|
+
| (LightningReceiveBase & {
|
|
125
|
+
state: 'in_progress';
|
|
126
|
+
phase: LightningReceivePhase;
|
|
127
|
+
amount_sat?: undefined;
|
|
128
|
+
settled_at?: undefined;
|
|
129
|
+
})
|
|
130
|
+
| (LightningReceiveBase & {
|
|
131
|
+
state: 'settled';
|
|
132
|
+
phase?: undefined;
|
|
133
|
+
amount_sat: number;
|
|
134
|
+
settled_at: number;
|
|
135
|
+
});
|
|
136
|
+
|
|
95
137
|
export type BarkMovementDestination = NitroBarkMovementDestination & {
|
|
96
138
|
payment_method:
|
|
97
139
|
| 'ark'
|
|
@@ -162,37 +204,85 @@ export type LightningPayment = Omit<LightningPaymentResult, 'state'> & {
|
|
|
162
204
|
state: LightningPaymentState;
|
|
163
205
|
};
|
|
164
206
|
|
|
207
|
+
/**
|
|
208
|
+
* A user-facing payment identifier that has already been resolved to a
|
|
209
|
+
* Lightning invoice. `custom` preserves protocols Bark does not model
|
|
210
|
+
* natively while still recording their original identifier.
|
|
211
|
+
*/
|
|
212
|
+
export type LightningPaymentOrigin =
|
|
213
|
+
| { method: 'lightning-address'; value: string }
|
|
214
|
+
| { method: 'lnurl'; value: string }
|
|
215
|
+
| { method: 'custom'; value: string };
|
|
216
|
+
|
|
165
217
|
export const NitroArkHybridObject =
|
|
166
218
|
NitroModules.createHybridObject<NitroArk>('NitroArk');
|
|
167
219
|
|
|
168
220
|
function enrichExitProgressStatus(
|
|
169
221
|
result: NitroExitProgressStatusResult
|
|
170
222
|
): ExitProgressStatusResult {
|
|
171
|
-
const { state, ...rest } = result;
|
|
223
|
+
const { state, state_details, ...rest } = result;
|
|
172
224
|
return {
|
|
173
225
|
...rest,
|
|
174
226
|
state: state as ExitProgressState,
|
|
227
|
+
state_details: {
|
|
228
|
+
...state_details,
|
|
229
|
+
kind: state_details.kind as ExitStateKind,
|
|
230
|
+
},
|
|
175
231
|
};
|
|
176
232
|
}
|
|
177
233
|
|
|
178
234
|
function enrichExitVtxo(result: NitroExitVtxoResult): ExitVtxoResult {
|
|
179
|
-
const {
|
|
235
|
+
const {
|
|
236
|
+
state,
|
|
237
|
+
state_details,
|
|
238
|
+
history: stateHistory,
|
|
239
|
+
history_details,
|
|
240
|
+
...rest
|
|
241
|
+
} = result;
|
|
180
242
|
return {
|
|
181
243
|
...rest,
|
|
182
244
|
state: state as ExitProgressState,
|
|
245
|
+
state_details: {
|
|
246
|
+
...state_details,
|
|
247
|
+
kind: state_details.kind as ExitStateKind,
|
|
248
|
+
},
|
|
183
249
|
history: stateHistory as ExitProgressState[],
|
|
250
|
+
history_details: history_details.map((details) => ({
|
|
251
|
+
...details,
|
|
252
|
+
kind: details.kind as ExitStateKind,
|
|
253
|
+
})),
|
|
184
254
|
};
|
|
185
255
|
}
|
|
186
256
|
|
|
187
257
|
function enrichExitStatus(result: NitroExitStatusResult): ExitStatusResult {
|
|
188
|
-
const {
|
|
258
|
+
const {
|
|
259
|
+
state,
|
|
260
|
+
state_details,
|
|
261
|
+
history: stateHistory,
|
|
262
|
+
history_details,
|
|
263
|
+
...rest
|
|
264
|
+
} = result;
|
|
189
265
|
return {
|
|
190
266
|
...rest,
|
|
191
267
|
state: state as ExitProgressState,
|
|
268
|
+
state_details: {
|
|
269
|
+
...state_details,
|
|
270
|
+
kind: state_details.kind as ExitStateKind,
|
|
271
|
+
},
|
|
192
272
|
history: stateHistory as ExitProgressState[],
|
|
273
|
+
history_details: history_details.map((details) => ({
|
|
274
|
+
...details,
|
|
275
|
+
kind: details.kind as ExitStateKind,
|
|
276
|
+
})),
|
|
193
277
|
};
|
|
194
278
|
}
|
|
195
279
|
|
|
280
|
+
function enrichLightningReceive(
|
|
281
|
+
result: NitroLightningReceive
|
|
282
|
+
): LightningReceive {
|
|
283
|
+
return result as LightningReceive;
|
|
284
|
+
}
|
|
285
|
+
|
|
196
286
|
// --- Management ---
|
|
197
287
|
|
|
198
288
|
/** Returns the semver of the Bark wallet library compiled into the native module. */
|
|
@@ -300,42 +390,16 @@ export function syncPendingBoards(): Promise<void> {
|
|
|
300
390
|
return NitroArkHybridObject.syncPendingBoards();
|
|
301
391
|
}
|
|
302
392
|
|
|
303
|
-
/**
|
|
304
|
-
* Runs wallet maintenance tasks for offchain.
|
|
305
|
-
* This includes refreshing vtxos that need to be refreshed.
|
|
306
|
-
* @returns A promise that resolves on success.
|
|
307
|
-
*/
|
|
393
|
+
/** Runs wallet maintenance, including on-chain synchronization and exit progression. */
|
|
308
394
|
export function maintenance(): Promise<void> {
|
|
309
395
|
return NitroArkHybridObject.maintenance();
|
|
310
396
|
}
|
|
311
397
|
|
|
312
|
-
/**
|
|
313
|
-
* Runs wallet maintenance tasks for both offchain and onchain.
|
|
314
|
-
* This includes refreshing vtxos that need to be refreshed.
|
|
315
|
-
* @returns A promise that resolves on success.
|
|
316
|
-
*/
|
|
317
|
-
export function maintenanceWithOnchain(): Promise<void> {
|
|
318
|
-
return NitroArkHybridObject.maintenanceWithOnchain();
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Runs delegated wallet maintenance tasks for offchain.
|
|
323
|
-
* This includes refreshing vtxos that need to be refreshed using delegated signing.
|
|
324
|
-
* @returns A promise that resolves on success.
|
|
325
|
-
*/
|
|
398
|
+
/** Runs delegated wallet maintenance, including on-chain synchronization. */
|
|
326
399
|
export function maintenanceDelegated(): Promise<void> {
|
|
327
400
|
return NitroArkHybridObject.maintenanceDelegated();
|
|
328
401
|
}
|
|
329
402
|
|
|
330
|
-
/**
|
|
331
|
-
* Runs delegated wallet maintenance tasks for both offchain and onchain.
|
|
332
|
-
* This includes refreshing vtxos that need to be refreshed using delegated signing.
|
|
333
|
-
* @returns A promise that resolves on success.
|
|
334
|
-
*/
|
|
335
|
-
export function maintenanceWithOnchainDelegated(): Promise<void> {
|
|
336
|
-
return NitroArkHybridObject.maintenanceWithOnchainDelegated();
|
|
337
|
-
}
|
|
338
|
-
|
|
339
403
|
/**
|
|
340
404
|
* Refreshes vtxos that need to be refreshed.
|
|
341
405
|
* @returns A promise that resolves on success.
|
|
@@ -704,6 +768,29 @@ export function history(): Promise<BarkMovement[]> {
|
|
|
704
768
|
return NitroArkHybridObject.history() as Promise<BarkMovement[]>;
|
|
705
769
|
}
|
|
706
770
|
|
|
771
|
+
/**
|
|
772
|
+
* Applies an RFC 7396 JSON Merge Patch to a wallet movement's metadata.
|
|
773
|
+
* The patch must serialize to a JSON object no larger than 16 KiB.
|
|
774
|
+
* @param movementId The Bark movement ID.
|
|
775
|
+
* @param patchJson The JSON object merge patch.
|
|
776
|
+
* @returns A promise that resolves after Bark persists the updated metadata.
|
|
777
|
+
*/
|
|
778
|
+
export function updateHistoryMetadata(
|
|
779
|
+
movementId: number,
|
|
780
|
+
patchJson: string
|
|
781
|
+
): Promise<void> {
|
|
782
|
+
if (
|
|
783
|
+
!Number.isFinite(movementId) ||
|
|
784
|
+
!Number.isInteger(movementId) ||
|
|
785
|
+
movementId < 0 ||
|
|
786
|
+
movementId > 0xffffffff
|
|
787
|
+
) {
|
|
788
|
+
throw new RangeError('movementId must be a finite unsigned 32-bit integer');
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
return NitroArkHybridObject.updateHistoryMetadata(movementId, patchJson);
|
|
792
|
+
}
|
|
793
|
+
|
|
707
794
|
/**
|
|
708
795
|
* Gets the list of VTXOs as a JSON string for the loaded wallet.
|
|
709
796
|
* @param no_sync If true, skips synchronization with the blockchain. Defaults to false.
|
|
@@ -742,6 +829,15 @@ export function dangerousDropVtxo(vtxoId: string): Promise<void> {
|
|
|
742
829
|
return NitroArkHybridObject.dangerousDropVtxo(vtxoId);
|
|
743
830
|
}
|
|
744
831
|
|
|
832
|
+
/**
|
|
833
|
+
* Unlocks locked VTXOs and returns them to the spendable state.
|
|
834
|
+
* Already-spendable VTXOs are left unchanged. Spent, unknown, or malformed IDs reject the batch.
|
|
835
|
+
* @param vtxoIds VTXO IDs to unlock.
|
|
836
|
+
*/
|
|
837
|
+
export function unlockVtxos(vtxoIds: string[]): Promise<void> {
|
|
838
|
+
return NitroArkHybridObject.unlockVtxos(vtxoIds);
|
|
839
|
+
}
|
|
840
|
+
|
|
745
841
|
/**
|
|
746
842
|
* Gets the first expiring VTXO blockheight for the loaded wallet.
|
|
747
843
|
* @returns A promise resolving to the first expiring VTXO blockheight.
|
|
@@ -877,9 +973,10 @@ export function onchainSendMany(
|
|
|
877
973
|
*/
|
|
878
974
|
export function bolt11Invoice(
|
|
879
975
|
amountMsat: number,
|
|
880
|
-
description?: string
|
|
976
|
+
description?: string,
|
|
977
|
+
token?: string
|
|
881
978
|
): Promise<Bolt11Invoice> {
|
|
882
|
-
return NitroArkHybridObject.bolt11Invoice(amountMsat, description);
|
|
979
|
+
return NitroArkHybridObject.bolt11Invoice(amountMsat, description, token);
|
|
883
980
|
}
|
|
884
981
|
|
|
885
982
|
/**
|
|
@@ -889,8 +986,10 @@ export function bolt11Invoice(
|
|
|
889
986
|
*/
|
|
890
987
|
export function lightningReceiveStatus(
|
|
891
988
|
paymentHash: string
|
|
892
|
-
): Promise<LightningReceive
|
|
893
|
-
return NitroArkHybridObject.lightningReceiveStatus(paymentHash)
|
|
989
|
+
): Promise<LightningReceive> {
|
|
990
|
+
return NitroArkHybridObject.lightningReceiveStatus(paymentHash).then(
|
|
991
|
+
enrichLightningReceive
|
|
992
|
+
);
|
|
894
993
|
}
|
|
895
994
|
|
|
896
995
|
/**
|
|
@@ -912,21 +1011,17 @@ export function checkLightningPayment(
|
|
|
912
1011
|
}
|
|
913
1012
|
|
|
914
1013
|
/**
|
|
915
|
-
* Attempts to claim a Lightning payment
|
|
1014
|
+
* Attempts to claim a Lightning payment.
|
|
916
1015
|
* @param paymentHash The payment hash of the Lightning payment.
|
|
917
1016
|
* @param wait Whether to wait for the claim to complete.
|
|
918
|
-
* @
|
|
919
|
-
* @returns A promise resolving to the claimed LightningReceive if successful, or null if not.
|
|
1017
|
+
* @returns A promise resolving to the current Lightning receive state.
|
|
920
1018
|
*/
|
|
921
1019
|
export function tryClaimLightningReceive(
|
|
922
1020
|
paymentHash: string,
|
|
923
|
-
wait: boolean
|
|
924
|
-
token?: string
|
|
1021
|
+
wait: boolean
|
|
925
1022
|
): Promise<LightningReceive> {
|
|
926
|
-
return NitroArkHybridObject.tryClaimLightningReceive(
|
|
927
|
-
|
|
928
|
-
wait,
|
|
929
|
-
token
|
|
1023
|
+
return NitroArkHybridObject.tryClaimLightningReceive(paymentHash, wait).then(
|
|
1024
|
+
enrichLightningReceive
|
|
930
1025
|
);
|
|
931
1026
|
}
|
|
932
1027
|
|
|
@@ -961,6 +1056,46 @@ export function payLightningInvoice(
|
|
|
961
1056
|
}));
|
|
962
1057
|
}
|
|
963
1058
|
|
|
1059
|
+
/**
|
|
1060
|
+
* Pays a Bolt11 invoice that the caller has already resolved from another
|
|
1061
|
+
* user-facing payment identifier.
|
|
1062
|
+
*
|
|
1063
|
+
* This is a low-level counterpart to helpers such as `payLightningAddress`.
|
|
1064
|
+
* It deliberately performs no remote discovery or callback request. Instead,
|
|
1065
|
+
* it tells Bark which identifier produced the invoice so Bark can persist that
|
|
1066
|
+
* identifier in the Lightning-send checkpoint and movement before settlement.
|
|
1067
|
+
* This keeps payment provenance intact across interruption, history reloads,
|
|
1068
|
+
* and wallet backups instead of recording only the one-time Bolt11 invoice.
|
|
1069
|
+
*
|
|
1070
|
+
* Callers remain responsible for resolving the origin, validating the returned
|
|
1071
|
+
* invoice, and ensuring its amount matches the external protocol request.
|
|
1072
|
+
* This API intentionally has no amount override: the resolved invoice must
|
|
1073
|
+
* contain its exact payment amount.
|
|
1074
|
+
*
|
|
1075
|
+
* The origin becomes durable wallet history and is included in wallet
|
|
1076
|
+
* database backups. Pass the original user-facing identifier, never a callback
|
|
1077
|
+
* URL containing payer data, authorization tokens, or other secrets.
|
|
1078
|
+
*
|
|
1079
|
+
* @param invoice The already-resolved Bolt11 invoice to pay.
|
|
1080
|
+
* @param origin The original destination to store in Bark's movement history.
|
|
1081
|
+
* @param wait Whether to wait for the payment to complete.
|
|
1082
|
+
* @returns A promise resolving to the current Lightning payment state.
|
|
1083
|
+
*/
|
|
1084
|
+
export function payLightningInvoiceWithOrigin(
|
|
1085
|
+
invoice: string,
|
|
1086
|
+
origin: LightningPaymentOrigin,
|
|
1087
|
+
wait: boolean
|
|
1088
|
+
): Promise<LightningPayment> {
|
|
1089
|
+
return NitroArkHybridObject.payLightningInvoiceWithOrigin(
|
|
1090
|
+
invoice,
|
|
1091
|
+
origin,
|
|
1092
|
+
wait
|
|
1093
|
+
).then((result) => ({
|
|
1094
|
+
...result,
|
|
1095
|
+
state: result.state as LightningPaymentState,
|
|
1096
|
+
}));
|
|
1097
|
+
}
|
|
1098
|
+
|
|
964
1099
|
/**
|
|
965
1100
|
* Sends a payment to a Bolt12 offer.
|
|
966
1101
|
* @param offer The Bolt12 offer.
|
|
@@ -1173,5 +1308,4 @@ export type {
|
|
|
1173
1308
|
OnchainBalanceResult,
|
|
1174
1309
|
NewAddressResult,
|
|
1175
1310
|
KeyPairResult,
|
|
1176
|
-
LightningReceive,
|
|
1177
1311
|
} from './NitroArk.nitro';
|