@arkade-os/sdk 0.4.15 → 0.4.17
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/README.md +102 -96
- package/dist/cjs/arkfee/estimator.js +1 -1
- package/dist/cjs/arkfee/types.js +2 -1
- package/dist/cjs/arknote/index.js +43 -4
- package/dist/cjs/bip322/index.js +1 -1
- package/dist/cjs/contracts/arkcontract.js +1 -1
- package/dist/cjs/contracts/contractManager.js +60 -28
- package/dist/cjs/contracts/contractWatcher.js +29 -22
- package/dist/cjs/contracts/handlers/default.js +1 -1
- package/dist/cjs/contracts/handlers/delegate.js +1 -1
- package/dist/cjs/contracts/handlers/helpers.js +1 -1
- package/dist/cjs/extension/asset/assetGroup.js +92 -5
- package/dist/cjs/extension/asset/assetId.js +67 -3
- package/dist/cjs/extension/asset/assetInput.js +18 -0
- package/dist/cjs/extension/asset/assetOutput.js +15 -0
- package/dist/cjs/extension/asset/assetRef.js +66 -0
- package/dist/cjs/extension/asset/metadata.js +15 -0
- package/dist/cjs/extension/asset/packet.js +4 -1
- package/dist/cjs/extension/index.js +1 -1
- package/dist/cjs/forfeit.js +14 -0
- package/dist/cjs/identity/seedIdentity.js +2 -2
- package/dist/cjs/identity/singleKey.js +4 -0
- package/dist/cjs/intent/index.js +28 -12
- package/dist/cjs/providers/ark.js +3 -2
- package/dist/cjs/providers/delegator.js +20 -1
- package/dist/cjs/providers/expoArk.js +2 -2
- package/dist/cjs/providers/indexer.js +2 -2
- package/dist/cjs/providers/onchain.js +2 -1
- package/dist/cjs/repositories/realm/schemas.js +2 -2
- package/dist/cjs/repositories/realm/types.js +1 -1
- package/dist/cjs/script/address.js +37 -6
- package/dist/cjs/script/base.js +70 -1
- package/dist/cjs/script/default.js +3 -0
- package/dist/cjs/script/delegate.js +4 -0
- package/dist/cjs/script/tapscript.js +17 -2
- package/dist/cjs/script/vhtlc.js +35 -27
- package/dist/cjs/storage/fileSystem.js +1 -1
- package/dist/cjs/storage/inMemory.js +1 -1
- package/dist/cjs/storage/indexedDB.js +1 -1
- package/dist/cjs/storage/localStorage.js +1 -1
- package/dist/cjs/tree/validation.js +1 -1
- package/dist/cjs/utils/arkTransaction.js +5 -5
- package/dist/cjs/utils/bip21.js +16 -3
- package/dist/cjs/utils/syncCursors.js +4 -4
- package/dist/cjs/utils/transaction.js +1 -1
- package/dist/cjs/utils/transactionHistory.js +11 -11
- package/dist/cjs/utils/unknownFields.js +3 -3
- package/dist/cjs/wallet/asset-manager.js +4 -4
- package/dist/cjs/wallet/batch.js +5 -5
- package/dist/cjs/wallet/delegator.js +9 -8
- package/dist/cjs/wallet/expo/background.js +3 -3
- package/dist/cjs/wallet/expo/wallet.js +7 -7
- package/dist/cjs/wallet/index.js +43 -0
- package/dist/cjs/wallet/onchain.js +43 -5
- package/dist/cjs/wallet/ramps.js +44 -14
- package/dist/cjs/wallet/serviceWorker/wallet-message-handler.js +22 -22
- package/dist/cjs/wallet/serviceWorker/wallet.js +28 -24
- package/dist/cjs/wallet/unroll.js +12 -8
- package/dist/cjs/wallet/utils.js +1 -1
- package/dist/cjs/wallet/vtxo-manager.js +122 -82
- package/dist/cjs/wallet/wallet.js +140 -77
- package/dist/cjs/worker/expo/asyncStorageTaskQueue.js +1 -1
- package/dist/cjs/worker/expo/processors/contractPollProcessor.js +2 -2
- package/dist/cjs/worker/expo/taskRunner.js +3 -3
- package/dist/cjs/worker/messageBus.js +3 -0
- package/dist/esm/arkfee/estimator.js +1 -1
- package/dist/esm/arkfee/types.js +2 -1
- package/dist/esm/arknote/index.js +43 -4
- package/dist/esm/bip322/index.js +1 -1
- package/dist/esm/contracts/arkcontract.js +1 -1
- package/dist/esm/contracts/contractManager.js +60 -28
- package/dist/esm/contracts/contractWatcher.js +29 -22
- package/dist/esm/contracts/handlers/default.js +1 -1
- package/dist/esm/contracts/handlers/delegate.js +1 -1
- package/dist/esm/contracts/handlers/helpers.js +1 -1
- package/dist/esm/extension/asset/assetGroup.js +92 -5
- package/dist/esm/extension/asset/assetId.js +67 -3
- package/dist/esm/extension/asset/assetInput.js +18 -0
- package/dist/esm/extension/asset/assetOutput.js +15 -0
- package/dist/esm/extension/asset/assetRef.js +66 -0
- package/dist/esm/extension/asset/metadata.js +15 -0
- package/dist/esm/extension/asset/packet.js +4 -1
- package/dist/esm/extension/index.js +1 -1
- package/dist/esm/forfeit.js +14 -0
- package/dist/esm/identity/seedIdentity.js +2 -2
- package/dist/esm/identity/singleKey.js +4 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/intent/index.js +28 -12
- package/dist/esm/providers/ark.js +3 -2
- package/dist/esm/providers/delegator.js +20 -1
- package/dist/esm/providers/expoArk.js +2 -2
- package/dist/esm/providers/indexer.js +2 -2
- package/dist/esm/providers/onchain.js +2 -1
- package/dist/esm/repositories/realm/schemas.js +2 -2
- package/dist/esm/repositories/realm/types.js +1 -1
- package/dist/esm/script/address.js +37 -6
- package/dist/esm/script/base.js +70 -1
- package/dist/esm/script/default.js +3 -0
- package/dist/esm/script/delegate.js +4 -0
- package/dist/esm/script/tapscript.js +17 -2
- package/dist/esm/script/vhtlc.js +35 -27
- package/dist/esm/storage/fileSystem.js +1 -1
- package/dist/esm/storage/inMemory.js +1 -1
- package/dist/esm/storage/indexedDB.js +1 -1
- package/dist/esm/storage/localStorage.js +1 -1
- package/dist/esm/tree/validation.js +1 -1
- package/dist/esm/utils/arkTransaction.js +5 -5
- package/dist/esm/utils/bip21.js +16 -3
- package/dist/esm/utils/syncCursors.js +4 -4
- package/dist/esm/utils/transaction.js +1 -1
- package/dist/esm/utils/transactionHistory.js +11 -11
- package/dist/esm/utils/unknownFields.js +3 -3
- package/dist/esm/wallet/asset-manager.js +4 -4
- package/dist/esm/wallet/batch.js +5 -5
- package/dist/esm/wallet/delegator.js +9 -8
- package/dist/esm/wallet/expo/background.js +3 -3
- package/dist/esm/wallet/expo/wallet.js +7 -7
- package/dist/esm/wallet/index.js +43 -0
- package/dist/esm/wallet/onchain.js +43 -5
- package/dist/esm/wallet/ramps.js +44 -14
- package/dist/esm/wallet/serviceWorker/wallet-message-handler.js +22 -22
- package/dist/esm/wallet/serviceWorker/wallet.js +28 -24
- package/dist/esm/wallet/unroll.js +12 -8
- package/dist/esm/wallet/utils.js +1 -1
- package/dist/esm/wallet/vtxo-manager.js +121 -81
- package/dist/esm/wallet/wallet.js +140 -77
- package/dist/esm/worker/expo/asyncStorageTaskQueue.js +1 -1
- package/dist/esm/worker/expo/processors/contractPollProcessor.js +2 -2
- package/dist/esm/worker/expo/taskRunner.js +3 -3
- package/dist/esm/worker/messageBus.js +3 -0
- package/dist/types/arkfee/estimator.d.ts +1 -1
- package/dist/types/arkfee/types.d.ts +2 -1
- package/dist/types/arknote/index.d.ts +44 -4
- package/dist/types/bip322/index.d.ts +1 -1
- package/dist/types/contracts/arkcontract.d.ts +1 -1
- package/dist/types/contracts/contractManager.d.ts +39 -65
- package/dist/types/contracts/contractWatcher.d.ts +39 -18
- package/dist/types/contracts/handlers/default.d.ts +1 -1
- package/dist/types/contracts/handlers/delegate.d.ts +1 -1
- package/dist/types/contracts/handlers/helpers.d.ts +1 -1
- package/dist/types/contracts/types.d.ts +36 -26
- package/dist/types/extension/asset/assetGroup.d.ts +92 -1
- package/dist/types/extension/asset/assetId.d.ts +67 -3
- package/dist/types/extension/asset/assetInput.d.ts +18 -0
- package/dist/types/extension/asset/assetOutput.d.ts +15 -0
- package/dist/types/extension/asset/assetRef.d.ts +66 -0
- package/dist/types/extension/asset/metadata.d.ts +15 -0
- package/dist/types/extension/asset/packet.d.ts +4 -1
- package/dist/types/extension/index.d.ts +1 -1
- package/dist/types/forfeit.d.ts +14 -0
- package/dist/types/identity/index.d.ts +16 -0
- package/dist/types/identity/seedIdentity.d.ts +8 -6
- package/dist/types/identity/singleKey.d.ts +4 -0
- package/dist/types/intent/index.d.ts +19 -6
- package/dist/types/providers/ark.d.ts +40 -2
- package/dist/types/providers/delegator.d.ts +54 -1
- package/dist/types/providers/expoArk.d.ts +2 -2
- package/dist/types/providers/indexer.d.ts +105 -2
- package/dist/types/providers/onchain.d.ts +62 -1
- package/dist/types/repositories/realm/schemas.d.ts +2 -2
- package/dist/types/repositories/realm/types.d.ts +2 -2
- package/dist/types/repositories/walletRepository.d.ts +16 -0
- package/dist/types/script/address.d.ts +35 -2
- package/dist/types/script/base.d.ts +66 -1
- package/dist/types/script/default.d.ts +3 -0
- package/dist/types/script/delegate.d.ts +4 -0
- package/dist/types/script/tapscript.d.ts +17 -2
- package/dist/types/script/vhtlc.d.ts +35 -27
- package/dist/types/storage/fileSystem.d.ts +1 -1
- package/dist/types/storage/inMemory.d.ts +1 -1
- package/dist/types/storage/index.d.ts +1 -1
- package/dist/types/storage/indexedDB.d.ts +1 -1
- package/dist/types/storage/localStorage.d.ts +1 -1
- package/dist/types/utils/arkTransaction.d.ts +3 -3
- package/dist/types/utils/bip21.d.ts +17 -0
- package/dist/types/utils/syncCursors.d.ts +4 -4
- package/dist/types/utils/transaction.d.ts +1 -1
- package/dist/types/utils/transactionHistory.d.ts +3 -3
- package/dist/types/utils/unknownFields.d.ts +5 -5
- package/dist/types/wallet/asset-manager.d.ts +3 -3
- package/dist/types/wallet/batch.d.ts +27 -7
- package/dist/types/wallet/delegator.d.ts +10 -0
- package/dist/types/wallet/expo/background.d.ts +4 -4
- package/dist/types/wallet/expo/wallet.d.ts +10 -10
- package/dist/types/wallet/index.d.ts +457 -25
- package/dist/types/wallet/onchain.d.ts +42 -4
- package/dist/types/wallet/ramps.d.ts +40 -10
- package/dist/types/wallet/serviceWorker/wallet-message-handler.d.ts +4 -4
- package/dist/types/wallet/serviceWorker/wallet.d.ts +71 -33
- package/dist/types/wallet/unroll.d.ts +8 -6
- package/dist/types/wallet/vtxo-manager.d.ts +146 -93
- package/dist/types/wallet/wallet.d.ts +91 -33
- package/dist/types/worker/expo/asyncStorageTaskQueue.d.ts +1 -1
- package/dist/types/worker/expo/processors/contractPollProcessor.d.ts +1 -1
- package/dist/types/worker/expo/taskRunner.d.ts +6 -6
- package/dist/types/worker/messageBus.d.ts +5 -3
- package/package.json +1 -1
|
@@ -3,8 +3,11 @@ import { TreeNonces, TreePartialSigs } from "../tree/signingSession";
|
|
|
3
3
|
import { Vtxo } from "./indexer";
|
|
4
4
|
import type { IntentFeeConfig } from "../arkfee";
|
|
5
5
|
import { Intent } from "../intent";
|
|
6
|
+
/** Output requested during settlement or transaction submission. */
|
|
6
7
|
export type Output = {
|
|
8
|
+
/** Destination address, either onchain or Arkade (offchain). */
|
|
7
9
|
address: string;
|
|
10
|
+
/** Amount to send in satoshis. */
|
|
8
11
|
amount: bigint;
|
|
9
12
|
};
|
|
10
13
|
export declare enum SettlementEventType {
|
|
@@ -44,6 +47,7 @@ export type TreeNoncesEvent = {
|
|
|
44
47
|
id: string;
|
|
45
48
|
topic: string[];
|
|
46
49
|
txid: string;
|
|
50
|
+
/** Musig2 public nonces keyed by cosigner public key. */
|
|
47
51
|
nonces: TreeNonces;
|
|
48
52
|
};
|
|
49
53
|
export type BatchStartedEvent = {
|
|
@@ -108,53 +112,87 @@ export interface ArkInfo {
|
|
|
108
112
|
sessionDuration: bigint;
|
|
109
113
|
signerPubkey: string;
|
|
110
114
|
unilateralExitDelay: bigint;
|
|
115
|
+
/**
|
|
116
|
+
* Maximum boarding input amount.
|
|
117
|
+
*
|
|
118
|
+
* @remarks
|
|
119
|
+
* `-1` means unlimited, while `0` disables boarding.
|
|
120
|
+
*/
|
|
111
121
|
utxoMaxAmount: bigint;
|
|
112
122
|
utxoMinAmount: bigint;
|
|
113
123
|
version: string;
|
|
124
|
+
/**
|
|
125
|
+
* Maximum virtual output amount.
|
|
126
|
+
*
|
|
127
|
+
* @remarks
|
|
128
|
+
* `-1` means unlimited.
|
|
129
|
+
*/
|
|
114
130
|
vtxoMaxAmount: bigint;
|
|
115
131
|
vtxoMinAmount: bigint;
|
|
116
132
|
}
|
|
133
|
+
/** Signed intent payload sent to the Arkade server. */
|
|
117
134
|
export interface SignedIntent<T extends Intent.Message> {
|
|
135
|
+
/** Base64-encoded signed proof transaction. */
|
|
118
136
|
proof: string;
|
|
137
|
+
/** Intent message payload associated with the proof. */
|
|
119
138
|
message: T;
|
|
120
139
|
}
|
|
140
|
+
/** Transaction notification emitted by the Arkade server stream. */
|
|
121
141
|
export interface TxNotification {
|
|
142
|
+
/** Transaction id. */
|
|
122
143
|
txid: string;
|
|
144
|
+
/** Raw transaction payload. */
|
|
123
145
|
tx: string;
|
|
146
|
+
/** Virtual outputs spent by the transaction. */
|
|
124
147
|
spentVtxos: Vtxo[];
|
|
148
|
+
/** Virtual outputs made spendable by the transaction. */
|
|
125
149
|
spendableVtxos: Vtxo[];
|
|
150
|
+
/** Optional checkpoint transactions associated with the notification. */
|
|
126
151
|
checkpointTxs?: Record<string, {
|
|
127
152
|
txid: string;
|
|
128
153
|
tx: string;
|
|
129
154
|
}>;
|
|
130
155
|
}
|
|
131
156
|
export interface ArkProvider {
|
|
157
|
+
/** Fetch Arkade server configuration and fee settings. */
|
|
132
158
|
getInfo(): Promise<ArkInfo>;
|
|
159
|
+
/** Submit a signed Arkade transaction and its checkpoint transactions. */
|
|
133
160
|
submitTx(signedArkTx: string, checkpointTxs: string[]): Promise<{
|
|
134
161
|
arkTxid: string;
|
|
135
162
|
finalArkTx: string;
|
|
136
163
|
signedCheckpointTxs: string[];
|
|
137
164
|
}>;
|
|
165
|
+
/** Finalize a previously submitted Arkade transaction. */
|
|
138
166
|
finalizeTx(arkTxid: string, finalCheckpointTxs: string[]): Promise<void>;
|
|
167
|
+
/** Register a signed intent with the Arkade server. */
|
|
139
168
|
registerIntent(intent: SignedIntent<Intent.RegisterMessage>): Promise<string>;
|
|
169
|
+
/** Delete a previously registered intent. */
|
|
140
170
|
deleteIntent(intent: SignedIntent<Intent.DeleteMessage>): Promise<void>;
|
|
171
|
+
/** Confirm an already registered intent id. */
|
|
141
172
|
confirmRegistration(intentId: string): Promise<void>;
|
|
173
|
+
/** Submit musig2 tree nonces for a batch signing session. */
|
|
142
174
|
submitTreeNonces(batchId: string, pubkey: string, nonces: TreeNonces): Promise<void>;
|
|
175
|
+
/** Submit musig2 partial signatures for a batch signing session. */
|
|
143
176
|
submitTreeSignatures(batchId: string, pubkey: string, signatures: TreePartialSigs): Promise<void>;
|
|
177
|
+
/** Submit signed forfeit transactions for cooperative settlement. */
|
|
144
178
|
submitSignedForfeitTxs(signedForfeitTxs: string[], signedCommitmentTx?: string): Promise<void>;
|
|
179
|
+
/** Open the settlement event stream for the given topics. */
|
|
145
180
|
getEventStream(signal: AbortSignal, topics: string[]): AsyncIterableIterator<SettlementEvent>;
|
|
181
|
+
/** Stream transaction notifications emitted by the Arkade server. */
|
|
146
182
|
getTransactionsStream(signal: AbortSignal): AsyncIterableIterator<{
|
|
147
183
|
commitmentTx?: TxNotification;
|
|
148
184
|
arkTx?: TxNotification;
|
|
149
185
|
}>;
|
|
186
|
+
/** Fetch pending transactions for a signed get-pending-tx intent. */
|
|
150
187
|
getPendingTxs(intent: SignedIntent<Intent.GetPendingTxMessage>): Promise<PendingTx[]>;
|
|
151
188
|
}
|
|
152
189
|
/**
|
|
153
|
-
* REST-based
|
|
190
|
+
* REST-based Arkade provider implementation.
|
|
191
|
+
*
|
|
154
192
|
* @see https://buf.build/arkade-os/arkd/docs/main:ark.v1#ark.v1.ArkService
|
|
155
193
|
* @example
|
|
156
194
|
* ```typescript
|
|
157
|
-
* const provider = new RestArkProvider('https://
|
|
195
|
+
* const provider = new RestArkProvider('https://arkade.computer');
|
|
158
196
|
* const info = await provider.getInfo();
|
|
159
197
|
* ```
|
|
160
198
|
*/
|
|
@@ -1,19 +1,53 @@
|
|
|
1
1
|
import { Intent } from "../intent";
|
|
2
2
|
import { SignedIntent } from "./ark";
|
|
3
|
+
/**
|
|
4
|
+
* Delegate identity and fee information returned by `getDelegateInfo`.
|
|
5
|
+
*/
|
|
3
6
|
export interface DelegateInfo {
|
|
7
|
+
/** Delegate public key. */
|
|
4
8
|
pubkey: string;
|
|
9
|
+
/** Delegate fee amount or expression returned by the delegation service. */
|
|
5
10
|
fee: string;
|
|
11
|
+
/**
|
|
12
|
+
* Address controlled by the delegation service.
|
|
13
|
+
* Naming is confusing: should be thought of as a "delegate address".
|
|
14
|
+
*/
|
|
6
15
|
delegatorAddress: string;
|
|
7
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Optional delegate behavior flags.
|
|
19
|
+
*/
|
|
8
20
|
export interface DelegateOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Instruct the delegate not to replace an existing delegation
|
|
23
|
+
* (meaning a signed register intent and its forfeit transactions)
|
|
24
|
+
* that already includes at least one virtual output from this request.
|
|
25
|
+
*
|
|
26
|
+
* @defaultValue `false`
|
|
27
|
+
*/
|
|
9
28
|
rejectReplace?: boolean;
|
|
10
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Provider interface for remote delegation services.
|
|
32
|
+
*/
|
|
11
33
|
export interface DelegatorProvider {
|
|
34
|
+
/**
|
|
35
|
+
* Request delegation for a signed register intent and its forfeit transactions.
|
|
36
|
+
*
|
|
37
|
+
* @param intent - Signed register intent to delegate
|
|
38
|
+
* @param forfeitTxs - Forfeit transactions associated with the delegation request
|
|
39
|
+
* @param options - Optional delegate behavior flags
|
|
40
|
+
*/
|
|
12
41
|
delegate(intent: SignedIntent<Intent.RegisterMessage>, forfeitTxs: string[], options?: DelegateOptions): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Fetch delegate metadata such as pubkey, fee, and delegate address.
|
|
44
|
+
*
|
|
45
|
+
* @returns Delegate identity and fee information
|
|
46
|
+
*/
|
|
13
47
|
getDelegateInfo(): Promise<DelegateInfo>;
|
|
14
48
|
}
|
|
15
49
|
/**
|
|
16
|
-
* REST-based
|
|
50
|
+
* REST-based delegation provider implementation.
|
|
17
51
|
* @example
|
|
18
52
|
* ```typescript
|
|
19
53
|
* const provider = new RestDelegatorProvider('https://delegator.example.com');
|
|
@@ -23,7 +57,26 @@ export interface DelegatorProvider {
|
|
|
23
57
|
*/
|
|
24
58
|
export declare class RestDelegatorProvider implements DelegatorProvider {
|
|
25
59
|
url: string;
|
|
60
|
+
/**
|
|
61
|
+
* Create a REST delegation provider targeting the given base URL.
|
|
62
|
+
*
|
|
63
|
+
* @param url - Base URL of the delegation service
|
|
64
|
+
*/
|
|
26
65
|
constructor(url: string);
|
|
66
|
+
/**
|
|
67
|
+
* Submit a delegation request to the remote delegation service.
|
|
68
|
+
*
|
|
69
|
+
* @param intent - Signed register intent to delegate
|
|
70
|
+
* @param forfeitTxs - Forfeit transactions associated with the delegation request
|
|
71
|
+
* @param options - Optional delegate behavior flags
|
|
72
|
+
* @throws Error if the remote service rejects the request
|
|
73
|
+
*/
|
|
27
74
|
delegate(intent: SignedIntent<Intent.RegisterMessage>, forfeitTxs: string[], options?: DelegateOptions): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Fetch delegate metadata exposed by the remote delegation service.
|
|
77
|
+
*
|
|
78
|
+
* @returns Delegate identity and fee information
|
|
79
|
+
* @throws Error if the remote service returns invalid data
|
|
80
|
+
*/
|
|
28
81
|
getDelegateInfo(): Promise<DelegateInfo>;
|
|
29
82
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RestArkProvider, SettlementEvent, TxNotification } from "./ark";
|
|
2
2
|
/**
|
|
3
|
-
* Expo-compatible
|
|
3
|
+
* Expo-compatible Arkade provider implementation using expo/fetch for SSE support.
|
|
4
4
|
* This provider works specifically in React Native/Expo environments where
|
|
5
5
|
* standard EventSource is not available but expo/fetch provides SSE capabilities.
|
|
6
6
|
*
|
|
@@ -8,7 +8,7 @@ import { RestArkProvider, SettlementEvent, TxNotification } from "./ark";
|
|
|
8
8
|
* ```typescript
|
|
9
9
|
* import { ExpoArkProvider } from '@arkade-os/sdk/providers/expo';
|
|
10
10
|
*
|
|
11
|
-
* const provider = new ExpoArkProvider('https://
|
|
11
|
+
* const provider = new ExpoArkProvider('https://arkade.computer');
|
|
12
12
|
* const info = await provider.getInfo();
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
@@ -33,6 +33,7 @@ export interface ChainTx {
|
|
|
33
33
|
txid: string;
|
|
34
34
|
expiresAt: string;
|
|
35
35
|
type: ChainTxType;
|
|
36
|
+
/** IDs of the transactions in the chain used as input of the current transaction. */
|
|
36
37
|
spends: string[];
|
|
37
38
|
}
|
|
38
39
|
export interface CommitmentTx {
|
|
@@ -101,61 +102,163 @@ export interface SubscriptionHeartbeat {
|
|
|
101
102
|
export interface SubscriptionEvent extends SubscriptionResponse {
|
|
102
103
|
type: "event";
|
|
103
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Filters accepted by `IndexerProvider.getVtxos`.
|
|
107
|
+
*
|
|
108
|
+
* @remarks
|
|
109
|
+
* Exactly one of `scripts` or `outpoints` must be supplied.
|
|
110
|
+
*
|
|
111
|
+
* @see IndexerProvider.getVtxos
|
|
112
|
+
*/
|
|
104
113
|
export type GetVtxosOptions = PaginationOptions & {
|
|
114
|
+
/** Only return spendable virtual outputs. */
|
|
105
115
|
spendableOnly?: boolean;
|
|
116
|
+
/** Only return spent virtual outputs. */
|
|
106
117
|
spentOnly?: boolean;
|
|
118
|
+
/** Only return recoverable virtual outputs. */
|
|
107
119
|
recoverableOnly?: boolean;
|
|
120
|
+
/** Only return pending/preconfirmed virtual outputs. */
|
|
108
121
|
pendingOnly?: boolean;
|
|
122
|
+
/** Only return virtual outputs created after this timestamp. */
|
|
109
123
|
after?: number;
|
|
124
|
+
/** Only return virtual outputs created before this timestamp. */
|
|
110
125
|
before?: number;
|
|
111
126
|
} & ({
|
|
127
|
+
/** Scripts to search for matching virtual outputs. */
|
|
112
128
|
scripts: string[];
|
|
113
129
|
outpoints?: never;
|
|
114
130
|
} | {
|
|
131
|
+
/** Explicit outpoints to fetch. */
|
|
115
132
|
outpoints: Outpoint[];
|
|
116
133
|
scripts?: never;
|
|
117
134
|
});
|
|
118
135
|
export interface IndexerProvider {
|
|
136
|
+
/**
|
|
137
|
+
* Fetch the virtual output tree for a batch outpoint.
|
|
138
|
+
*
|
|
139
|
+
* @param batchOutpoint - Batch outpoint whose tree should be fetched
|
|
140
|
+
* @param opts - Optional pagination settings
|
|
141
|
+
* @returns virtual output tree nodes and optional pagination state
|
|
142
|
+
*/
|
|
119
143
|
getVtxoTree(batchOutpoint: Outpoint, opts?: PaginationOptions): Promise<{
|
|
120
144
|
vtxoTree: Tx[];
|
|
121
145
|
page?: PageResponse;
|
|
122
146
|
}>;
|
|
147
|
+
/**
|
|
148
|
+
* Fetch the leaf outpoints for a batch virtual output tree.
|
|
149
|
+
*
|
|
150
|
+
* @param batchOutpoint - Batch outpoint whose leaf outpoints should be fetched
|
|
151
|
+
* @param opts - Optional pagination settings
|
|
152
|
+
* @returns Leaf outpoints and optional pagination state
|
|
153
|
+
*/
|
|
123
154
|
getVtxoTreeLeaves(batchOutpoint: Outpoint, opts?: PaginationOptions): Promise<{
|
|
124
155
|
leaves: Outpoint[];
|
|
125
156
|
page?: PageResponse;
|
|
126
157
|
}>;
|
|
158
|
+
/**
|
|
159
|
+
* Fetch sweep transactions that spent a batch.
|
|
160
|
+
*
|
|
161
|
+
* @param batchOutpoint - Batch outpoint to inspect
|
|
162
|
+
* @returns Sweep transaction ids
|
|
163
|
+
*/
|
|
127
164
|
getBatchSweepTransactions(batchOutpoint: Outpoint): Promise<{
|
|
128
165
|
sweptBy: string[];
|
|
129
166
|
}>;
|
|
167
|
+
/**
|
|
168
|
+
* Fetch a commitment transaction by txid.
|
|
169
|
+
*
|
|
170
|
+
* @param txid - Commitment transaction id
|
|
171
|
+
* @returns Commitment transaction details
|
|
172
|
+
*/
|
|
130
173
|
getCommitmentTx(txid: string): Promise<CommitmentTx>;
|
|
174
|
+
/**
|
|
175
|
+
* Fetch connector transactions for a commitment transaction.
|
|
176
|
+
*
|
|
177
|
+
* @param txid - Commitment transaction id
|
|
178
|
+
* @param opts - Optional pagination settings
|
|
179
|
+
* @returns Connector transactions and optional pagination state
|
|
180
|
+
*/
|
|
131
181
|
getCommitmentTxConnectors(txid: string, opts?: PaginationOptions): Promise<{
|
|
132
182
|
connectors: Tx[];
|
|
133
183
|
page?: PageResponse;
|
|
134
184
|
}>;
|
|
185
|
+
/**
|
|
186
|
+
* Fetch forfeit transaction ids for a commitment transaction.
|
|
187
|
+
*
|
|
188
|
+
* @param txid - Commitment transaction id
|
|
189
|
+
* @param opts - Optional pagination settings
|
|
190
|
+
* @returns Forfeit transaction ids and optional pagination state
|
|
191
|
+
*/
|
|
135
192
|
getCommitmentTxForfeitTxs(txid: string, opts?: PaginationOptions): Promise<{
|
|
136
193
|
txids: string[];
|
|
137
194
|
page?: PageResponse;
|
|
138
195
|
}>;
|
|
196
|
+
/**
|
|
197
|
+
* Open a streamed subscription for a previously created subscription id.
|
|
198
|
+
*
|
|
199
|
+
* @param subscriptionId - Subscription identifier returned by `subscribeForScripts`
|
|
200
|
+
* @param abortSignal - Signal used to terminate the stream
|
|
201
|
+
* @returns Async iterator of subscription responses
|
|
202
|
+
*/
|
|
139
203
|
getSubscription(subscriptionId: string, abortSignal: AbortSignal): AsyncIterableIterator<SubscriptionResponse>;
|
|
204
|
+
/**
|
|
205
|
+
* Fetch raw virtual transactions by txid.
|
|
206
|
+
*
|
|
207
|
+
* @param txids - Virtual transaction ids to fetch
|
|
208
|
+
* @param opts - Optional pagination settings
|
|
209
|
+
* @returns Raw virtual transactions and optional pagination state
|
|
210
|
+
*/
|
|
140
211
|
getVirtualTxs(txids: string[], opts?: PaginationOptions): Promise<{
|
|
141
212
|
txs: string[];
|
|
142
213
|
page?: PageResponse;
|
|
143
214
|
}>;
|
|
215
|
+
/**
|
|
216
|
+
* Fetch the ancestry chain for a virtual output.
|
|
217
|
+
*
|
|
218
|
+
* @param vtxoOutpoint - Virtual output outpoint to inspect
|
|
219
|
+
* @param opts - Optional pagination settings
|
|
220
|
+
* @returns Chain data and optional pagination state
|
|
221
|
+
*/
|
|
144
222
|
getVtxoChain(vtxoOutpoint: Outpoint, opts?: PaginationOptions): Promise<VtxoChain>;
|
|
223
|
+
/**
|
|
224
|
+
* Fetch virtual outputs by script set or outpoints.
|
|
225
|
+
*
|
|
226
|
+
* @param opts - Virtual output filters and pagination settings
|
|
227
|
+
* @returns Virtual outputs and optional pagination state
|
|
228
|
+
*/
|
|
145
229
|
getVtxos(opts?: GetVtxosOptions): Promise<{
|
|
146
230
|
vtxos: VirtualCoin[];
|
|
147
231
|
page?: PageResponse;
|
|
148
232
|
}>;
|
|
233
|
+
/**
|
|
234
|
+
* Fetch metadata for a specific asset id.
|
|
235
|
+
*
|
|
236
|
+
* @param assetId - Asset identifier
|
|
237
|
+
* @returns Asset details
|
|
238
|
+
*/
|
|
149
239
|
getAssetDetails(assetId: string): Promise<AssetDetails>;
|
|
240
|
+
/**
|
|
241
|
+
* Create or extend a subscription for a set of scripts.
|
|
242
|
+
*
|
|
243
|
+
* @param scripts - Scripts to monitor
|
|
244
|
+
* @param subscriptionId - Existing subscription id to extend
|
|
245
|
+
* @returns Subscription id
|
|
246
|
+
*/
|
|
150
247
|
subscribeForScripts(scripts: string[], subscriptionId?: string): Promise<string>;
|
|
248
|
+
/**
|
|
249
|
+
* Remove some or all scripts from an existing subscription.
|
|
250
|
+
*
|
|
251
|
+
* @param subscriptionId - Subscription identifier to update
|
|
252
|
+
* @param scripts - Scripts to remove, or omit to remove all
|
|
253
|
+
*/
|
|
151
254
|
unsubscribeForScripts(subscriptionId: string, scripts?: string[]): Promise<void>;
|
|
152
255
|
}
|
|
153
256
|
/**
|
|
154
|
-
* REST-based
|
|
257
|
+
* REST-based indexer provider implementation.
|
|
155
258
|
* @see https://buf.build/arkade-os/arkd/docs/main:ark.v1#ark.v1.IndexerService
|
|
156
259
|
* @example
|
|
157
260
|
* ```typescript
|
|
158
|
-
* const provider = new RestIndexerProvider('https://
|
|
261
|
+
* const provider = new RestIndexerProvider('https://arkade.computer');
|
|
159
262
|
* const commitmentTx = await provider.getCommitmentTx("6686af8f3be3517880821f62e6c3d749b9d6713736a1d8e229a55daa659446b2");
|
|
160
263
|
* ```
|
|
161
264
|
*/
|
|
@@ -16,14 +16,57 @@ export type ExplorerTransaction = {
|
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
18
|
export interface OnchainProvider {
|
|
19
|
+
/**
|
|
20
|
+
* Fetch spendable onchain outputs for an address.
|
|
21
|
+
*
|
|
22
|
+
* @param address - Bitcoin address to query
|
|
23
|
+
* @returns Spendable onchain outputs for the address
|
|
24
|
+
* @see Coin
|
|
25
|
+
*/
|
|
19
26
|
getCoins(address: string): Promise<Coin[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Fetch the current fastest fee rate estimate.
|
|
29
|
+
*
|
|
30
|
+
* @returns Fee rate in sats/vB, if available
|
|
31
|
+
* @remarks
|
|
32
|
+
* Implementations may return `undefined` when the backing service does not expose
|
|
33
|
+
* a usable fee estimate.
|
|
34
|
+
*/
|
|
20
35
|
getFeeRate(): Promise<number | undefined>;
|
|
36
|
+
/**
|
|
37
|
+
* Broadcast a single transaction or a 1P1C package.
|
|
38
|
+
*
|
|
39
|
+
* @param txs - One or more raw transaction hex strings
|
|
40
|
+
* @returns Broadcast transaction id
|
|
41
|
+
* @throws Error if the broadcast request fails or the package shape is invalid
|
|
42
|
+
*/
|
|
21
43
|
broadcastTransaction(...txs: string[]): Promise<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Fetch outspend information for every output in a transaction.
|
|
46
|
+
*
|
|
47
|
+
* @param txid - Transaction id to inspect
|
|
48
|
+
* @returns Per-output spend status information
|
|
49
|
+
* @see getTxStatus
|
|
50
|
+
*/
|
|
22
51
|
getTxOutspends(txid: string): Promise<{
|
|
23
52
|
spent: boolean;
|
|
24
53
|
txid: string;
|
|
25
54
|
}[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Fetch transactions associated with an address.
|
|
57
|
+
*
|
|
58
|
+
* @param address - Bitcoin address to query
|
|
59
|
+
* @returns Transactions involving the address
|
|
60
|
+
* @see ExplorerTransaction
|
|
61
|
+
*/
|
|
26
62
|
getTransactions(address: string): Promise<ExplorerTransaction[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Fetch confirmation status for a transaction.
|
|
65
|
+
*
|
|
66
|
+
* @param txid - Transaction id to inspect
|
|
67
|
+
* @returns Confirmation status and block metadata when confirmed
|
|
68
|
+
* @see getTxOutspends
|
|
69
|
+
*/
|
|
27
70
|
getTxStatus(txid: string): Promise<{
|
|
28
71
|
confirmed: false;
|
|
29
72
|
} | {
|
|
@@ -31,20 +74,36 @@ export interface OnchainProvider {
|
|
|
31
74
|
blockTime: number;
|
|
32
75
|
blockHeight: number;
|
|
33
76
|
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Fetch the current chain tip.
|
|
79
|
+
*
|
|
80
|
+
* @returns Current chain height, block time, and block hash
|
|
81
|
+
*/
|
|
34
82
|
getChainTip(): Promise<{
|
|
35
83
|
height: number;
|
|
36
84
|
time: number;
|
|
37
85
|
hash: string;
|
|
38
86
|
}>;
|
|
87
|
+
/**
|
|
88
|
+
* Watch a set of addresses and invoke the callback when transactions are observed.
|
|
89
|
+
*
|
|
90
|
+
* @param addresses - Addresses to monitor
|
|
91
|
+
* @param eventCallback - Callback invoked when matching transactions are seen
|
|
92
|
+
* @returns Stop function that cancels the watch
|
|
93
|
+
* @remarks
|
|
94
|
+
* Implementations may use websockets, server-sent events, polling, or a hybrid strategy.
|
|
95
|
+
* @see getTransactions
|
|
96
|
+
*/
|
|
39
97
|
watchAddresses(addresses: string[], eventCallback: (txs: ExplorerTransaction[]) => void): Promise<() => void>;
|
|
40
98
|
}
|
|
41
99
|
/**
|
|
42
100
|
* Implementation of the onchain provider interface for esplora REST API.
|
|
101
|
+
*
|
|
43
102
|
* @see https://mempool.space/docs/api/rest
|
|
44
103
|
* @example
|
|
45
104
|
* ```typescript
|
|
46
105
|
* const provider = new EsploraProvider("https://mempool.space/api");
|
|
47
|
-
* const
|
|
106
|
+
* const outputs = await provider.getCoins("bcrt1q679zsd45msawvr7782r0twvmukns3drlstjt77");
|
|
48
107
|
* ```
|
|
49
108
|
*/
|
|
50
109
|
export declare class EsploraProvider implements OnchainProvider {
|
|
@@ -52,7 +111,9 @@ export declare class EsploraProvider implements OnchainProvider {
|
|
|
52
111
|
readonly pollingInterval: number;
|
|
53
112
|
readonly forcePolling: boolean;
|
|
54
113
|
constructor(baseUrl: string, opts?: {
|
|
114
|
+
/** Polling interval in milliseconds. */
|
|
55
115
|
pollingInterval?: number;
|
|
116
|
+
/** Force polling even when websocket transport is available. */
|
|
56
117
|
forcePolling?: boolean;
|
|
57
118
|
});
|
|
58
119
|
getCoins(address: string): Promise<Coin[]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Realm object schemas for the
|
|
2
|
+
* Realm object schemas for the Arkade wallet.
|
|
3
3
|
*
|
|
4
4
|
* All schema names are prefixed with "Ark" to avoid collisions with
|
|
5
5
|
* other Realm schemas in the consuming application.
|
|
@@ -108,7 +108,7 @@ export declare const ArkContractSchema: {
|
|
|
108
108
|
};
|
|
109
109
|
};
|
|
110
110
|
/**
|
|
111
|
-
* All Realm schemas needed by the
|
|
111
|
+
* All Realm schemas needed by the Arkade wallet repositories.
|
|
112
112
|
* Pass this array to your Realm configuration's `schema` property.
|
|
113
113
|
*/
|
|
114
114
|
export declare const ArkRealmSchemas: ({
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Minimal interface for the subset of the Realm API used by the
|
|
3
|
-
*
|
|
3
|
+
* Arkade repositories. Consumers pass their real Realm instance and
|
|
4
4
|
* the compiler validates it satisfies this shape.
|
|
5
5
|
*/
|
|
6
6
|
/** Result set returned by `realm.objects()`. */
|
|
7
7
|
export interface RealmResults<T = Record<string, unknown>> extends Iterable<T> {
|
|
8
8
|
filtered(query: string, ...args: unknown[]): RealmResults<T>;
|
|
9
9
|
}
|
|
10
|
-
/** The Realm API surface used by
|
|
10
|
+
/** The Realm API surface used by Arkade repositories. */
|
|
11
11
|
export interface RealmLike {
|
|
12
12
|
write(callback: () => void): void;
|
|
13
13
|
objects<T = Record<string, unknown>>(schemaName: string): RealmResults<T>;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { ArkTransaction, ExtendedCoin, ExtendedVirtualCoin } from "../wallet";
|
|
2
2
|
export interface WalletState {
|
|
3
|
+
/** Timestamp of the last successful wallet sync, in milliseconds. */
|
|
3
4
|
lastSyncTime?: number;
|
|
5
|
+
/** Arbitrary stored wallet settings. */
|
|
4
6
|
settings?: Record<string, any>;
|
|
5
7
|
}
|
|
8
|
+
/** Stored commitment transaction metadata. */
|
|
6
9
|
export type CommitmentTxRecord = {
|
|
10
|
+
/** Commitment transaction id. */
|
|
7
11
|
txid: string;
|
|
12
|
+
/** Creation timestamp in milliseconds. */
|
|
8
13
|
createdAt: number;
|
|
9
14
|
};
|
|
10
15
|
export interface WalletRepository extends AsyncDisposable {
|
|
@@ -13,15 +18,26 @@ export interface WalletRepository extends AsyncDisposable {
|
|
|
13
18
|
* Clear all data from storage.
|
|
14
19
|
*/
|
|
15
20
|
clear(): Promise<void>;
|
|
21
|
+
/** Fetch stored virtual outputs for an address. */
|
|
16
22
|
getVtxos(address: string): Promise<ExtendedVirtualCoin[]>;
|
|
23
|
+
/** Save virtual outputs for an address. */
|
|
17
24
|
saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise<void>;
|
|
25
|
+
/** Delete stored virtual outputs for an address. */
|
|
18
26
|
deleteVtxos(address: string): Promise<void>;
|
|
27
|
+
/** Fetch stored boarding inputs for an address. */
|
|
19
28
|
getUtxos(address: string): Promise<ExtendedCoin[]>;
|
|
29
|
+
/** Save boarding inputs for an address. */
|
|
20
30
|
saveUtxos(address: string, utxos: ExtendedCoin[]): Promise<void>;
|
|
31
|
+
/** Delete stored boarding inputs for an address. */
|
|
21
32
|
deleteUtxos(address: string): Promise<void>;
|
|
33
|
+
/** Fetch stored transaction history for an address. */
|
|
22
34
|
getTransactionHistory(address: string): Promise<ArkTransaction[]>;
|
|
35
|
+
/** Save transaction history for an address. */
|
|
23
36
|
saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
|
|
37
|
+
/** Delete stored transaction history for an address. */
|
|
24
38
|
deleteTransactions(address: string): Promise<void>;
|
|
39
|
+
/** Fetch stored wallet state. */
|
|
25
40
|
getWalletState(): Promise<WalletState | null>;
|
|
41
|
+
/** Save wallet state. */
|
|
26
42
|
saveWalletState(state: WalletState): Promise<void>;
|
|
27
43
|
}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { Bytes } from "@scure/btc-signer/utils.js";
|
|
2
2
|
/**
|
|
3
|
-
* ArkAddress allows
|
|
4
|
-
*
|
|
3
|
+
* ArkAddress allows creating and decoding bech32m-encoded Arkade addresses.
|
|
4
|
+
*
|
|
5
|
+
* An Arkade address is composed of:
|
|
5
6
|
* - a human readable prefix (hrp)
|
|
6
7
|
* - a version byte (1 byte)
|
|
7
8
|
* - a server public key (32 bytes)
|
|
8
9
|
* - a vtxo taproot public key (32 bytes)
|
|
9
10
|
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* This is an Arkade-specific address format.
|
|
13
|
+
* It is distinct from the Taproot onchain address returned by `VtxoScript.onchainAddress`.
|
|
14
|
+
*
|
|
15
|
+
* @see VtxoScript
|
|
16
|
+
*
|
|
10
17
|
* @example
|
|
11
18
|
* ```typescript
|
|
12
19
|
* const address = new ArkAddress(
|
|
@@ -26,9 +33,35 @@ export declare class ArkAddress {
|
|
|
26
33
|
readonly vtxoTaprootKey: Bytes;
|
|
27
34
|
readonly hrp: string;
|
|
28
35
|
readonly version: number;
|
|
36
|
+
/**
|
|
37
|
+
* Create an Arkade address from its server key, vtxo taproot public key, and prefix.
|
|
38
|
+
*
|
|
39
|
+
* @param serverPubKey - 32-byte Arkade server public key
|
|
40
|
+
* @param vtxoTaprootKey - 32-byte tweaked vtxo taproot public key
|
|
41
|
+
* @param hrp - Bech32 human-readable prefix
|
|
42
|
+
* @param version - Address version byte
|
|
43
|
+
* @defaultValue `version = 0`
|
|
44
|
+
* @throws Error if either public key is not 32 bytes long
|
|
45
|
+
*/
|
|
29
46
|
constructor(serverPubKey: Bytes, vtxoTaprootKey: Bytes, hrp: string, version?: number);
|
|
47
|
+
/**
|
|
48
|
+
* Decode an Arkade address from its bech32m string form.
|
|
49
|
+
*
|
|
50
|
+
* @param address - Bech32m-encoded Arkade address
|
|
51
|
+
* @returns Decoded Arkade address
|
|
52
|
+
* @throws Error if the address is malformed or has an invalid payload length
|
|
53
|
+
* @see encode
|
|
54
|
+
*/
|
|
30
55
|
static decode(address: string): ArkAddress;
|
|
56
|
+
/**
|
|
57
|
+
* Encode the address to its bech32m string form.
|
|
58
|
+
*
|
|
59
|
+
* @returns Bech32m-encoded Arkade address
|
|
60
|
+
* @see decode
|
|
61
|
+
*/
|
|
31
62
|
encode(): string;
|
|
63
|
+
/** ScriptPubKey used to send non-dust funds to the address. */
|
|
32
64
|
get pkScript(): Bytes;
|
|
65
|
+
/** ScriptPubKey used to send sub-dust funds to the address. */
|
|
33
66
|
get subdustPkScript(): Bytes;
|
|
34
67
|
}
|