react-native-nitro-ark 0.0.132 → 0.0.133
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/cpp/NitroArk.hpp +59 -85
- package/cpp/generated/ark_cxx.h +14 -10
- package/lib/module/index.js +49 -39
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NitroArk.nitro.d.ts +10 -8
- package/lib/typescript/src/NitroArk.nitro.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +41 -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 +1 -2
- package/nitrogen/generated/shared/c++/HybridNitroArkSpec.hpp +4 -5
- package/nitrogen/generated/shared/c++/LightningReceive.hpp +26 -9
- package/package.json +1 -1
- package/src/NitroArk.nitro.ts +11 -11
- package/src/index.tsx +112 -51
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;
|
|
@@ -229,11 +228,15 @@ export interface MailboxAuthorizationResult {
|
|
|
229
228
|
}
|
|
230
229
|
|
|
231
230
|
export interface LightningReceive {
|
|
231
|
+
state: string;
|
|
232
|
+
phase?: string;
|
|
232
233
|
payment_hash: string;
|
|
233
234
|
payment_preimage: string;
|
|
234
235
|
invoice: string;
|
|
235
|
-
|
|
236
|
-
|
|
236
|
+
htlc_vtxo_ids: string[];
|
|
237
|
+
movement_id?: number;
|
|
238
|
+
amount_sat?: number;
|
|
239
|
+
settled_at?: number;
|
|
237
240
|
}
|
|
238
241
|
|
|
239
242
|
export interface BarkMovementSubsystem {
|
|
@@ -339,9 +342,7 @@ export interface NitroArk extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
|
339
342
|
refreshServer(): Promise<void>;
|
|
340
343
|
syncPendingBoards(): Promise<void>;
|
|
341
344
|
maintenance(): Promise<void>;
|
|
342
|
-
maintenanceWithOnchain(): Promise<void>;
|
|
343
345
|
maintenanceDelegated(): Promise<void>;
|
|
344
|
-
maintenanceWithOnchainDelegated(): Promise<void>;
|
|
345
346
|
maintenanceRefresh(): Promise<void>;
|
|
346
347
|
sync(): Promise<void>;
|
|
347
348
|
|
|
@@ -413,6 +414,7 @@ export interface NitroArk extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
|
413
414
|
decodeVtxoHex(vtxoHex: string): Promise<BarkVtxo>;
|
|
414
415
|
importVtxo(vtxoHex: string): Promise<BarkVtxo>;
|
|
415
416
|
dangerousDropVtxo(vtxoId: string): Promise<void>;
|
|
417
|
+
unlockVtxos(vtxoIds: string[]): Promise<void>;
|
|
416
418
|
refreshVtxosDelegated(
|
|
417
419
|
vtxoIds: string[]
|
|
418
420
|
): Promise<DelegatedRoundState | undefined>;
|
|
@@ -483,19 +485,17 @@ export interface NitroArk extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
|
483
485
|
// --- Lightning Invoicing ---
|
|
484
486
|
bolt11Invoice(
|
|
485
487
|
amountMsat: number,
|
|
486
|
-
description?: string
|
|
488
|
+
description?: string,
|
|
489
|
+
token?: string
|
|
487
490
|
): Promise<Bolt11Invoice>;
|
|
488
|
-
lightningReceiveStatus(
|
|
489
|
-
paymentHash: string
|
|
490
|
-
): Promise<LightningReceive | undefined>;
|
|
491
|
+
lightningReceiveStatus(paymentHash: string): Promise<LightningReceive>;
|
|
491
492
|
checkLightningPayment(
|
|
492
493
|
paymentHash: string,
|
|
493
494
|
wait: boolean
|
|
494
495
|
): Promise<LightningPaymentResult>;
|
|
495
496
|
tryClaimLightningReceive(
|
|
496
497
|
paymentHash: string,
|
|
497
|
-
wait: boolean
|
|
498
|
-
token?: string
|
|
498
|
+
wait: boolean
|
|
499
499
|
): Promise<LightningReceive>; // Throws on error
|
|
500
500
|
tryClaimAllLightningReceives(wait: boolean): Promise<void>; // Throws on error
|
|
501
501
|
|
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'
|
|
@@ -168,31 +210,69 @@ export const NitroArkHybridObject =
|
|
|
168
210
|
function enrichExitProgressStatus(
|
|
169
211
|
result: NitroExitProgressStatusResult
|
|
170
212
|
): ExitProgressStatusResult {
|
|
171
|
-
const { state, ...rest } = result;
|
|
213
|
+
const { state, state_details, ...rest } = result;
|
|
172
214
|
return {
|
|
173
215
|
...rest,
|
|
174
216
|
state: state as ExitProgressState,
|
|
217
|
+
state_details: {
|
|
218
|
+
...state_details,
|
|
219
|
+
kind: state_details.kind as ExitStateKind,
|
|
220
|
+
},
|
|
175
221
|
};
|
|
176
222
|
}
|
|
177
223
|
|
|
178
224
|
function enrichExitVtxo(result: NitroExitVtxoResult): ExitVtxoResult {
|
|
179
|
-
const {
|
|
225
|
+
const {
|
|
226
|
+
state,
|
|
227
|
+
state_details,
|
|
228
|
+
history: stateHistory,
|
|
229
|
+
history_details,
|
|
230
|
+
...rest
|
|
231
|
+
} = result;
|
|
180
232
|
return {
|
|
181
233
|
...rest,
|
|
182
234
|
state: state as ExitProgressState,
|
|
235
|
+
state_details: {
|
|
236
|
+
...state_details,
|
|
237
|
+
kind: state_details.kind as ExitStateKind,
|
|
238
|
+
},
|
|
183
239
|
history: stateHistory as ExitProgressState[],
|
|
240
|
+
history_details: history_details.map((details) => ({
|
|
241
|
+
...details,
|
|
242
|
+
kind: details.kind as ExitStateKind,
|
|
243
|
+
})),
|
|
184
244
|
};
|
|
185
245
|
}
|
|
186
246
|
|
|
187
247
|
function enrichExitStatus(result: NitroExitStatusResult): ExitStatusResult {
|
|
188
|
-
const {
|
|
248
|
+
const {
|
|
249
|
+
state,
|
|
250
|
+
state_details,
|
|
251
|
+
history: stateHistory,
|
|
252
|
+
history_details,
|
|
253
|
+
...rest
|
|
254
|
+
} = result;
|
|
189
255
|
return {
|
|
190
256
|
...rest,
|
|
191
257
|
state: state as ExitProgressState,
|
|
258
|
+
state_details: {
|
|
259
|
+
...state_details,
|
|
260
|
+
kind: state_details.kind as ExitStateKind,
|
|
261
|
+
},
|
|
192
262
|
history: stateHistory as ExitProgressState[],
|
|
263
|
+
history_details: history_details.map((details) => ({
|
|
264
|
+
...details,
|
|
265
|
+
kind: details.kind as ExitStateKind,
|
|
266
|
+
})),
|
|
193
267
|
};
|
|
194
268
|
}
|
|
195
269
|
|
|
270
|
+
function enrichLightningReceive(
|
|
271
|
+
result: NitroLightningReceive
|
|
272
|
+
): LightningReceive {
|
|
273
|
+
return result as LightningReceive;
|
|
274
|
+
}
|
|
275
|
+
|
|
196
276
|
// --- Management ---
|
|
197
277
|
|
|
198
278
|
/** Returns the semver of the Bark wallet library compiled into the native module. */
|
|
@@ -300,42 +380,16 @@ export function syncPendingBoards(): Promise<void> {
|
|
|
300
380
|
return NitroArkHybridObject.syncPendingBoards();
|
|
301
381
|
}
|
|
302
382
|
|
|
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
|
-
*/
|
|
383
|
+
/** Runs wallet maintenance, including on-chain synchronization and exit progression. */
|
|
308
384
|
export function maintenance(): Promise<void> {
|
|
309
385
|
return NitroArkHybridObject.maintenance();
|
|
310
386
|
}
|
|
311
387
|
|
|
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
|
-
*/
|
|
388
|
+
/** Runs delegated wallet maintenance, including on-chain synchronization. */
|
|
326
389
|
export function maintenanceDelegated(): Promise<void> {
|
|
327
390
|
return NitroArkHybridObject.maintenanceDelegated();
|
|
328
391
|
}
|
|
329
392
|
|
|
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
393
|
/**
|
|
340
394
|
* Refreshes vtxos that need to be refreshed.
|
|
341
395
|
* @returns A promise that resolves on success.
|
|
@@ -742,6 +796,15 @@ export function dangerousDropVtxo(vtxoId: string): Promise<void> {
|
|
|
742
796
|
return NitroArkHybridObject.dangerousDropVtxo(vtxoId);
|
|
743
797
|
}
|
|
744
798
|
|
|
799
|
+
/**
|
|
800
|
+
* Unlocks locked VTXOs and returns them to the spendable state.
|
|
801
|
+
* Already-spendable VTXOs are left unchanged. Spent, unknown, or malformed IDs reject the batch.
|
|
802
|
+
* @param vtxoIds VTXO IDs to unlock.
|
|
803
|
+
*/
|
|
804
|
+
export function unlockVtxos(vtxoIds: string[]): Promise<void> {
|
|
805
|
+
return NitroArkHybridObject.unlockVtxos(vtxoIds);
|
|
806
|
+
}
|
|
807
|
+
|
|
745
808
|
/**
|
|
746
809
|
* Gets the first expiring VTXO blockheight for the loaded wallet.
|
|
747
810
|
* @returns A promise resolving to the first expiring VTXO blockheight.
|
|
@@ -877,9 +940,10 @@ export function onchainSendMany(
|
|
|
877
940
|
*/
|
|
878
941
|
export function bolt11Invoice(
|
|
879
942
|
amountMsat: number,
|
|
880
|
-
description?: string
|
|
943
|
+
description?: string,
|
|
944
|
+
token?: string
|
|
881
945
|
): Promise<Bolt11Invoice> {
|
|
882
|
-
return NitroArkHybridObject.bolt11Invoice(amountMsat, description);
|
|
946
|
+
return NitroArkHybridObject.bolt11Invoice(amountMsat, description, token);
|
|
883
947
|
}
|
|
884
948
|
|
|
885
949
|
/**
|
|
@@ -889,8 +953,10 @@ export function bolt11Invoice(
|
|
|
889
953
|
*/
|
|
890
954
|
export function lightningReceiveStatus(
|
|
891
955
|
paymentHash: string
|
|
892
|
-
): Promise<LightningReceive
|
|
893
|
-
return NitroArkHybridObject.lightningReceiveStatus(paymentHash)
|
|
956
|
+
): Promise<LightningReceive> {
|
|
957
|
+
return NitroArkHybridObject.lightningReceiveStatus(paymentHash).then(
|
|
958
|
+
enrichLightningReceive
|
|
959
|
+
);
|
|
894
960
|
}
|
|
895
961
|
|
|
896
962
|
/**
|
|
@@ -912,21 +978,17 @@ export function checkLightningPayment(
|
|
|
912
978
|
}
|
|
913
979
|
|
|
914
980
|
/**
|
|
915
|
-
* Attempts to claim a Lightning payment
|
|
981
|
+
* Attempts to claim a Lightning payment.
|
|
916
982
|
* @param paymentHash The payment hash of the Lightning payment.
|
|
917
983
|
* @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.
|
|
984
|
+
* @returns A promise resolving to the current Lightning receive state.
|
|
920
985
|
*/
|
|
921
986
|
export function tryClaimLightningReceive(
|
|
922
987
|
paymentHash: string,
|
|
923
|
-
wait: boolean
|
|
924
|
-
token?: string
|
|
988
|
+
wait: boolean
|
|
925
989
|
): Promise<LightningReceive> {
|
|
926
|
-
return NitroArkHybridObject.tryClaimLightningReceive(
|
|
927
|
-
|
|
928
|
-
wait,
|
|
929
|
-
token
|
|
990
|
+
return NitroArkHybridObject.tryClaimLightningReceive(paymentHash, wait).then(
|
|
991
|
+
enrichLightningReceive
|
|
930
992
|
);
|
|
931
993
|
}
|
|
932
994
|
|
|
@@ -1173,5 +1235,4 @@ export type {
|
|
|
1173
1235
|
OnchainBalanceResult,
|
|
1174
1236
|
NewAddressResult,
|
|
1175
1237
|
KeyPairResult,
|
|
1176
|
-
LightningReceive,
|
|
1177
1238
|
} from './NitroArk.nitro';
|