@arkade-os/sdk 0.3.0-alpha.7 → 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 (109) hide show
  1. package/README.md +99 -14
  2. package/dist/cjs/adapters/expo.js +8 -0
  3. package/dist/cjs/arknote/index.js +3 -3
  4. package/dist/cjs/forfeit.js +2 -2
  5. package/dist/cjs/identity/singleKey.js +8 -8
  6. package/dist/cjs/index.js +14 -5
  7. package/dist/cjs/{bip322 → intent}/index.js +38 -61
  8. package/dist/cjs/musig2/index.js +2 -1
  9. package/dist/cjs/musig2/nonces.js +4 -0
  10. package/dist/cjs/providers/ark.js +76 -45
  11. package/dist/cjs/providers/errors.js +59 -0
  12. package/dist/cjs/providers/expoArk.js +82 -0
  13. package/dist/cjs/providers/expoIndexer.js +105 -0
  14. package/dist/cjs/providers/expoUtils.js +124 -0
  15. package/dist/cjs/providers/indexer.js +3 -1
  16. package/dist/cjs/providers/onchain.js +19 -20
  17. package/dist/cjs/repositories/walletRepository.js +64 -28
  18. package/dist/cjs/script/base.js +15 -7
  19. package/dist/cjs/script/tapscript.js +20 -21
  20. package/dist/cjs/script/vhtlc.js +2 -2
  21. package/dist/cjs/tree/signingSession.js +44 -11
  22. package/dist/cjs/tree/txTree.js +3 -4
  23. package/dist/cjs/tree/validation.js +2 -3
  24. package/dist/cjs/utils/arkTransaction.js +118 -15
  25. package/dist/cjs/utils/transaction.js +28 -0
  26. package/dist/cjs/utils/unknownFields.js +7 -7
  27. package/dist/cjs/wallet/index.js +1 -1
  28. package/dist/cjs/wallet/onchain.js +6 -7
  29. package/dist/cjs/wallet/serviceWorker/response.js +32 -0
  30. package/dist/cjs/wallet/serviceWorker/utils.js +2 -9
  31. package/dist/cjs/wallet/serviceWorker/wallet.js +7 -8
  32. package/dist/cjs/wallet/serviceWorker/worker.js +48 -32
  33. package/dist/cjs/wallet/unroll.js +7 -9
  34. package/dist/cjs/wallet/utils.js +20 -0
  35. package/dist/cjs/wallet/vtxo-manager.js +323 -0
  36. package/dist/cjs/wallet/wallet.js +165 -174
  37. package/dist/esm/adapters/expo.js +3 -0
  38. package/dist/esm/arknote/index.js +2 -2
  39. package/dist/esm/forfeit.js +1 -1
  40. package/dist/esm/identity/singleKey.js +9 -9
  41. package/dist/esm/index.js +14 -10
  42. package/dist/esm/{bip322 → intent}/index.js +32 -54
  43. package/dist/esm/musig2/index.js +1 -1
  44. package/dist/esm/musig2/nonces.js +3 -0
  45. package/dist/esm/providers/ark.js +76 -45
  46. package/dist/esm/providers/errors.js +54 -0
  47. package/dist/esm/providers/expoArk.js +78 -0
  48. package/dist/esm/providers/expoIndexer.js +101 -0
  49. package/dist/esm/providers/expoUtils.js +87 -0
  50. package/dist/esm/providers/indexer.js +3 -1
  51. package/dist/esm/providers/onchain.js +19 -20
  52. package/dist/esm/repositories/walletRepository.js +64 -28
  53. package/dist/esm/script/base.js +12 -4
  54. package/dist/esm/script/tapscript.js +1 -2
  55. package/dist/esm/script/vhtlc.js +1 -1
  56. package/dist/esm/tree/signingSession.js +45 -12
  57. package/dist/esm/tree/txTree.js +3 -4
  58. package/dist/esm/tree/validation.js +2 -3
  59. package/dist/esm/utils/arkTransaction.js +110 -9
  60. package/dist/esm/utils/transaction.js +24 -0
  61. package/dist/esm/utils/unknownFields.js +3 -3
  62. package/dist/esm/wallet/index.js +1 -1
  63. package/dist/esm/wallet/onchain.js +3 -4
  64. package/dist/esm/wallet/serviceWorker/response.js +32 -0
  65. package/dist/esm/wallet/serviceWorker/utils.js +1 -8
  66. package/dist/esm/wallet/serviceWorker/wallet.js +8 -9
  67. package/dist/esm/wallet/serviceWorker/worker.js +49 -33
  68. package/dist/esm/wallet/unroll.js +5 -7
  69. package/dist/esm/wallet/utils.js +16 -0
  70. package/dist/esm/wallet/vtxo-manager.js +317 -0
  71. package/dist/esm/wallet/wallet.js +159 -168
  72. package/dist/types/adapters/expo.d.ts +4 -0
  73. package/dist/types/arknote/index.d.ts +1 -1
  74. package/dist/types/forfeit.d.ts +2 -2
  75. package/dist/types/identity/index.d.ts +2 -2
  76. package/dist/types/identity/singleKey.d.ts +2 -2
  77. package/dist/types/index.d.ts +11 -9
  78. package/dist/types/intent/index.d.ts +41 -0
  79. package/dist/types/musig2/index.d.ts +1 -1
  80. package/dist/types/musig2/nonces.d.ts +1 -0
  81. package/dist/types/providers/ark.d.ts +197 -27
  82. package/dist/types/providers/errors.d.ts +13 -0
  83. package/dist/types/providers/expoArk.d.ts +22 -0
  84. package/dist/types/providers/expoIndexer.d.ts +18 -0
  85. package/dist/types/providers/expoUtils.d.ts +18 -0
  86. package/dist/types/providers/indexer.d.ts +8 -8
  87. package/dist/types/providers/onchain.d.ts +6 -2
  88. package/dist/types/repositories/walletRepository.d.ts +9 -5
  89. package/dist/types/script/base.d.ts +5 -2
  90. package/dist/types/tree/signingSession.d.ts +16 -11
  91. package/dist/types/utils/anchor.d.ts +2 -2
  92. package/dist/types/utils/arkTransaction.d.ts +15 -5
  93. package/dist/types/utils/transaction.d.ts +13 -0
  94. package/dist/types/utils/unknownFields.d.ts +4 -4
  95. package/dist/types/wallet/index.d.ts +47 -7
  96. package/dist/types/wallet/onchain.d.ts +1 -1
  97. package/dist/types/wallet/serviceWorker/response.d.ts +16 -2
  98. package/dist/types/wallet/serviceWorker/utils.d.ts +1 -2
  99. package/dist/types/wallet/serviceWorker/wallet.d.ts +2 -2
  100. package/dist/types/wallet/serviceWorker/worker.d.ts +7 -1
  101. package/dist/types/wallet/unroll.d.ts +1 -1
  102. package/dist/types/wallet/utils.d.ts +3 -0
  103. package/dist/types/wallet/vtxo-manager.d.ts +179 -0
  104. package/dist/types/wallet/wallet.d.ts +17 -5
  105. package/package.json +11 -3
  106. package/dist/cjs/bip322/errors.js +0 -13
  107. package/dist/esm/bip322/errors.js +0 -9
  108. package/dist/types/bip322/errors.d.ts +0 -6
  109. package/dist/types/bip322/index.d.ts +0 -57
@@ -1,15 +1,16 @@
1
- import { Transaction } from "@scure/btc-signer/transaction.js";
1
+ import { Transaction } from "./utils/transaction";
2
2
  import { SingleKey } from "./identity/singleKey";
3
3
  import { Identity } from "./identity";
4
4
  import { ArkAddress } from "./script/address";
5
5
  import { VHTLC } from "./script/vhtlc";
6
6
  import { DefaultVtxo } from "./script/default";
7
- import { VtxoScript, EncodedVtxoScript, TapLeafScript } from "./script/base";
8
- import { TxType, IWallet, WalletConfig, ArkTransaction, Coin, ExtendedCoin, ExtendedVirtualCoin, WalletBalance, SendBitcoinParams, Recipient, SettleParams, Status, VirtualStatus, Outpoint, VirtualCoin, TxKey, GetVtxosFilter, TapLeaves } from "./wallet";
7
+ import { VtxoScript, EncodedVtxoScript, TapLeafScript, TapTreeCoder } from "./script/base";
8
+ import { TxType, IWallet, WalletConfig, ProviderClass, ArkTransaction, Coin, ExtendedCoin, ExtendedVirtualCoin, WalletBalance, SendBitcoinParams, Recipient, SettleParams, Status, VirtualStatus, Outpoint, VirtualCoin, TxKey, GetVtxosFilter, TapLeaves } from "./wallet";
9
9
  import { Wallet, waitForIncomingFunds, IncomingFunds } from "./wallet/wallet";
10
10
  import { TxTree, TxTreeNode } from "./tree/txTree";
11
11
  import { SignerSession, TreeNonces, TreePartialSigs } from "./tree/signingSession";
12
12
  import { Ramps } from "./wallet/ramps";
13
+ import { VtxoManager } from "./wallet/vtxo-manager";
13
14
  import { ServiceWorkerWallet } from "./wallet/serviceWorker/wallet";
14
15
  import { OnchainWallet } from "./wallet/onchain";
15
16
  import { setupServiceWorker } from "./wallet/serviceWorker/utils";
@@ -17,19 +18,20 @@ import { Worker } from "./wallet/serviceWorker/worker";
17
18
  import { Request } from "./wallet/serviceWorker/request";
18
19
  import { Response } from "./wallet/serviceWorker/response";
19
20
  import { ESPLORA_URL, EsploraProvider, OnchainProvider, ExplorerTransaction } from "./providers/onchain";
20
- import { RestArkProvider, ArkProvider, SettlementEvent, SettlementEventType, ArkInfo, Intent, Output, TxNotification, BatchFinalizationEvent, BatchFinalizedEvent, BatchFailedEvent, TreeSigningStartedEvent, TreeNoncesAggregatedEvent, BatchStartedEvent, TreeTxEvent, TreeSignatureEvent, MarketHour } from "./providers/ark";
21
+ import { RestArkProvider, ArkProvider, SettlementEvent, SettlementEventType, ArkInfo, SignedIntent, Output, TxNotification, BatchFinalizationEvent, BatchFinalizedEvent, BatchFailedEvent, TreeSigningStartedEvent, TreeNoncesEvent, BatchStartedEvent, TreeTxEvent, TreeSignatureEvent, ScheduledSession } from "./providers/ark";
21
22
  import { CLTVMultisigTapscript, ConditionCSVMultisigTapscript, ConditionMultisigTapscript, CSVMultisigTapscript, decodeTapscript, MultisigTapscript, TapscriptType, ArkTapscript, RelativeTimelock } from "./script/tapscript";
22
- import { buildOffchainTx, ArkTxInput, OffchainTx } from "./utils/arkTransaction";
23
+ import { hasBoardingTxExpired, buildOffchainTx, verifyTapscriptSignatures, ArkTxInput, OffchainTx } from "./utils/arkTransaction";
23
24
  import { VtxoTaprootTree, ConditionWitness, getArkPsbtFields, setArkPsbtField, ArkPsbtFieldCoder, ArkPsbtFieldKey, ArkPsbtFieldKeyType, CosignerPublicKey, VtxoTreeExpiry } from "./utils/unknownFields";
24
- import { BIP322 } from "./bip322";
25
+ import { Intent } from "./intent";
25
26
  import { ArkNote } from "./arknote";
26
27
  import { networks, Network, NetworkName } from "./networks";
27
- import { RestIndexerProvider, IndexerProvider, IndexerTxType, ChainTxType, PageResponse, Batch, ChainTx, CommitmentTx, TxHistoryRecord, VtxoChain, Tx, Vtxo, PaginationOptions, SubscriptionResponse } from "./providers/indexer";
28
+ import { RestIndexerProvider, IndexerProvider, IndexerTxType, ChainTxType, PageResponse, Batch, ChainTx, CommitmentTx, TxHistoryRecord, VtxoChain, Tx, Vtxo, PaginationOptions, SubscriptionResponse, SubscriptionHeartbeat, SubscriptionEvent } from "./providers/indexer";
28
29
  import { Nonces } from "./musig2/nonces";
29
30
  import { PartialSig } from "./musig2/sign";
30
31
  import { AnchorBumper, P2A } from "./utils/anchor";
31
32
  import { Unroll } from "./wallet/unroll";
32
33
  import { WalletRepositoryImpl } from "./repositories/walletRepository";
33
34
  import { ContractRepositoryImpl } from "./repositories/contractRepository";
34
- export { Wallet, SingleKey, OnchainWallet, Ramps, ESPLORA_URL, EsploraProvider, RestArkProvider, RestIndexerProvider, ArkAddress, DefaultVtxo, VtxoScript, VHTLC, TxType, IndexerTxType, ChainTxType, SettlementEventType, setupServiceWorker, Worker, ServiceWorkerWallet, Request, Response, decodeTapscript, MultisigTapscript, CSVMultisigTapscript, ConditionCSVMultisigTapscript, ConditionMultisigTapscript, CLTVMultisigTapscript, ArkPsbtFieldKey, ArkPsbtFieldKeyType, setArkPsbtField, getArkPsbtFields, CosignerPublicKey, VtxoTreeExpiry, VtxoTaprootTree, ConditionWitness, buildOffchainTx, waitForIncomingFunds, ArkNote, networks, WalletRepositoryImpl, ContractRepositoryImpl, BIP322, TxTree, P2A, Unroll, Transaction, };
35
- export type { Identity, IWallet, WalletConfig, ArkTransaction, Coin, ExtendedCoin, ExtendedVirtualCoin, WalletBalance, SendBitcoinParams, Recipient, SettleParams, Status, VirtualStatus, Outpoint, VirtualCoin, TxKey, TapscriptType, ArkTxInput, OffchainTx, TapLeaves, IncomingFunds, IndexerProvider, PageResponse, Batch, ChainTx, CommitmentTx, TxHistoryRecord, Vtxo, VtxoChain, Tx, OnchainProvider, ArkProvider, SettlementEvent, ArkInfo, Intent, Output, TxNotification, ExplorerTransaction, BatchFinalizationEvent, BatchFinalizedEvent, BatchFailedEvent, TreeSigningStartedEvent, TreeNoncesAggregatedEvent, BatchStartedEvent, TreeTxEvent, TreeSignatureEvent, MarketHour, PaginationOptions, SubscriptionResponse, Network, NetworkName, ArkTapscript, RelativeTimelock, EncodedVtxoScript, TapLeafScript, SignerSession, TreeNonces, TreePartialSigs, GetVtxosFilter, Nonces, PartialSig, ArkPsbtFieldCoder, TxTreeNode, AnchorBumper, };
35
+ import { ArkError, maybeArkError } from "./providers/errors";
36
+ export { Wallet, SingleKey, OnchainWallet, Ramps, VtxoManager, ESPLORA_URL, EsploraProvider, RestArkProvider, RestIndexerProvider, ArkAddress, DefaultVtxo, VtxoScript, VHTLC, TxType, IndexerTxType, ChainTxType, SettlementEventType, setupServiceWorker, Worker, ServiceWorkerWallet, Request, Response, decodeTapscript, MultisigTapscript, CSVMultisigTapscript, ConditionCSVMultisigTapscript, ConditionMultisigTapscript, CLTVMultisigTapscript, TapTreeCoder, ArkPsbtFieldKey, ArkPsbtFieldKeyType, setArkPsbtField, getArkPsbtFields, CosignerPublicKey, VtxoTreeExpiry, VtxoTaprootTree, ConditionWitness, buildOffchainTx, verifyTapscriptSignatures, waitForIncomingFunds, hasBoardingTxExpired, ArkNote, networks, WalletRepositoryImpl, ContractRepositoryImpl, Intent, TxTree, P2A, Unroll, Transaction, ArkError, maybeArkError, };
37
+ export type { Identity, IWallet, WalletConfig, ProviderClass, ArkTransaction, Coin, ExtendedCoin, ExtendedVirtualCoin, WalletBalance, SendBitcoinParams, Recipient, SettleParams, Status, VirtualStatus, Outpoint, VirtualCoin, TxKey, TapscriptType, ArkTxInput, OffchainTx, TapLeaves, IncomingFunds, IndexerProvider, PageResponse, Batch, ChainTx, CommitmentTx, TxHistoryRecord, Vtxo, VtxoChain, Tx, OnchainProvider, ArkProvider, SettlementEvent, ArkInfo, SignedIntent, Output, TxNotification, ExplorerTransaction, BatchFinalizationEvent, BatchFinalizedEvent, BatchFailedEvent, TreeSigningStartedEvent, TreeNoncesEvent, BatchStartedEvent, TreeTxEvent, TreeSignatureEvent, ScheduledSession, PaginationOptions, SubscriptionResponse, SubscriptionHeartbeat, SubscriptionEvent, Network, NetworkName, ArkTapscript, RelativeTimelock, EncodedVtxoScript, TapLeafScript, SignerSession, TreeNonces, TreePartialSigs, GetVtxosFilter, Nonces, PartialSig, ArkPsbtFieldCoder, TxTreeNode, AnchorBumper, };
@@ -0,0 +1,41 @@
1
+ import { TransactionInput, TransactionOutput } from "@scure/btc-signer/psbt.js";
2
+ import { Transaction } from "../utils/transaction";
3
+ /**
4
+ * Intent proof implementation for Bitcoin message signing.
5
+ *
6
+ * Intent proof defines a standard for signing Bitcoin messages as well as proving
7
+ * ownership of coins. This namespace provides utilities for creating and
8
+ * validating Intent proof.
9
+ *
10
+ * it is greatly inspired by BIP322.
11
+ * @see https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // Create a Intent proof
16
+ * const proof = Intent.create(
17
+ * "Hello Bitcoin!",
18
+ * [input],
19
+ * [output]
20
+ * );
21
+ *
22
+ * // Sign the proof
23
+ * const signedProof = await identity.sign(proof);
24
+ *
25
+ */
26
+ export declare namespace Intent {
27
+ type Proof = Transaction;
28
+ /**
29
+ * Creates a new Intent proof unsigned transaction.
30
+ *
31
+ * This function constructs a special transaction that can be signed to prove
32
+ * ownership of VTXOs and UTXOs. The proof includes the message to be
33
+ * signed and the inputs/outputs that demonstrate ownership.
34
+ *
35
+ * @param message - The Intent message to be signed
36
+ * @param inputs - Array of transaction inputs to prove ownership of
37
+ * @param outputs - Optional array of transaction outputs
38
+ * @returns An unsigned Intent proof transaction
39
+ */
40
+ function create(message: string, inputs: TransactionInput[], outputs?: TransactionOutput[]): Proof;
41
+ }
@@ -1,4 +1,4 @@
1
1
  export type { Nonces } from "./nonces";
2
- export { generateNonces } from "./nonces";
2
+ export { generateNonces, aggregateNonces } from "./nonces";
3
3
  export { PartialSig, sign } from "./sign";
4
4
  export { aggregateKeys } from "./keys";
@@ -11,3 +11,4 @@ export type Nonces = {
11
11
  * Generates a pair of public and secret nonces for MuSig2 signing
12
12
  */
13
13
  export declare function generateNonces(publicKey: Uint8Array): Nonces;
14
+ export declare function aggregateNonces(pubNonces: Uint8Array[]): Uint8Array;
@@ -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,7 +178,149 @@ export declare class RestArkProvider implements ArkProvider {
150
178
  commitmentTx?: TxNotification;
151
179
  arkTx?: TxNotification;
152
180
  }>;
153
- private parseSettlementEvent;
154
- private parseTransactionNotification;
181
+ getPendingTxs(intent: SignedIntent): Promise<PendingTx[]>;
182
+ protected parseSettlementEvent(data: ProtoTypes.GetEventStreamResponse): SettlementEvent | null;
183
+ protected parseTransactionNotification(data: ProtoTypes.GetTransactionsStreamResponse): {
184
+ commitmentTx?: TxNotification;
185
+ arkTx?: TxNotification;
186
+ } | null;
187
+ }
188
+ declare namespace ProtoTypes {
189
+ interface BatchStartedEvent {
190
+ id: string;
191
+ intentIdHashes: string[];
192
+ batchExpiry: number;
193
+ }
194
+ interface BatchFailed {
195
+ id: string;
196
+ reason: string;
197
+ }
198
+ export interface BatchFinalizationEvent {
199
+ id: string;
200
+ commitmentTx: string;
201
+ }
202
+ interface BatchFinalizedEvent {
203
+ id: string;
204
+ commitmentTxid: string;
205
+ }
206
+ interface TreeSigningStartedEvent {
207
+ id: string;
208
+ cosignersPubkeys: string[];
209
+ unsignedCommitmentTx: string;
210
+ }
211
+ interface TreeNoncesAggregatedEvent {
212
+ id: string;
213
+ treeNonces: Record<string, string>;
214
+ }
215
+ interface TreeNoncesEvent {
216
+ id: string;
217
+ topic: string[];
218
+ txid: string;
219
+ nonces: Record<string, string>;
220
+ }
221
+ interface TreeTxEvent {
222
+ id: string;
223
+ topic: string[];
224
+ batchIndex: number;
225
+ txid: string;
226
+ tx: string;
227
+ children: Record<string, string>;
228
+ }
229
+ interface TreeSignatureEvent {
230
+ id: string;
231
+ topic: string[];
232
+ batchIndex: number;
233
+ txid: string;
234
+ signature: string;
235
+ }
236
+ interface Heartbeat {
237
+ }
238
+ export interface VtxoData {
239
+ outpoint: {
240
+ txid: string;
241
+ vout: number;
242
+ };
243
+ amount: string;
244
+ script: string;
245
+ createdAt: string;
246
+ expiresAt: string | null;
247
+ commitmentTxids: string[];
248
+ isPreconfirmed: boolean;
249
+ isSwept: boolean;
250
+ isUnrolled: boolean;
251
+ isSpent: boolean;
252
+ spentBy: string;
253
+ settledBy?: string;
254
+ arkTxid?: string;
255
+ }
256
+ export interface GetEventStreamResponse {
257
+ batchStarted?: BatchStartedEvent;
258
+ batchFailed?: BatchFailed;
259
+ batchFinalization?: BatchFinalizationEvent;
260
+ batchFinalized?: BatchFinalizedEvent;
261
+ treeSigningStarted?: TreeSigningStartedEvent;
262
+ treeNoncesAggregated?: TreeNoncesAggregatedEvent;
263
+ treeNonces?: TreeNoncesEvent;
264
+ treeTx?: TreeTxEvent;
265
+ treeSignature?: TreeSignatureEvent;
266
+ heartbeat?: Heartbeat;
267
+ }
268
+ export interface GetTransactionsStreamResponse {
269
+ commitmentTx?: {
270
+ txid: string;
271
+ tx: string;
272
+ spentVtxos: VtxoData[];
273
+ spendableVtxos: VtxoData[];
274
+ checkpointTxs?: Record<string, {
275
+ txid: string;
276
+ tx: string;
277
+ }>;
278
+ };
279
+ arkTx?: {
280
+ txid: string;
281
+ tx: string;
282
+ spentVtxos: VtxoData[];
283
+ spendableVtxos: VtxoData[];
284
+ checkpointTxs?: Record<string, {
285
+ txid: string;
286
+ tx: string;
287
+ }>;
288
+ };
289
+ heartbeat?: Heartbeat;
290
+ }
291
+ export interface EventData {
292
+ batchStarted?: BatchStartedEvent;
293
+ batchFailed?: BatchFailed;
294
+ batchFinalization?: BatchFinalizationEvent;
295
+ batchFinalized?: BatchFinalizedEvent;
296
+ treeSigningStarted?: TreeSigningStartedEvent;
297
+ treeNoncesAggregated?: TreeNoncesAggregatedEvent;
298
+ treeTx?: TreeTxEvent;
299
+ treeSignature?: TreeSignatureEvent;
300
+ }
301
+ export interface TransactionData {
302
+ commitmentTx?: {
303
+ txid: string;
304
+ tx: string;
305
+ spentVtxos: VtxoData[];
306
+ spendableVtxos: VtxoData[];
307
+ checkpointTxs?: Record<string, {
308
+ txid: string;
309
+ tx: string;
310
+ }>;
311
+ };
312
+ arkTx?: {
313
+ txid: string;
314
+ tx: string;
315
+ spentVtxos: VtxoData[];
316
+ spendableVtxos: VtxoData[];
317
+ checkpointTxs?: Record<string, {
318
+ txid: string;
319
+ tx: string;
320
+ }>;
321
+ };
322
+ }
323
+ export {};
155
324
  }
156
325
  export declare function isFetchTimeoutError(err: any): boolean;
326
+ export {};
@@ -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;
@@ -0,0 +1,22 @@
1
+ import { RestArkProvider, SettlementEvent, TxNotification } from "./ark";
2
+ /**
3
+ * Expo-compatible Ark provider implementation using expo/fetch for SSE support.
4
+ * This provider works specifically in React Native/Expo environments where
5
+ * standard EventSource is not available but expo/fetch provides SSE capabilities.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { ExpoArkProvider } from '@arkade-os/sdk/providers/expo';
10
+ *
11
+ * const provider = new ExpoArkProvider('https://ark.example.com');
12
+ * const info = await provider.getInfo();
13
+ * ```
14
+ */
15
+ export declare class ExpoArkProvider extends RestArkProvider {
16
+ constructor(serverUrl: string);
17
+ getEventStream(signal: AbortSignal, topics: string[]): AsyncIterableIterator<SettlementEvent>;
18
+ getTransactionsStream(signal: AbortSignal): AsyncIterableIterator<{
19
+ commitmentTx?: TxNotification;
20
+ arkTx?: TxNotification;
21
+ }>;
22
+ }
@@ -0,0 +1,18 @@
1
+ import { RestIndexerProvider, SubscriptionResponse } from "./indexer";
2
+ /**
3
+ * Expo-compatible Indexer provider implementation using expo/fetch for streaming support.
4
+ * This provider works specifically in React Native/Expo environments where
5
+ * standard fetch streaming may not work properly but expo/fetch provides streaming capabilities.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { ExpoIndexerProvider } from '@arkade-os/sdk/adapters/expo';
10
+ *
11
+ * const provider = new ExpoIndexerProvider('https://indexer.example.com');
12
+ * const vtxos = await provider.getVtxos({ scripts: ['script1'] });
13
+ * ```
14
+ */
15
+ export declare class ExpoIndexerProvider extends RestIndexerProvider {
16
+ constructor(serverUrl: string);
17
+ getSubscription(subscriptionId: string, abortSignal: AbortSignal): AsyncIterableIterator<SubscriptionResponse>;
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>;
@@ -80,12 +80,19 @@ export interface SubscriptionResponse {
80
80
  scripts: string[];
81
81
  newVtxos: VirtualCoin[];
82
82
  spentVtxos: VirtualCoin[];
83
+ sweptVtxos: VirtualCoin[];
83
84
  tx?: string;
84
85
  checkpointTxs?: Record<string, {
85
86
  txid: string;
86
87
  tx: string;
87
88
  }>;
88
89
  }
90
+ export interface SubscriptionHeartbeat {
91
+ type: "heartbeat";
92
+ }
93
+ export interface SubscriptionEvent extends SubscriptionResponse {
94
+ type: "event";
95
+ }
89
96
  export interface IndexerProvider {
90
97
  getVtxoTree(batchOutpoint: Outpoint, opts?: PaginationOptions): Promise<{
91
98
  vtxoTree: Tx[];
@@ -158,14 +165,7 @@ export declare class RestIndexerProvider implements IndexerProvider {
158
165
  txids: string[];
159
166
  page?: PageResponse;
160
167
  }>;
161
- getSubscription(subscriptionId: string, abortSignal: AbortSignal): AsyncGenerator<{
162
- txid: any;
163
- scripts: any;
164
- newVtxos: any;
165
- spentVtxos: any;
166
- tx: any;
167
- checkpointTxs: any;
168
- }, void, unknown>;
168
+ getSubscription(subscriptionId: string, abortSignal: AbortSignal): AsyncIterableIterator<SubscriptionResponse>;
169
169
  getVirtualTxs(txids: string[], opts?: PaginationOptions): Promise<{
170
170
  txs: string[];
171
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
  /**