@lightninglabs/wavelength-core 0.1.0
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/LICENSE +19 -0
- package/README.md +31 -0
- package/dist/activity-options.d.ts +15 -0
- package/dist/activity-options.d.ts.map +1 -0
- package/dist/activity-options.js +7 -0
- package/dist/base-client.d.ts +59 -0
- package/dist/base-client.d.ts.map +1 -0
- package/dist/base-client.js +144 -0
- package/dist/casing.d.ts +4 -0
- package/dist/casing.d.ts.map +1 -0
- package/dist/casing.js +42 -0
- package/dist/client.d.ts +90 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +1 -0
- package/dist/config.d.ts +128 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +142 -0
- package/dist/destination.d.ts +56 -0
- package/dist/destination.d.ts.map +1 -0
- package/dist/destination.js +90 -0
- package/dist/engine/activity.d.ts +25 -0
- package/dist/engine/activity.d.ts.map +1 -0
- package/dist/engine/activity.js +119 -0
- package/dist/engine/constants.d.ts +29 -0
- package/dist/engine/constants.d.ts.map +1 -0
- package/dist/engine/constants.js +29 -0
- package/dist/engine/engine.d.ts +115 -0
- package/dist/engine/engine.d.ts.map +1 -0
- package/dist/engine/engine.js +548 -0
- package/dist/engine/machine.d.ts +50 -0
- package/dist/engine/machine.d.ts.map +1 -0
- package/dist/engine/machine.js +55 -0
- package/dist/engine/optionsAssertions.d.ts +2 -0
- package/dist/engine/optionsAssertions.d.ts.map +1 -0
- package/dist/engine/optionsAssertions.js +20 -0
- package/dist/engine/poller.d.ts +20 -0
- package/dist/engine/poller.d.ts.map +1 -0
- package/dist/engine/poller.js +51 -0
- package/dist/engine/reconcile.d.ts +36 -0
- package/dist/engine/reconcile.d.ts.map +1 -0
- package/dist/engine/reconcile.js +81 -0
- package/dist/engine/snapshot.d.ts +58 -0
- package/dist/engine/snapshot.d.ts.map +1 -0
- package/dist/engine/snapshot.js +10 -0
- package/dist/engine/stabilize.d.ts +8 -0
- package/dist/engine/stabilize.d.ts.map +1 -0
- package/dist/engine/stabilize.js +17 -0
- package/dist/engine/store.d.ts +21 -0
- package/dist/engine/store.d.ts.map +1 -0
- package/dist/engine/store.js +46 -0
- package/dist/errors.d.ts +55 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +80 -0
- package/dist/events.d.ts +62 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +1 -0
- package/dist/exit.d.ts +93 -0
- package/dist/exit.d.ts.map +1 -0
- package/dist/exit.js +86 -0
- package/dist/facade.d.ts +88 -0
- package/dist/facade.d.ts.map +1 -0
- package/dist/facade.js +150 -0
- package/dist/generated.d.ts +1197 -0
- package/dist/generated.d.ts.map +1 -0
- package/dist/generated.js +206 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/passkey.d.ts +46 -0
- package/dist/passkey.d.ts.map +1 -0
- package/dist/passkey.js +16 -0
- package/dist/public-api-assertions.d.ts +2 -0
- package/dist/public-api-assertions.d.ts.map +1 -0
- package/dist/public-api-assertions.js +42 -0
- package/dist/request-assertions.d.ts +2 -0
- package/dist/request-assertions.d.ts.map +1 -0
- package/dist/request-assertions.js +12 -0
- package/dist/requests.d.ts +186 -0
- package/dist/requests.d.ts.map +1 -0
- package/dist/requests.js +5 -0
- package/dist/response-normalization.d.ts +5 -0
- package/dist/response-normalization.d.ts.map +1 -0
- package/dist/response-normalization.js +101 -0
- package/dist/results.d.ts +49 -0
- package/dist/results.d.ts.map +1 -0
- package/dist/results.js +4 -0
- package/dist/state.d.ts +87 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +87 -0
- package/dist/version.d.ts +18 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +17 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (C) 2026 Lightning Labs and The Lightning Network Developers
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @lightninglabs/wavelength-core
|
|
2
|
+
|
|
3
|
+
The contract at the base of the [Wavelength](https://wavelength.lightning.engineering) SDK: a
|
|
4
|
+
self-custodial Lightning wallet you embed directly in your app, so your users
|
|
5
|
+
send and receive Lightning payments with no node to run, no channels to open,
|
|
6
|
+
and no inbound liquidity to manage, while their keys stay on their own device.
|
|
7
|
+
|
|
8
|
+
This package is transport- and framework-agnostic. It carries the
|
|
9
|
+
`WavelengthClient` interface, the request/response types, `RuntimeConfig` and
|
|
10
|
+
its per-network endpoint defaults, the errors and enums, and the generated
|
|
11
|
+
daemon types. It has no DOM and no transport of its own.
|
|
12
|
+
|
|
13
|
+
You usually don't install this package directly. Each transport re-exports
|
|
14
|
+
everything here, so an app imports the client and its types from one place:
|
|
15
|
+
|
|
16
|
+
- [`@lightninglabs/wavelength-web`](https://www.npmjs.com/package/@lightninglabs/wavelength-web) for the browser (WebAssembly).
|
|
17
|
+
- [`@lightninglabs/wavelength-react-native`](https://www.npmjs.com/package/@lightninglabs/wavelength-react-native) for React Native.
|
|
18
|
+
|
|
19
|
+
Install it on its own only when you need the types or the client contract
|
|
20
|
+
without a transport, for example in shared code:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
npm install @lightninglabs/wavelength-core
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import type { WavelengthClient, RuntimeConfig } from "@lightninglabs/wavelength-core";
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
See the [documentation](https://wavelength.lightning.engineering) for the full
|
|
31
|
+
API reference.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EntryKind } from './generated.ts';
|
|
2
|
+
/** Controls the wallet activity replay, filtering, and resume position. */
|
|
3
|
+
export type ActivityStreamOptions = {
|
|
4
|
+
/** When true with a zero cursor, replays existing activity before live updates. */
|
|
5
|
+
includeExisting?: boolean;
|
|
6
|
+
/** Restricts updates to the selected activity kinds. */
|
|
7
|
+
kinds?: EntryKind[];
|
|
8
|
+
/**
|
|
9
|
+
* Resumes after this monotonic activity cursor, replaying later events before
|
|
10
|
+
* live updates. Must be a nonnegative safe integer.
|
|
11
|
+
*/
|
|
12
|
+
cursor?: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function validateActivityStreamOptions(opts: ActivityStreamOptions): void;
|
|
15
|
+
//# sourceMappingURL=activity-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activity-options.d.ts","sourceRoot":"","sources":["../src/activity-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,2EAA2E;AAC3E,MAAM,MAAM,qBAAqB,GAAG;IAClC,mFAAmF;IACnF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,wDAAwD;IACxD,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,qBAAqB,GAC1B,IAAI,CAUN"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { WavelengthError } from "./errors.js";
|
|
2
|
+
export function validateActivityStreamOptions(opts) {
|
|
3
|
+
if (opts.cursor !== undefined &&
|
|
4
|
+
(!Number.isSafeInteger(opts.cursor) || opts.cursor < 0)) {
|
|
5
|
+
throw new WavelengthError('activity cursor must be a nonnegative safe integer', 'invalid_cursor');
|
|
6
|
+
}
|
|
7
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { CreateWalletRequest, DepositRequest, ExitRequest, ExitStatusRequest, ExitSummaryRequest, GetExitPlanRequest, ListRequest, OpenWalletFromPasskeyRequest, ReceiveRequest, SendRequest, SweepWalletRequest, UnlockWalletRequest } from './requests.ts';
|
|
2
|
+
import type { Balance, CreateWalletResult, DepositResult, ExitResult, ExitStatusResult, ExitSummaryResult, GetExitPlanResult, ListResult, OpenWalletFromPasskeyResult, PrepareSendResult, ReceiveResult, SendResult, SweepWalletResult, UnlockWalletResult } from './results.ts';
|
|
3
|
+
import { type RuntimeConfig } from './config.ts';
|
|
4
|
+
import type { WavelengthClient } from './client.ts';
|
|
5
|
+
import type { WavelengthEvent, WavelengthListener } from './events.ts';
|
|
6
|
+
import type { WalletInfo, WalletStatus } from './state.ts';
|
|
7
|
+
import type { FacadeMethod, ServerTransport } from './facade.ts';
|
|
8
|
+
import type { Entry } from './generated.ts';
|
|
9
|
+
import { type ActivityStreamOptions } from './activity-options.ts';
|
|
10
|
+
/**
|
|
11
|
+
* Implements the transport-agnostic half of {@link WavelengthClient}: every RPC
|
|
12
|
+
* verb is expressed in terms of the abstract invokeFacade, so a transport (web
|
|
13
|
+
* wasm, React Native gomobile, or a future one) supplies only the pipe:
|
|
14
|
+
* invokeFacade, ready, the activity-stream plumbing, and its {@link ServerTransport}
|
|
15
|
+
* flavor. The shared subscribe/emit listener machinery and typed wrappers live
|
|
16
|
+
* here. The facade catalog, public contract, native dispatch, and response
|
|
17
|
+
* normalization remain separate synchronization points.
|
|
18
|
+
*/
|
|
19
|
+
export declare abstract class BaseWavelengthClient implements WavelengthClient {
|
|
20
|
+
protected readonly listeners: Set<WavelengthListener>;
|
|
21
|
+
abstract ready(): Promise<void>;
|
|
22
|
+
protected abstract invokeFacade<T = unknown>(method: FacadeMethod, params?: unknown): Promise<T>;
|
|
23
|
+
protected abstract openActivityStream(opts: ActivityStreamOptions): Promise<void>;
|
|
24
|
+
abstract stopActivity(): void;
|
|
25
|
+
/** How this transport's daemon dials the Ark and swap servers. */
|
|
26
|
+
protected abstract readonly serverTransport: ServerTransport;
|
|
27
|
+
callFacade<T = unknown>(method: FacadeMethod, params?: unknown): Promise<T>;
|
|
28
|
+
isRunning(): Promise<boolean>;
|
|
29
|
+
startActivity(opts?: ActivityStreamOptions): Promise<void>;
|
|
30
|
+
start(config: RuntimeConfig): Promise<WalletInfo>;
|
|
31
|
+
stop(): Promise<void>;
|
|
32
|
+
getInfo(): Promise<WalletInfo>;
|
|
33
|
+
status(): Promise<WalletStatus>;
|
|
34
|
+
balance(): Promise<Balance>;
|
|
35
|
+
createWallet(req: CreateWalletRequest): Promise<CreateWalletResult>;
|
|
36
|
+
unlockWallet(req: UnlockWalletRequest): Promise<UnlockWalletResult>;
|
|
37
|
+
openWalletFromPasskey(req: OpenWalletFromPasskeyRequest): Promise<OpenWalletFromPasskeyResult>;
|
|
38
|
+
deposit(req?: DepositRequest): Promise<DepositResult>;
|
|
39
|
+
receive(req: ReceiveRequest): Promise<ReceiveResult>;
|
|
40
|
+
prepareSend(req: SendRequest): Promise<PrepareSendResult>;
|
|
41
|
+
sendPrepared(prepared: PrepareSendResult): Promise<SendResult>;
|
|
42
|
+
send(req: SendRequest): Promise<SendResult>;
|
|
43
|
+
list(req?: ListRequest): Promise<ListResult>;
|
|
44
|
+
exit(req: ExitRequest): Promise<ExitResult>;
|
|
45
|
+
exitStatus(req: ExitStatusRequest): Promise<ExitStatusResult>;
|
|
46
|
+
exitSummary(req?: ExitSummaryRequest): Promise<ExitSummaryResult>;
|
|
47
|
+
getExitPlan(req: GetExitPlanRequest): Promise<GetExitPlanResult>;
|
|
48
|
+
sweepWallet(req: SweepWalletRequest): Promise<SweepWalletResult>;
|
|
49
|
+
subscribe(listener: WavelengthListener): () => void;
|
|
50
|
+
protected emit(event: WavelengthEvent): void;
|
|
51
|
+
protected normalizeActivityEntry(raw: unknown): Entry;
|
|
52
|
+
/**
|
|
53
|
+
* Closes the activity stream and unsubscribes all listeners. The concrete
|
|
54
|
+
* transports override this to also tear down their runtime (terminate the
|
|
55
|
+
* Worker, or drop the main-thread runtime listener).
|
|
56
|
+
*/
|
|
57
|
+
dispose(): void;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=base-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-client.d.ts","sourceRoot":"","sources":["../src/base-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,4BAA4B,EAC5B,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,OAAO,EACP,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,2BAA2B,EAC3B,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EACn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E,kBAAkB,GAAG,MAAM,IAAI;IAQnD,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,eAAe;IAkBrC,SAAS,CAAC,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK;IAIrD;;;;OAIG;IACH,OAAO,IAAI,IAAI;CAIhB"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { validateRuntimeConfig } from "./config.js";
|
|
2
|
+
import { assertFacadeMethod, toGoCreateWalletReq, toGoUnlockWalletReq, toMobileConfig, } from "./facade.js";
|
|
3
|
+
import { errorMessage } from "./errors.js";
|
|
4
|
+
import { normalizeEntry, normalizeFacadeResult, } from "./response-normalization.js";
|
|
5
|
+
import { validateActivityStreamOptions, } from "./activity-options.js";
|
|
6
|
+
/**
|
|
7
|
+
* Implements the transport-agnostic half of {@link WavelengthClient}: every RPC
|
|
8
|
+
* verb is expressed in terms of the abstract invokeFacade, so a transport (web
|
|
9
|
+
* wasm, React Native gomobile, or a future one) supplies only the pipe:
|
|
10
|
+
* invokeFacade, ready, the activity-stream plumbing, and its {@link ServerTransport}
|
|
11
|
+
* flavor. The shared subscribe/emit listener machinery and typed wrappers live
|
|
12
|
+
* here. The facade catalog, public contract, native dispatch, and response
|
|
13
|
+
* normalization remain separate synchronization points.
|
|
14
|
+
*/
|
|
15
|
+
export class BaseWavelengthClient {
|
|
16
|
+
listeners = new Set();
|
|
17
|
+
async callFacade(method, params = {}) {
|
|
18
|
+
assertFacadeMethod(method);
|
|
19
|
+
const raw = await this.invokeFacade(method, params);
|
|
20
|
+
return normalizeFacadeResult(method, raw);
|
|
21
|
+
}
|
|
22
|
+
isRunning() {
|
|
23
|
+
return this.callFacade('isRunning');
|
|
24
|
+
}
|
|
25
|
+
async startActivity(opts = {}) {
|
|
26
|
+
validateActivityStreamOptions(opts);
|
|
27
|
+
await this.openActivityStream(opts);
|
|
28
|
+
}
|
|
29
|
+
// start boots the embedded daemon and returns the post-boot WalletInfo. The
|
|
30
|
+
// facade's start verb resolves nothing useful on its own, so the client
|
|
31
|
+
// fetches getInfo afterwards; the React provider derives the runtime phase
|
|
32
|
+
// from it.
|
|
33
|
+
async start(config) {
|
|
34
|
+
validateRuntimeConfig(config, this.serverTransport);
|
|
35
|
+
await this.callFacade('start', toMobileConfig(config, this.serverTransport));
|
|
36
|
+
return this.getInfo();
|
|
37
|
+
}
|
|
38
|
+
async stop() {
|
|
39
|
+
await this.callFacade('stop');
|
|
40
|
+
this.emit({ type: 'runtimeStopped' });
|
|
41
|
+
}
|
|
42
|
+
getInfo() {
|
|
43
|
+
return this.callFacade('getInfo');
|
|
44
|
+
}
|
|
45
|
+
status() {
|
|
46
|
+
return this.callFacade('status');
|
|
47
|
+
}
|
|
48
|
+
balance() {
|
|
49
|
+
// The daemon's Balance shape; generated.ts is the field source of truth.
|
|
50
|
+
return this.callFacade('balance');
|
|
51
|
+
}
|
|
52
|
+
createWallet(req) {
|
|
53
|
+
return this.callFacade('createWallet', toGoCreateWalletReq(req));
|
|
54
|
+
}
|
|
55
|
+
unlockWallet(req) {
|
|
56
|
+
return this.callFacade('unlockWallet', toGoUnlockWalletReq(req));
|
|
57
|
+
}
|
|
58
|
+
openWalletFromPasskey(req) {
|
|
59
|
+
return this.callFacade('openWalletFromPasskey', req);
|
|
60
|
+
}
|
|
61
|
+
deposit(req = {}) {
|
|
62
|
+
return this.callFacade('deposit', req);
|
|
63
|
+
}
|
|
64
|
+
receive(req) {
|
|
65
|
+
return this.callFacade('receive', req);
|
|
66
|
+
}
|
|
67
|
+
// prepareSend quotes a payment without dispatching it, returning the fee and a
|
|
68
|
+
// single-use sendIntentId. Pair it with sendPrepared for a quote -> confirm ->
|
|
69
|
+
// pay flow; send() folds the two steps into one.
|
|
70
|
+
prepareSend(req) {
|
|
71
|
+
return this.callFacade('prepareSend', req);
|
|
72
|
+
}
|
|
73
|
+
// sendPrepared dispatches a payment quoted by prepareSend. It folds the
|
|
74
|
+
// prepare-time paymentHash into the result so a two-step caller sees the same
|
|
75
|
+
// shape send() returns (the daemon omits PaymentHash from sendPrepared).
|
|
76
|
+
async sendPrepared(prepared) {
|
|
77
|
+
const result = await this.callFacade('sendPrepared', {
|
|
78
|
+
SendIntentID: prepared.sendIntentId,
|
|
79
|
+
});
|
|
80
|
+
return {
|
|
81
|
+
...result,
|
|
82
|
+
paymentHash: result.paymentHash ?? prepared.paymentHash,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
// send composes prepareSend + sendPrepared into one call for the common
|
|
86
|
+
// fire-and-forget path.
|
|
87
|
+
async send(req) {
|
|
88
|
+
return this.sendPrepared(await this.prepareSend(req));
|
|
89
|
+
}
|
|
90
|
+
list(req = {}) {
|
|
91
|
+
return this.callFacade('list', req);
|
|
92
|
+
}
|
|
93
|
+
exit(req) {
|
|
94
|
+
return this.callFacade('exit', req);
|
|
95
|
+
}
|
|
96
|
+
exitStatus(req) {
|
|
97
|
+
return this.callFacade('exitStatus', req);
|
|
98
|
+
}
|
|
99
|
+
exitSummary(req = {}) {
|
|
100
|
+
return this.callFacade('exitSummary', req);
|
|
101
|
+
}
|
|
102
|
+
getExitPlan(req) {
|
|
103
|
+
return this.callFacade('getExitPlan', req);
|
|
104
|
+
}
|
|
105
|
+
sweepWallet(req) {
|
|
106
|
+
return this.callFacade('sweepWallet', req);
|
|
107
|
+
}
|
|
108
|
+
subscribe(listener) {
|
|
109
|
+
this.listeners.add(listener);
|
|
110
|
+
return () => {
|
|
111
|
+
this.listeners.delete(listener);
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
emit(event) {
|
|
115
|
+
for (const listener of this.listeners) {
|
|
116
|
+
try {
|
|
117
|
+
listener(event);
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
// Isolate a throwing subscriber so it cannot suppress the others or
|
|
121
|
+
// abort the transport's event dispatch. Reported as a log event
|
|
122
|
+
// unless the log listener itself is the one that threw.
|
|
123
|
+
if (event.type !== 'log') {
|
|
124
|
+
this.emit({
|
|
125
|
+
type: 'log',
|
|
126
|
+
payload: { level: 'error', message: errorMessage(err) },
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
normalizeActivityEntry(raw) {
|
|
133
|
+
return normalizeEntry(raw);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Closes the activity stream and unsubscribes all listeners. The concrete
|
|
137
|
+
* transports override this to also tear down their runtime (terminate the
|
|
138
|
+
* Worker, or drop the main-thread runtime listener).
|
|
139
|
+
*/
|
|
140
|
+
dispose() {
|
|
141
|
+
this.stopActivity();
|
|
142
|
+
this.listeners.clear();
|
|
143
|
+
}
|
|
144
|
+
}
|
package/dist/casing.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"casing.d.ts","sourceRoot":"","sources":["../src/casing.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAIpD,CAAC;AAIF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAU7C;AAKD,wBAAgB,YAAY,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAE3D"}
|
package/dist/casing.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Shared PascalCase -> camelCase logic, used by BOTH the type generator
|
|
2
|
+
// (scripts/gen-types.mts, at build time) and the runtime response mapping
|
|
3
|
+
// (the shared base client, after transport invocation). One implementation
|
|
4
|
+
// guarantees the generated types and the values the client returns always agree.
|
|
5
|
+
// ACRONYM_OVERRIDES holds field names where a plain lowercase-first-letter would
|
|
6
|
+
// read wrong. Extend this when a new acronym-led field appears (a stale entry is
|
|
7
|
+
// harmless -- the name just falls back to lowercase-first).
|
|
8
|
+
export const ACRONYM_OVERRIDES = {
|
|
9
|
+
ID: 'id',
|
|
10
|
+
VTXOs: 'vtxos',
|
|
11
|
+
SendIntentID: 'sendIntentId',
|
|
12
|
+
};
|
|
13
|
+
// camelKey converts one Go/PascalCase field name to camelCase. Most names just
|
|
14
|
+
// lowercase the first letter; ACRONYM_OVERRIDES covers the few that need more.
|
|
15
|
+
export function camelKey(name) {
|
|
16
|
+
if (Object.prototype.hasOwnProperty.call(ACRONYM_OVERRIDES, name)) {
|
|
17
|
+
return ACRONYM_OVERRIDES[name];
|
|
18
|
+
}
|
|
19
|
+
if (!name) {
|
|
20
|
+
return name;
|
|
21
|
+
}
|
|
22
|
+
return name.charAt(0).toLowerCase() + name.slice(1);
|
|
23
|
+
}
|
|
24
|
+
// camelizeKeys recursively rewrites object keys to camelCase via camelKey.
|
|
25
|
+
// Arrays are walked; primitives pass through unchanged. This maps the daemon's
|
|
26
|
+
// PascalCase JSON responses onto the SDK's camelCase public shapes.
|
|
27
|
+
export function camelizeKeys(value) {
|
|
28
|
+
return camelize(value);
|
|
29
|
+
}
|
|
30
|
+
function camelize(value) {
|
|
31
|
+
if (Array.isArray(value)) {
|
|
32
|
+
return value.map(camelize);
|
|
33
|
+
}
|
|
34
|
+
if (value && typeof value === 'object') {
|
|
35
|
+
const out = {};
|
|
36
|
+
for (const [key, val] of Object.entries(value)) {
|
|
37
|
+
out[camelKey(key)] = camelize(val);
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { WavelengthListener } from './events.ts';
|
|
2
|
+
import type { RuntimeConfig } from './config.ts';
|
|
3
|
+
import type { FacadeMethod } from './facade.ts';
|
|
4
|
+
import type { WalletInfo, WalletStatus } from './state.ts';
|
|
5
|
+
import type { ActivityStreamOptions } from './activity-options.ts';
|
|
6
|
+
import type { CreateWalletRequest, DepositRequest, ExitRequest, ExitStatusRequest, ExitSummaryRequest, GetExitPlanRequest, ListRequest, OpenWalletFromPasskeyRequest, ReceiveRequest, SendRequest, SweepWalletRequest, UnlockWalletRequest } from './requests.ts';
|
|
7
|
+
import type { Balance, CreateWalletResult, DepositResult, ExitResult, ExitStatusResult, ExitSummaryResult, GetExitPlanResult, ListResult, OpenWalletFromPasskeyResult, PrepareSendResult, ReceiveResult, SendResult, SweepWalletResult, UnlockWalletResult } from './results.ts';
|
|
8
|
+
/**
|
|
9
|
+
* The framework-agnostic contract every Wavelength transport implements. It wraps
|
|
10
|
+
* the embedded daemon's lifecycle, wallet operations, and activity stream behind
|
|
11
|
+
* typed, camelCase-normalized methods.
|
|
12
|
+
*/
|
|
13
|
+
export interface WavelengthClient {
|
|
14
|
+
/** Resolves once the runtime assets are loaded and the client is usable. */
|
|
15
|
+
ready(): Promise<void>;
|
|
16
|
+
/** Starts the embedded daemon with the given config and resolves with its initial info. */
|
|
17
|
+
start(config: RuntimeConfig): Promise<WalletInfo>;
|
|
18
|
+
/** Stops the embedded daemon. */
|
|
19
|
+
stop(): Promise<void>;
|
|
20
|
+
/** Returns the current normalized wallet info. */
|
|
21
|
+
getInfo(): Promise<WalletInfo>;
|
|
22
|
+
/** Returns the daemon's runtime status snapshot. */
|
|
23
|
+
status(): Promise<WalletStatus>;
|
|
24
|
+
/** Returns the current wallet balance. */
|
|
25
|
+
balance(): Promise<Balance>;
|
|
26
|
+
/** Creates a new wallet from the given request. */
|
|
27
|
+
createWallet(req: CreateWalletRequest): Promise<CreateWalletResult>;
|
|
28
|
+
/** Unlocks an existing wallet with the given password. */
|
|
29
|
+
unlockWallet(req: UnlockWalletRequest): Promise<UnlockWalletResult>;
|
|
30
|
+
/** Opens a wallet from a passkey assertion. */
|
|
31
|
+
openWalletFromPasskey(req: OpenWalletFromPasskeyRequest): Promise<OpenWalletFromPasskeyResult>;
|
|
32
|
+
/** Generates an on-chain deposit address. */
|
|
33
|
+
deposit(req?: DepositRequest): Promise<DepositResult>;
|
|
34
|
+
/** Generates a receive invoice for the requested amount. */
|
|
35
|
+
receive(req: ReceiveRequest): Promise<ReceiveResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Quotes a payment without dispatching it: it returns the fee and a single-use
|
|
38
|
+
* sendIntentId. Pair it with {@link sendPrepared} for a quote -> confirm -> pay
|
|
39
|
+
* flow; {@link send} folds the two steps into one call.
|
|
40
|
+
*/
|
|
41
|
+
prepareSend(req: SendRequest): Promise<PrepareSendResult>;
|
|
42
|
+
/** Dispatches a payment previously quoted by {@link prepareSend}. */
|
|
43
|
+
sendPrepared(prepared: PrepareSendResult): Promise<SendResult>;
|
|
44
|
+
/** Quotes and dispatches a payment in a single call. */
|
|
45
|
+
send(req: SendRequest): Promise<SendResult>;
|
|
46
|
+
/** Lists wallet activity or UTXOs per the request. */
|
|
47
|
+
list(req?: ListRequest): Promise<ListResult>;
|
|
48
|
+
/** Exits a single outpoint, attempting a cooperative leave to the optional destination. */
|
|
49
|
+
exit(req: ExitRequest): Promise<ExitResult>;
|
|
50
|
+
/** Queries the status of an exit. */
|
|
51
|
+
exitStatus(req: ExitStatusRequest): Promise<ExitStatusResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Summarizes all in-progress exits: one entry per active exit plus
|
|
54
|
+
* wallet-wide totals for the amount being recovered, the estimated fees, and
|
|
55
|
+
* the estimated net recoverable. Completed and failed exits are omitted.
|
|
56
|
+
*/
|
|
57
|
+
exitSummary(req?: ExitSummaryRequest): Promise<ExitSummaryResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Previews unilateral-exit readiness (and the backing-wallet funding required)
|
|
60
|
+
* for a set of VTXO outpoints, without moving funds.
|
|
61
|
+
*/
|
|
62
|
+
getExitPlan(req: GetExitPlanRequest): Promise<GetExitPlanResult>;
|
|
63
|
+
/**
|
|
64
|
+
* Previews or broadcasts a sweep of the backing wallet. Call it with
|
|
65
|
+
* `broadcast: false` first to preview; `broadcast: true` moves funds.
|
|
66
|
+
*/
|
|
67
|
+
sweepWallet(req: SweepWalletRequest): Promise<SweepWalletResult>;
|
|
68
|
+
/** Invokes a portable daemon facade method with a normalized response. */
|
|
69
|
+
callFacade<T = unknown>(method: FacadeMethod, params?: unknown): Promise<T>;
|
|
70
|
+
/** Reports whether the embedded daemon is running. */
|
|
71
|
+
isRunning(): Promise<boolean>;
|
|
72
|
+
/** Subscribes a listener to runtime events; returns an unsubscribe function. */
|
|
73
|
+
subscribe(listener: WavelengthListener): () => void;
|
|
74
|
+
/**
|
|
75
|
+
* Opens the wallet activity stream and forwards each entry to subscribers as an
|
|
76
|
+
* `'activity'` event until {@link stopActivity} is called.
|
|
77
|
+
*/
|
|
78
|
+
startActivity(opts?: ActivityStreamOptions): Promise<void>;
|
|
79
|
+
/** Closes the activity stream opened by {@link startActivity}. */
|
|
80
|
+
stopActivity(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Releases the client's resources and unsubscribes all listeners: it closes
|
|
83
|
+
* the activity stream, and transports tear down their runtime resources (the
|
|
84
|
+
* web transport terminates its Worker; the native transport removes its
|
|
85
|
+
* event subscription). The client is unusable afterward; build a new one to
|
|
86
|
+
* start again.
|
|
87
|
+
*/
|
|
88
|
+
dispose(): void;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EACV,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,4BAA4B,EAC5B,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G;IACH,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { ServerTransport } from './facade.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Selects the Bitcoin network the embedded daemon runs against. Names match
|
|
4
|
+
* the daemon's network selector: 'testnet' is Bitcoin testnet3 and 'testnet4'
|
|
5
|
+
* is Bitcoin testnet4.
|
|
6
|
+
*/
|
|
7
|
+
export type Network = 'mainnet' | 'testnet' | 'testnet4' | 'signet' | 'regtest';
|
|
8
|
+
/**
|
|
9
|
+
* The networks that carry a public endpoint preset, and so can be passed to a
|
|
10
|
+
* transport package's defaultConfig helper. mainnet and regtest are excluded:
|
|
11
|
+
* mainnet has no public deployment yet, and regtest's ports vary per
|
|
12
|
+
* development environment. A {@link RuntimeConfig} for either is built by hand.
|
|
13
|
+
*/
|
|
14
|
+
export type PresetNetwork = 'testnet' | 'testnet4' | 'signet';
|
|
15
|
+
/**
|
|
16
|
+
* The daemon log verbosity levels accepted by {@link RuntimeConfig.debugLevel},
|
|
17
|
+
* from most to least verbose. Exported for UIs that render a level picker.
|
|
18
|
+
* debugLevel itself stays a plain string because the daemon also accepts a
|
|
19
|
+
* per-subsystem list such as 'ROND=debug,info'.
|
|
20
|
+
*/
|
|
21
|
+
export declare const DEBUG_LEVELS: readonly ["trace", "debug", "info", "warn", "error", "critical", "off"];
|
|
22
|
+
/** One of the daemon log verbosity levels in {@link DEBUG_LEVELS}. */
|
|
23
|
+
export type DebugLevel = (typeof DEBUG_LEVELS)[number];
|
|
24
|
+
/**
|
|
25
|
+
* The configuration passed to `client.start()`. For the common case prefer
|
|
26
|
+
* the defaultConfig helper exported by your transport package (wavelength-web
|
|
27
|
+
* or wavelength-react-native), which preloads the canonical public endpoints
|
|
28
|
+
* in that transport's flavor, and override only the fields you need.
|
|
29
|
+
*/
|
|
30
|
+
export type RuntimeConfig = {
|
|
31
|
+
/** The Bitcoin network to run against. `mainnet` also requires {@link allowMainnet}. */
|
|
32
|
+
network?: Network;
|
|
33
|
+
/** Explicitly permits mainnet. The SDK rejects mainnet configs unless this is true. */
|
|
34
|
+
allowMainnet?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Storage root for daemon and wallet state. This is an OPFS path on web and
|
|
37
|
+
* a filesystem path on React Native. The daemon chooses a default when unset.
|
|
38
|
+
*/
|
|
39
|
+
dataDir?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Daemon log verbosity. Accepts a standard {@link DebugLevel} or a
|
|
42
|
+
* per-subsystem expression such as `ROND=debug,info`.
|
|
43
|
+
*/
|
|
44
|
+
debugLevel?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Ark operator and mailbox endpoint. Use a REST URL on web and a `host:port`
|
|
47
|
+
* gRPC address on React Native. The daemon network default is used when unset.
|
|
48
|
+
*/
|
|
49
|
+
arkServerAddress?: string;
|
|
50
|
+
/** Filesystem path to an Ark TLS certificate. The web transport rejects it. */
|
|
51
|
+
arkServerTlsCertPath?: string;
|
|
52
|
+
/** Disables TLS for the Ark endpoint. Use only for local development. */
|
|
53
|
+
arkServerInsecure?: boolean;
|
|
54
|
+
/** Embedded wallet backend. Defaults to `lwwallet`. */
|
|
55
|
+
walletType?: 'lwwallet' | 'btcwallet';
|
|
56
|
+
/** HTTP Esplora endpoint used by the `lwwallet` backend on both platforms. */
|
|
57
|
+
walletEsploraUrl?: string;
|
|
58
|
+
/** Password file used by `lwwallet` to unlock automatically. */
|
|
59
|
+
walletPasswordFile?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Chain polling interval in seconds for `lwwallet`. Must be a nonnegative
|
|
62
|
+
* safe integer.
|
|
63
|
+
*/
|
|
64
|
+
walletPollIntervalSeconds?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Wallet address look-ahead window for either backend. Must be a
|
|
67
|
+
* nonnegative safe integer that fits in a uint32.
|
|
68
|
+
*/
|
|
69
|
+
walletRecoveryWindow?: number;
|
|
70
|
+
/** Fee estimator endpoint used by the `btcwallet` backend. */
|
|
71
|
+
walletFeeUrl?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Local file path or HTTP(S) URL from which `btcwallet` imports block
|
|
74
|
+
* headers on startup.
|
|
75
|
+
*/
|
|
76
|
+
walletBlockHeadersSource?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Local file path or HTTP(S) URL from which `btcwallet` imports compact
|
|
79
|
+
* filter headers on startup.
|
|
80
|
+
*/
|
|
81
|
+
walletFilterHeadersSource?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Lightning swap endpoint. Use a REST URL on web and a `host:port` gRPC
|
|
84
|
+
* address on React Native. The daemon network default is used when unset.
|
|
85
|
+
*/
|
|
86
|
+
swapServerAddress?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Filesystem path to a swap-server TLS certificate. Web rejects it unless
|
|
89
|
+
* swaps are disabled, in which case every swap field is omitted.
|
|
90
|
+
*/
|
|
91
|
+
swapServerTlsCertPath?: string;
|
|
92
|
+
/** Disables TLS for the swap endpoint. Use only for local development. */
|
|
93
|
+
swapServerInsecure?: boolean;
|
|
94
|
+
/** Path to the daemon-owned SQLite database that stores swap state. */
|
|
95
|
+
swapDatabaseFileName?: string;
|
|
96
|
+
/** Disables Lightning swaps and omits every swap configuration field. */
|
|
97
|
+
disableSwaps?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Maximum per-round operator fee the daemon accepts, in satoshis. Must be a
|
|
100
|
+
* nonnegative safe integer.
|
|
101
|
+
*/
|
|
102
|
+
maxOperatorFeeSat?: number;
|
|
103
|
+
/**
|
|
104
|
+
* Maximum concurrent VTXO signing sessions. Zero selects the wallet-backend
|
|
105
|
+
* default and one forces serial signing.
|
|
106
|
+
*/
|
|
107
|
+
signingWorkers?: number;
|
|
108
|
+
/** Bufconn listener buffer size override. Must be a nonnegative safe integer. */
|
|
109
|
+
bufferSize?: number;
|
|
110
|
+
};
|
|
111
|
+
/** Validates host-owned runtime settings before the typed start dispatches. */
|
|
112
|
+
export declare function validateRuntimeConfig(config: RuntimeConfig, transport: ServerTransport): void;
|
|
113
|
+
/**
|
|
114
|
+
* Returns the canonical public endpoint preset for a network in one
|
|
115
|
+
* transport's flavor: REST gateway URLs for 'rest' (the web transport),
|
|
116
|
+
* host:port gRPC addresses for 'grpc' (native transports). This is the
|
|
117
|
+
* building block the transport packages' defaultConfig helpers compose over;
|
|
118
|
+
* app code normally calls those instead.
|
|
119
|
+
*
|
|
120
|
+
* Only the preset networks are accepted (see {@link PresetNetwork}); mainnet
|
|
121
|
+
* and regtest have no preset and their {@link RuntimeConfig} is built by hand.
|
|
122
|
+
*
|
|
123
|
+
* @param network - The Bitcoin network to look up.
|
|
124
|
+
* @param transport - The endpoint flavor the caller's transport dials.
|
|
125
|
+
* @returns The preset config fields for that network and transport.
|
|
126
|
+
*/
|
|
127
|
+
export declare function networkDefaults(network: PresetNetwork, transport: ServerTransport): Partial<RuntimeConfig>;
|
|
128
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD;;;;GAIG;AACH,MAAM,MAAM,OAAO,GACf,SAAS,GACT,SAAS,GACT,UAAU,GACV,QAAQ,GACR,SAAS,CAAC;AAEd;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE9D;;;;;GAKG;AACH,eAAO,MAAM,YAAY,yEAQf,CAAC;AAEX,sEAAsE;AACtE,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,wFAAwF;IACxF,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