@arkade-os/sdk 0.3.0-alpha.8 → 0.3.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.
Files changed (101) hide show
  1. package/README.md +48 -14
  2. package/dist/cjs/arknote/index.js +3 -3
  3. package/dist/cjs/forfeit.js +2 -2
  4. package/dist/cjs/identity/singleKey.js +8 -8
  5. package/dist/cjs/index.js +13 -5
  6. package/dist/cjs/{bip322 → intent}/index.js +38 -61
  7. package/dist/cjs/musig2/index.js +2 -1
  8. package/dist/cjs/musig2/nonces.js +4 -0
  9. package/dist/cjs/providers/ark.js +76 -45
  10. package/dist/cjs/providers/errors.js +59 -0
  11. package/dist/cjs/providers/expoArk.js +15 -170
  12. package/dist/cjs/providers/expoIndexer.js +22 -111
  13. package/dist/cjs/providers/expoUtils.js +124 -0
  14. package/dist/cjs/providers/onchain.js +19 -20
  15. package/dist/cjs/repositories/walletRepository.js +64 -28
  16. package/dist/cjs/script/base.js +15 -7
  17. package/dist/cjs/script/tapscript.js +20 -21
  18. package/dist/cjs/script/vhtlc.js +2 -2
  19. package/dist/cjs/tree/signingSession.js +44 -11
  20. package/dist/cjs/tree/txTree.js +3 -4
  21. package/dist/cjs/tree/validation.js +2 -3
  22. package/dist/cjs/utils/arkTransaction.js +105 -15
  23. package/dist/cjs/utils/transaction.js +28 -0
  24. package/dist/cjs/utils/unknownFields.js +7 -7
  25. package/dist/cjs/wallet/onchain.js +6 -7
  26. package/dist/cjs/wallet/serviceWorker/response.js +32 -0
  27. package/dist/cjs/wallet/serviceWorker/utils.js +2 -0
  28. package/dist/cjs/wallet/serviceWorker/wallet.js +7 -8
  29. package/dist/cjs/wallet/serviceWorker/worker.js +46 -27
  30. package/dist/cjs/wallet/unroll.js +7 -9
  31. package/dist/cjs/wallet/utils.js +9 -0
  32. package/dist/cjs/wallet/vtxo-manager.js +323 -0
  33. package/dist/cjs/wallet/wallet.js +98 -125
  34. package/dist/esm/arknote/index.js +2 -2
  35. package/dist/esm/forfeit.js +1 -1
  36. package/dist/esm/identity/singleKey.js +9 -9
  37. package/dist/esm/index.js +14 -10
  38. package/dist/esm/{bip322 → intent}/index.js +32 -54
  39. package/dist/esm/musig2/index.js +1 -1
  40. package/dist/esm/musig2/nonces.js +3 -0
  41. package/dist/esm/providers/ark.js +76 -45
  42. package/dist/esm/providers/errors.js +54 -0
  43. package/dist/esm/providers/expoArk.js +15 -137
  44. package/dist/esm/providers/expoIndexer.js +22 -78
  45. package/dist/esm/providers/expoUtils.js +87 -0
  46. package/dist/esm/providers/onchain.js +19 -20
  47. package/dist/esm/repositories/walletRepository.js +64 -28
  48. package/dist/esm/script/base.js +12 -4
  49. package/dist/esm/script/tapscript.js +1 -2
  50. package/dist/esm/script/vhtlc.js +1 -1
  51. package/dist/esm/tree/signingSession.js +45 -12
  52. package/dist/esm/tree/txTree.js +3 -4
  53. package/dist/esm/tree/validation.js +2 -3
  54. package/dist/esm/utils/arkTransaction.js +97 -8
  55. package/dist/esm/utils/transaction.js +24 -0
  56. package/dist/esm/utils/unknownFields.js +3 -3
  57. package/dist/esm/wallet/onchain.js +3 -4
  58. package/dist/esm/wallet/serviceWorker/response.js +32 -0
  59. package/dist/esm/wallet/serviceWorker/utils.js +1 -0
  60. package/dist/esm/wallet/serviceWorker/wallet.js +8 -9
  61. package/dist/esm/wallet/serviceWorker/worker.js +48 -29
  62. package/dist/esm/wallet/unroll.js +5 -7
  63. package/dist/esm/wallet/utils.js +8 -0
  64. package/dist/esm/wallet/vtxo-manager.js +317 -0
  65. package/dist/esm/wallet/wallet.js +92 -119
  66. package/dist/types/arknote/index.d.ts +1 -1
  67. package/dist/types/forfeit.d.ts +2 -2
  68. package/dist/types/identity/index.d.ts +2 -2
  69. package/dist/types/identity/singleKey.d.ts +2 -2
  70. package/dist/types/index.d.ts +9 -7
  71. package/dist/types/intent/index.d.ts +41 -0
  72. package/dist/types/musig2/index.d.ts +1 -1
  73. package/dist/types/musig2/nonces.d.ts +1 -0
  74. package/dist/types/providers/ark.d.ts +62 -26
  75. package/dist/types/providers/errors.d.ts +13 -0
  76. package/dist/types/providers/expoIndexer.d.ts +2 -10
  77. package/dist/types/providers/expoUtils.d.ts +18 -0
  78. package/dist/types/providers/indexer.d.ts +1 -9
  79. package/dist/types/providers/onchain.d.ts +6 -2
  80. package/dist/types/repositories/walletRepository.d.ts +9 -5
  81. package/dist/types/script/base.d.ts +5 -2
  82. package/dist/types/tree/signingSession.d.ts +16 -11
  83. package/dist/types/utils/anchor.d.ts +2 -2
  84. package/dist/types/utils/arkTransaction.d.ts +12 -4
  85. package/dist/types/utils/transaction.d.ts +13 -0
  86. package/dist/types/utils/unknownFields.d.ts +4 -4
  87. package/dist/types/wallet/index.d.ts +6 -4
  88. package/dist/types/wallet/onchain.d.ts +1 -1
  89. package/dist/types/wallet/serviceWorker/response.d.ts +16 -2
  90. package/dist/types/wallet/serviceWorker/utils.d.ts +1 -0
  91. package/dist/types/wallet/serviceWorker/wallet.d.ts +2 -2
  92. package/dist/types/wallet/serviceWorker/worker.d.ts +7 -1
  93. package/dist/types/wallet/unroll.d.ts +1 -1
  94. package/dist/types/wallet/utils.d.ts +2 -1
  95. package/dist/types/wallet/vtxo-manager.d.ts +179 -0
  96. package/dist/types/wallet/wallet.d.ts +8 -4
  97. package/package.json +1 -2
  98. package/dist/cjs/bip322/errors.js +0 -13
  99. package/dist/esm/bip322/errors.js +0 -9
  100. package/dist/types/bip322/errors.d.ts +0 -6
  101. package/dist/types/bip322/index.d.ts +0 -57
@@ -11,7 +11,7 @@ export declare enum SettlementEventType {
11
11
  BatchFinalized = "batch_finalized",
12
12
  BatchFailed = "batch_failed",
13
13
  TreeSigningStarted = "tree_signing_started",
14
- TreeNoncesAggregated = "tree_nonces_aggregated",
14
+ TreeNonces = "tree_nonces",
15
15
  TreeTx = "tree_tx",
16
16
  TreeSignature = "tree_signature"
17
17
  }
@@ -36,10 +36,12 @@ export type TreeSigningStartedEvent = {
36
36
  cosignersPublicKeys: string[];
37
37
  unsignedCommitmentTx: string;
38
38
  };
39
- export type TreeNoncesAggregatedEvent = {
40
- type: SettlementEventType.TreeNoncesAggregated;
39
+ export type TreeNoncesEvent = {
40
+ type: SettlementEventType.TreeNonces;
41
41
  id: string;
42
- treeNonces: TreeNonces;
42
+ topic: string[];
43
+ txid: string;
44
+ nonces: TreeNonces;
43
45
  };
44
46
  export type BatchStartedEvent = {
45
47
  type: SettlementEventType.BatchStarted;
@@ -62,32 +64,57 @@ export type TreeSignatureEvent = {
62
64
  txid: string;
63
65
  signature: string;
64
66
  };
65
- export type SettlementEvent = BatchFinalizationEvent | BatchFinalizedEvent | BatchFailedEvent | TreeSigningStartedEvent | TreeNoncesAggregatedEvent | BatchStartedEvent | TreeTxEvent | TreeSignatureEvent;
66
- export interface MarketHour {
67
- nextStartTime: bigint;
67
+ export type SettlementEvent = BatchFinalizationEvent | BatchFinalizedEvent | BatchFailedEvent | TreeSigningStartedEvent | TreeNoncesEvent | BatchStartedEvent | TreeTxEvent | TreeSignatureEvent;
68
+ export interface ScheduledSession {
69
+ duration: bigint;
70
+ fees: FeeInfo;
68
71
  nextEndTime: bigint;
72
+ nextStartTime: bigint;
69
73
  period: bigint;
70
- roundInterval: bigint;
71
74
  }
75
+ export interface IntentFeeInfo {
76
+ offchainInput: string;
77
+ offchainOutput: string;
78
+ onchainInput: string;
79
+ onchainOutput: string;
80
+ }
81
+ export interface FeeInfo {
82
+ intentFee: IntentFeeInfo;
83
+ txFeeRate: string;
84
+ }
85
+ export interface PendingTx {
86
+ arkTxid: string;
87
+ finalArkTx: string;
88
+ signedCheckpointTxs: string[];
89
+ }
90
+ export interface DeprecatedSigner {
91
+ cutoffDate: bigint;
92
+ pubkey: string;
93
+ }
94
+ export type ServiceStatus = Record<string, string>;
72
95
  export interface ArkInfo {
73
- signerPubkey: string;
74
- vtxoTreeExpiry: bigint;
75
- unilateralExitDelay: bigint;
76
- roundInterval: bigint;
77
- network: string;
96
+ boardingExitDelay: bigint;
97
+ checkpointTapscript: string;
98
+ deprecatedSigners: DeprecatedSigner[];
99
+ digest: string;
78
100
  dust: bigint;
101
+ fees: FeeInfo;
79
102
  forfeitAddress: string;
80
- marketHour?: MarketHour;
81
- version: string;
82
- utxoMinAmount: bigint;
103
+ forfeitPubkey: string;
104
+ network: string;
105
+ scheduledSession: ScheduledSession;
106
+ serviceStatus: ServiceStatus;
107
+ sessionDuration: bigint;
108
+ signerPubkey: string;
109
+ unilateralExitDelay: bigint;
83
110
  utxoMaxAmount: bigint;
84
- vtxoMinAmount: bigint;
111
+ utxoMinAmount: bigint;
112
+ version: string;
85
113
  vtxoMaxAmount: bigint;
86
- boardingExitDelay: bigint;
87
- checkpointExitClosure: string;
114
+ vtxoMinAmount: bigint;
88
115
  }
89
- export interface Intent {
90
- signature: string;
116
+ export interface SignedIntent {
117
+ proof: string;
91
118
  message: string;
92
119
  }
93
120
  export interface TxNotification {
@@ -108,8 +135,8 @@ export interface ArkProvider {
108
135
  signedCheckpointTxs: string[];
109
136
  }>;
110
137
  finalizeTx(arkTxid: string, finalCheckpointTxs: string[]): Promise<void>;
111
- registerIntent(intent: Intent): Promise<string>;
112
- deleteIntent(intent: Intent): Promise<void>;
138
+ registerIntent(intent: SignedIntent): Promise<string>;
139
+ deleteIntent(intent: SignedIntent): Promise<void>;
113
140
  confirmRegistration(intentId: string): Promise<void>;
114
141
  submitTreeNonces(batchId: string, pubkey: string, nonces: TreeNonces): Promise<void>;
115
142
  submitTreeSignatures(batchId: string, pubkey: string, signatures: TreePartialSigs): Promise<void>;
@@ -119,6 +146,7 @@ export interface ArkProvider {
119
146
  commitmentTx?: TxNotification;
120
147
  arkTx?: TxNotification;
121
148
  }>;
149
+ getPendingTxs(intent: SignedIntent): Promise<PendingTx[]>;
122
150
  }
123
151
  /**
124
152
  * REST-based Ark provider implementation.
@@ -139,8 +167,8 @@ export declare class RestArkProvider implements ArkProvider {
139
167
  signedCheckpointTxs: string[];
140
168
  }>;
141
169
  finalizeTx(arkTxid: string, finalCheckpointTxs: string[]): Promise<void>;
142
- registerIntent(intent: Intent): Promise<string>;
143
- deleteIntent(intent: Intent): Promise<void>;
170
+ registerIntent(intent: SignedIntent): Promise<string>;
171
+ deleteIntent(intent: SignedIntent): Promise<void>;
144
172
  confirmRegistration(intentId: string): Promise<void>;
145
173
  submitTreeNonces(batchId: string, pubkey: string, nonces: TreeNonces): Promise<void>;
146
174
  submitTreeSignatures(batchId: string, pubkey: string, signatures: TreePartialSigs): Promise<void>;
@@ -150,6 +178,7 @@ export declare class RestArkProvider implements ArkProvider {
150
178
  commitmentTx?: TxNotification;
151
179
  arkTx?: TxNotification;
152
180
  }>;
181
+ getPendingTxs(intent: SignedIntent): Promise<PendingTx[]>;
153
182
  protected parseSettlementEvent(data: ProtoTypes.GetEventStreamResponse): SettlementEvent | null;
154
183
  protected parseTransactionNotification(data: ProtoTypes.GetTransactionsStreamResponse): {
155
184
  commitmentTx?: TxNotification;
@@ -181,7 +210,13 @@ declare namespace ProtoTypes {
181
210
  }
182
211
  interface TreeNoncesAggregatedEvent {
183
212
  id: string;
184
- treeNonces: string;
213
+ treeNonces: Record<string, string>;
214
+ }
215
+ interface TreeNoncesEvent {
216
+ id: string;
217
+ topic: string[];
218
+ txid: string;
219
+ nonces: Record<string, string>;
185
220
  }
186
221
  interface TreeTxEvent {
187
222
  id: string;
@@ -225,6 +260,7 @@ declare namespace ProtoTypes {
225
260
  batchFinalized?: BatchFinalizedEvent;
226
261
  treeSigningStarted?: TreeSigningStartedEvent;
227
262
  treeNoncesAggregated?: TreeNoncesAggregatedEvent;
263
+ treeNonces?: TreeNoncesEvent;
228
264
  treeTx?: TreeTxEvent;
229
265
  treeSignature?: TreeSignatureEvent;
230
266
  heartbeat?: Heartbeat;
@@ -0,0 +1,13 @@
1
+ export declare class ArkError extends Error {
2
+ readonly code: number;
3
+ readonly message: string;
4
+ readonly name: string;
5
+ readonly metadata?: Record<string, string> | undefined;
6
+ constructor(code: number, message: string, name: string, metadata?: Record<string, string> | undefined);
7
+ }
8
+ /**
9
+ * Try to convert an error to an ArkError class, returning undefined if the error is not an ArkError
10
+ * @param error - The error to parse
11
+ * @returns The parsed ArkError, or undefined if the error is not an ArkError
12
+ */
13
+ export declare function maybeArkError(error: any): ArkError | undefined;
@@ -1,4 +1,4 @@
1
- import { RestIndexerProvider } from "./indexer";
1
+ import { RestIndexerProvider, SubscriptionResponse } from "./indexer";
2
2
  /**
3
3
  * Expo-compatible Indexer provider implementation using expo/fetch for streaming support.
4
4
  * This provider works specifically in React Native/Expo environments where
@@ -14,13 +14,5 @@ import { RestIndexerProvider } from "./indexer";
14
14
  */
15
15
  export declare class ExpoIndexerProvider extends RestIndexerProvider {
16
16
  constructor(serverUrl: string);
17
- getSubscription(subscriptionId: string, abortSignal: AbortSignal): AsyncGenerator<{
18
- txid: any;
19
- scripts: any;
20
- newVtxos: any;
21
- spentVtxos: any;
22
- sweptVtxos: any;
23
- tx: any;
24
- checkpointTxs: any;
25
- }, void, unknown>;
17
+ getSubscription(subscriptionId: string, abortSignal: AbortSignal): AsyncIterableIterator<SubscriptionResponse>;
26
18
  }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Dynamically imports expo/fetch with fallback to standard fetch.
3
+ * @returns A fetch function suitable for SSE streaming
4
+ */
5
+ export declare function getExpoFetch(options?: {
6
+ requireExpo?: boolean;
7
+ }): Promise<typeof fetch>;
8
+ /**
9
+ * Generic SSE stream processor using fetch API with ReadableStream.
10
+ * Handles SSE format parsing, buffer management, and abort signals.
11
+ *
12
+ * @param url - The SSE endpoint URL
13
+ * @param abortSignal - Signal to abort the stream
14
+ * @param fetchFn - Fetch function to use (defaults to standard fetch)
15
+ * @param headers - Additional headers to send
16
+ * @param parseData - Function to parse and yield data from SSE events
17
+ */
18
+ export declare function sseStreamIterator<T>(url: string, abortSignal: AbortSignal, fetchFn: typeof fetch, headers: Record<string, string>, parseData: (data: any) => T | null): AsyncGenerator<T, void, unknown>;
@@ -165,15 +165,7 @@ export declare class RestIndexerProvider implements IndexerProvider {
165
165
  txids: string[];
166
166
  page?: PageResponse;
167
167
  }>;
168
- getSubscription(subscriptionId: string, abortSignal: AbortSignal): AsyncGenerator<{
169
- txid: any;
170
- scripts: any;
171
- newVtxos: any;
172
- spentVtxos: any;
173
- sweptVtxos: any;
174
- tx: any;
175
- checkpointTxs: any;
176
- }, void, unknown>;
168
+ getSubscription(subscriptionId: string, abortSignal: AbortSignal): AsyncIterableIterator<SubscriptionResponse>;
177
169
  getVirtualTxs(txids: string[], opts?: PaginationOptions): Promise<{
178
170
  txs: string[];
179
171
  page?: PageResponse;
@@ -49,8 +49,12 @@ export interface OnchainProvider {
49
49
  */
50
50
  export declare class EsploraProvider implements OnchainProvider {
51
51
  private baseUrl;
52
- private polling;
53
- constructor(baseUrl: string);
52
+ readonly pollingInterval: number;
53
+ readonly forcePolling: boolean;
54
+ constructor(baseUrl: string, opts?: {
55
+ pollingInterval?: number;
56
+ forcePolling?: boolean;
57
+ });
54
58
  getCoins(address: string): Promise<Coin[]>;
55
59
  getFeeRate(): Promise<number | undefined>;
56
60
  broadcastTransaction(...txs: string[]): Promise<string>;
@@ -1,17 +1,19 @@
1
1
  import { StorageAdapter } from "../storage";
2
- import { ArkTransaction, ExtendedVirtualCoin } from "../wallet";
2
+ import { ArkTransaction, ExtendedCoin, ExtendedVirtualCoin } from "../wallet";
3
3
  export interface WalletState {
4
4
  lastSyncTime?: number;
5
5
  settings?: Record<string, any>;
6
6
  }
7
7
  export interface WalletRepository {
8
8
  getVtxos(address: string): Promise<ExtendedVirtualCoin[]>;
9
- saveVtxo(address: string, vtxo: ExtendedVirtualCoin): Promise<void>;
10
9
  saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise<void>;
11
10
  removeVtxo(address: string, vtxoId: string): Promise<void>;
12
11
  clearVtxos(address: string): Promise<void>;
12
+ getUtxos(address: string): Promise<ExtendedCoin[]>;
13
+ saveUtxos(address: string, utxos: ExtendedCoin[]): Promise<void>;
14
+ removeUtxo(address: string, utxoId: string): Promise<void>;
15
+ clearUtxos(address: string): Promise<void>;
13
16
  getTransactionHistory(address: string): Promise<ArkTransaction[]>;
14
- saveTransaction(address: string, tx: ArkTransaction): Promise<void>;
15
17
  saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
16
18
  clearTransactions(address: string): Promise<void>;
17
19
  getWalletState(): Promise<WalletState | null>;
@@ -22,12 +24,14 @@ export declare class WalletRepositoryImpl implements WalletRepository {
22
24
  private cache;
23
25
  constructor(storage: StorageAdapter);
24
26
  getVtxos(address: string): Promise<ExtendedVirtualCoin[]>;
25
- saveVtxo(address: string, vtxo: ExtendedVirtualCoin): Promise<void>;
26
27
  saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise<void>;
27
28
  removeVtxo(address: string, vtxoId: string): Promise<void>;
28
29
  clearVtxos(address: string): Promise<void>;
30
+ getUtxos(address: string): Promise<ExtendedCoin[]>;
31
+ saveUtxos(address: string, utxos: ExtendedCoin[]): Promise<void>;
32
+ removeUtxo(address: string, utxoId: string): Promise<void>;
33
+ clearUtxos(address: string): Promise<void>;
29
34
  getTransactionHistory(address: string): Promise<ArkTransaction[]>;
30
- saveTransaction(address: string, tx: ArkTransaction): Promise<void>;
31
35
  saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
32
36
  clearTransactions(address: string): Promise<void>;
33
37
  getWalletState(): Promise<WalletState | null>;
@@ -1,4 +1,6 @@
1
- import { BTC_NETWORK, Bytes } from "@scure/btc-signer/utils.js";
1
+ import { NETWORK } from "@scure/btc-signer";
2
+ import { PSBTOutput } from "@scure/btc-signer/psbt.js";
3
+ import { Bytes } from "@scure/btc-signer/utils.js";
2
4
  import { ArkAddress } from "./address";
3
5
  import { ConditionCSVMultisigTapscript, CSVMultisigTapscript } from "./tapscript";
4
6
  export type TapLeafScript = [
@@ -9,6 +11,7 @@ export type TapLeafScript = [
9
11
  },
10
12
  Bytes
11
13
  ];
14
+ export declare const TapTreeCoder: (typeof PSBTOutput.tapTree)[2];
12
15
  export declare function scriptFromTapLeafScript(leaf: TapLeafScript): Bytes;
13
16
  /**
14
17
  * VtxoScript is a script that contains a list of tapleaf scripts.
@@ -27,7 +30,7 @@ export declare class VtxoScript {
27
30
  encode(): Bytes;
28
31
  address(prefix: string, serverPubKey: Bytes): ArkAddress;
29
32
  get pkScript(): Bytes;
30
- onchainAddress(network: BTC_NETWORK): string;
33
+ onchainAddress(network: typeof NETWORK): string;
31
34
  findLeaf(scriptHex: string): TapLeafScript;
32
35
  exitPaths(): Array<CSVMultisigTapscript.Type | ConditionCSVMultisigTapscript.Type>;
33
36
  }
@@ -2,14 +2,17 @@ import * as musig2 from "../musig2";
2
2
  import { TxTree } from "./txTree";
3
3
  export declare const ErrMissingVtxoGraph: Error;
4
4
  export declare const ErrMissingAggregateKey: Error;
5
- export type TreeNonces = Map<string, Pick<musig2.Nonces, "pubNonce">>;
5
+ export type Musig2PublicNonce = Pick<musig2.Nonces, "pubNonce">;
6
+ export type TreeNonces = Map<string, Musig2PublicNonce>;
6
7
  export type TreePartialSigs = Map<string, musig2.PartialSig>;
7
8
  export interface SignerSession {
8
- getPublicKey(): Uint8Array;
9
- init(tree: TxTree, scriptRoot: Uint8Array, rootInputAmount: bigint): void;
10
- getNonces(): TreeNonces;
11
- setAggregatedNonces(nonces: TreeNonces): void;
12
- sign(): TreePartialSigs;
9
+ getPublicKey(): Promise<Uint8Array>;
10
+ init(tree: TxTree, scriptRoot: Uint8Array, rootInputAmount: bigint): Promise<void>;
11
+ getNonces(): Promise<TreeNonces>;
12
+ aggregatedNonces(txid: string, noncesByPubkey: TreeNonces): Promise<{
13
+ hasAllNonces: boolean;
14
+ }>;
15
+ sign(): Promise<TreePartialSigs>;
13
16
  }
14
17
  export declare class TreeSignerSession implements SignerSession {
15
18
  private secretKey;
@@ -21,11 +24,13 @@ export declare class TreeSignerSession implements SignerSession {
21
24
  private rootSharedOutputAmount;
22
25
  constructor(secretKey: Uint8Array);
23
26
  static random(): TreeSignerSession;
24
- init(tree: TxTree, scriptRoot: Uint8Array, rootInputAmount: bigint): void;
25
- getPublicKey(): Uint8Array;
26
- getNonces(): TreeNonces;
27
- setAggregatedNonces(nonces: TreeNonces): void;
28
- sign(): TreePartialSigs;
27
+ init(tree: TxTree, scriptRoot: Uint8Array, rootInputAmount: bigint): Promise<void>;
28
+ getPublicKey(): Promise<Uint8Array>;
29
+ getNonces(): Promise<TreeNonces>;
30
+ aggregatedNonces(txid: string, noncesByPubkey: TreeNonces): Promise<{
31
+ hasAllNonces: boolean;
32
+ }>;
33
+ sign(): Promise<TreePartialSigs>;
29
34
  private generateNonces;
30
35
  private signPartial;
31
36
  }
@@ -1,5 +1,5 @@
1
- import { Transaction } from "@scure/btc-signer/transaction.js";
2
- import { TransactionInputUpdate } from "@scure/btc-signer/psbt";
1
+ import { Transaction } from "@scure/btc-signer";
2
+ import { TransactionInputUpdate } from "@scure/btc-signer/psbt.js";
3
3
  export declare const ANCHOR_VALUE = 0n;
4
4
  export declare const ANCHOR_PKSCRIPT: Uint8Array<ArrayBuffer>;
5
5
  /**
@@ -1,13 +1,11 @@
1
- import { Transaction } from "@scure/btc-signer/transaction.js";
1
+ import { TransactionOutput } from "@scure/btc-signer/psbt.js";
2
2
  import { ExtendedCoin, VirtualCoin } from "../wallet";
3
3
  import { RelativeTimelock } from "../script/tapscript";
4
4
  import { EncodedVtxoScript, TapLeafScript } from "../script/base";
5
5
  import { CSVMultisigTapscript } from "../script/tapscript";
6
- import { TransactionOutput } from "@scure/btc-signer/psbt.js";
7
- import { Bytes } from "@scure/btc-signer/utils.js";
6
+ import { Transaction } from "./transaction";
8
7
  export type ArkTxInput = {
9
8
  tapLeafScript: TapLeafScript;
10
- checkpointTapLeafScript?: Bytes;
11
9
  } & EncodedVtxoScript & Pick<VirtualCoin, "txid" | "vout" | "value">;
12
10
  export type OffchainTx = {
13
11
  arkTx: Transaction;
@@ -27,3 +25,13 @@ export type OffchainTx = {
27
25
  */
28
26
  export declare function buildOffchainTx(inputs: ArkTxInput[], outputs: TransactionOutput[], serverUnrollScript: CSVMultisigTapscript.Type): OffchainTx;
29
27
  export declare function hasBoardingTxExpired(coin: ExtendedCoin, boardingTimelock: RelativeTimelock): boolean;
28
+ /**
29
+ * Verify tapscript signatures on a transaction input
30
+ * @param tx Transaction to verify
31
+ * @param inputIndex Index of the input to verify
32
+ * @param requiredSigners List of required signer pubkeys (hex encoded)
33
+ * @param excludePubkeys List of pubkeys to exclude from verification (hex encoded, e.g., server key not yet signed)
34
+ * @param allowedSighashTypes List of allowed sighash types (defaults to [SigHash.DEFAULT])
35
+ * @throws Error if verification fails
36
+ */
37
+ export declare function verifyTapscriptSignatures(tx: Transaction, inputIndex: number, requiredSigners: string[], excludePubkeys?: string[], allowedSighashTypes?: number[]): void;
@@ -0,0 +1,13 @@
1
+ import { Transaction as BtcSignerTransaction } from "@scure/btc-signer";
2
+ import { TxOpts } from "@scure/btc-signer/transaction";
3
+ import { Bytes } from "@scure/btc-signer/utils";
4
+ /**
5
+ * Transaction is a wrapper around the @scure/btc-signer Transaction class.
6
+ * It adds the Ark protocol specific options to the transaction.
7
+ */
8
+ export declare class Transaction extends BtcSignerTransaction {
9
+ static ARK_TX_OPTS: TxOpts;
10
+ constructor(opts?: TxOpts);
11
+ static fromPSBT(psbt_: Bytes, opts?: TxOpts): Transaction;
12
+ static fromRaw(raw: Bytes, opts?: TxOpts): Transaction;
13
+ }
@@ -1,5 +1,5 @@
1
- import { Transaction } from "@scure/btc-signer/transaction.js";
2
- import { TransactionInputUpdate } from "@scure/btc-signer/psbt";
1
+ import { Transaction } from "@scure/btc-signer";
2
+ import { TransactionInputUpdate } from "@scure/btc-signer/psbt.js";
3
3
  /**
4
4
  * ArkPsbtFieldKey is the key values for ark psbt fields.
5
5
  */
@@ -11,9 +11,9 @@ export declare enum ArkPsbtFieldKey {
11
11
  }
12
12
  /**
13
13
  * ArkPsbtFieldKeyType is the type of the ark psbt field key.
14
- * Every ark psbt field has key type 255.
14
+ * Every ark psbt field has key type 222.
15
15
  */
16
- export declare const ArkPsbtFieldKeyType = 255;
16
+ export declare const ArkPsbtFieldKeyType = 222;
17
17
  /**
18
18
  * ArkPsbtFieldCoder is the coder for the ark psbt fields.
19
19
  * each type has its own coder.
@@ -1,11 +1,12 @@
1
- import { Output, SettlementEvent, ArkProvider } from "../providers/ark";
2
- import { IndexerProvider } from "../providers/indexer";
3
- import { OnchainProvider } from "../providers/onchain";
1
+ import { Bytes } from "@scure/btc-signer/utils.js";
2
+ import { ArkProvider, Output, SettlementEvent } from "../providers/ark";
4
3
  import { Identity } from "../identity";
5
4
  import { RelativeTimelock } from "../script/tapscript";
6
5
  import { EncodedVtxoScript, TapLeafScript } from "../script/base";
7
- import { Bytes } from "@scure/btc-signer/utils.js";
8
6
  import { StorageAdapter } from "../storage";
7
+ import { RenewalConfig } from "./vtxo-manager";
8
+ import { IndexerProvider } from "../providers/indexer";
9
+ import { OnchainProvider } from "../providers/onchain";
9
10
  /**
10
11
  * Configuration options for wallet initialization.
11
12
  *
@@ -50,6 +51,7 @@ export interface WalletConfig {
50
51
  arkProvider?: ArkProvider;
51
52
  indexerProvider?: IndexerProvider;
52
53
  onchainProvider?: OnchainProvider;
54
+ renewalConfig?: RenewalConfig;
53
55
  }
54
56
  /**
55
57
  * Provider class constructor interface for dependency injection.
@@ -3,8 +3,8 @@ import { Coin, SendBitcoinParams } from ".";
3
3
  import { Identity } from "../identity";
4
4
  import { Network, NetworkName } from "../networks";
5
5
  import { OnchainProvider } from "../providers/onchain";
6
- import { Transaction } from "@scure/btc-signer/transaction.js";
7
6
  import { AnchorBumper } from "../utils/anchor";
7
+ import { Transaction } from "../utils/transaction";
8
8
  /**
9
9
  * Onchain Bitcoin wallet implementation for traditional Bitcoin transactions.
10
10
  *
@@ -1,10 +1,11 @@
1
- import { WalletBalance, VirtualCoin, ArkTransaction, IWallet } from "..";
1
+ import { WalletBalance, VirtualCoin, ArkTransaction, IWallet, Coin } from "..";
2
+ import { ExtendedVirtualCoin } from "../..";
2
3
  import { SettlementEvent } from "../../providers/ark";
3
4
  /**
4
5
  * Response is the namespace that contains the response types for the service worker.
5
6
  */
6
7
  export declare namespace Response {
7
- type Type = "WALLET_INITIALIZED" | "WALLET_RELOADED" | "SETTLE_EVENT" | "SETTLE_SUCCESS" | "ADDRESS" | "BOARDING_ADDRESS" | "BALANCE" | "VTXOS" | "VIRTUAL_COINS" | "BOARDING_UTXOS" | "SEND_BITCOIN_SUCCESS" | "TRANSACTION_HISTORY" | "WALLET_STATUS" | "ERROR" | "CLEAR_RESPONSE";
8
+ type Type = "WALLET_INITIALIZED" | "WALLET_RELOADED" | "SETTLE_EVENT" | "SETTLE_SUCCESS" | "ADDRESS" | "BOARDING_ADDRESS" | "BALANCE" | "VTXOS" | "VIRTUAL_COINS" | "BOARDING_UTXOS" | "SEND_BITCOIN_SUCCESS" | "TRANSACTION_HISTORY" | "WALLET_STATUS" | "ERROR" | "CLEAR_RESPONSE" | "VTXO_UPDATE" | "UTXO_UPDATE";
8
9
  interface Base {
9
10
  type: Type;
10
11
  success: boolean;
@@ -106,4 +107,17 @@ export declare namespace Response {
106
107
  }
107
108
  function isWalletReloaded(response: Base): response is WalletReloaded;
108
109
  function walletReloaded(id: string, success: boolean): WalletReloaded;
110
+ interface VtxoUpdate extends Base {
111
+ type: "VTXO_UPDATE";
112
+ spentVtxos: ExtendedVirtualCoin[];
113
+ newVtxos: ExtendedVirtualCoin[];
114
+ }
115
+ function isVtxoUpdate(response: Base): response is VtxoUpdate;
116
+ function vtxoUpdate(newVtxos: ExtendedVirtualCoin[], spentVtxos: ExtendedVirtualCoin[]): VtxoUpdate;
117
+ interface UtxoUpdate extends Base {
118
+ type: "UTXO_UPDATE";
119
+ coins: Coin[];
120
+ }
121
+ function isUtxoUpdate(response: Base): response is UtxoUpdate;
122
+ function utxoUpdate(coins: Coin[]): UtxoUpdate;
109
123
  }
@@ -1,3 +1,4 @@
1
+ export declare const DEFAULT_DB_NAME = "arkade-service-worker";
1
2
  /**
2
3
  * setupServiceWorker sets up the service worker.
3
4
  * @param path - the path to the service worker script
@@ -2,7 +2,6 @@ import { IWallet, WalletBalance, SendBitcoinParams, SettleParams, ArkTransaction
2
2
  import { Response } from "./response";
3
3
  import { SettlementEvent } from "../../providers/ark";
4
4
  import { Identity } from "../../identity";
5
- import { StorageAdapter } from "../../storage";
6
5
  import { WalletRepository } from "../../repositories/walletRepository";
7
6
  import { ContractRepository } from "../../repositories/contractRepository";
8
7
  export type PrivateKeyIdentity = Identity & {
@@ -44,8 +43,9 @@ interface ServiceWorkerWalletOptions {
44
43
  arkServerPublicKey?: string;
45
44
  arkServerUrl: string;
46
45
  esploraUrl?: string;
46
+ dbName?: string;
47
+ dbVersion?: number;
47
48
  identity: PrivateKeyIdentity;
48
- storage?: StorageAdapter;
49
49
  }
50
50
  export type ServiceWorkerWalletCreateOptions = ServiceWorkerWalletOptions & {
51
51
  serviceWorker: ServiceWorker;
@@ -3,6 +3,8 @@
3
3
  * it aims to be run in a service worker context
4
4
  */
5
5
  export declare class Worker {
6
+ readonly dbName: string;
7
+ readonly dbVersion: number;
6
8
  private readonly messageCallback;
7
9
  private wallet;
8
10
  private arkProvider;
@@ -10,7 +12,7 @@ export declare class Worker {
10
12
  private incomingFundsSubscription;
11
13
  private walletRepository;
12
14
  private storage;
13
- constructor(messageCallback?: (message: ExtendableMessageEvent) => void);
15
+ constructor(dbName?: string, dbVersion?: number, messageCallback?: (message: ExtendableMessageEvent) => void);
14
16
  /**
15
17
  * Get spendable vtxos for the current wallet address
16
18
  */
@@ -23,6 +25,10 @@ export declare class Worker {
23
25
  * Get all vtxos categorized by type
24
26
  */
25
27
  private getAllVtxos;
28
+ /**
29
+ * Get all boarding utxos from wallet repository
30
+ */
31
+ private getAllBoardingUtxos;
26
32
  start(withServiceWorkerUpdate?: boolean): Promise<void>;
27
33
  clear(): Promise<void>;
28
34
  reload(): Promise<void>;
@@ -1,9 +1,9 @@
1
- import { Transaction } from "@scure/btc-signer/transaction.js";
2
1
  import { ChainTx, IndexerProvider } from "../providers/indexer";
3
2
  import { AnchorBumper } from "../utils/anchor";
4
3
  import { OnchainProvider } from "../providers/onchain";
5
4
  import { Outpoint } from ".";
6
5
  import { Wallet } from "./wallet";
6
+ import { Transaction } from "../utils/transaction";
7
7
  export declare namespace Unroll {
8
8
  enum StepType {
9
9
  UNROLL = 0,
@@ -1,2 +1,3 @@
1
- import type { ExtendedVirtualCoin, VirtualCoin, Wallet } from "..";
1
+ import type { Coin, ExtendedCoin, ExtendedVirtualCoin, VirtualCoin, Wallet } from "..";
2
2
  export declare function extendVirtualCoin(wallet: Wallet, vtxo: VirtualCoin): ExtendedVirtualCoin;
3
+ export declare function extendCoin(wallet: Wallet, utxo: Coin): ExtendedCoin;