@anywalletkit/wallet-zcash 0.0.0-stage → 0.2.1

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.
@@ -0,0 +1,304 @@
1
+ import { ChainTx, HistoryPage, HistorySource, HistoryQuery } from '@anywalletkit/core';
2
+
3
+ /** Zcash mainnet or testnet. */
4
+ type ZcashNetwork = 'mainnet' | 'testnet';
5
+ /** CAIP-2 ids the SDK uses for Zcash (the swap2 catalog already names `zcash:mainnet`). */
6
+ declare const CAIP2: Record<ZcashNetwork, string>;
7
+ /** An unspent transparent output the account can spend. */
8
+ interface Utxo {
9
+ txid: string;
10
+ vout: number;
11
+ /** Zatoshis. */
12
+ value: bigint;
13
+ /** Block height; -1 while in the mempool. */
14
+ height: number;
15
+ }
16
+ /** A previous output a transaction spends — ZIP-244 signs its value AND script. */
17
+ interface SpentOutput {
18
+ value: bigint;
19
+ script: Uint8Array;
20
+ }
21
+ /** Transport-neutral transaction record (receipts, confirmations). */
22
+ interface ZcashTxInfo {
23
+ txid: string;
24
+ /** -1 or 0 while unconfirmed. */
25
+ blockHeight: number;
26
+ confirmations: number;
27
+ fee?: bigint;
28
+ /** Unix seconds. */
29
+ blockTime?: number;
30
+ }
31
+ /** Minimal chain-data client every transport implements. Values in zatoshis. */
32
+ interface ZcashClient {
33
+ connect(): Promise<void>;
34
+ close(): Promise<void>;
35
+ getBalance(address: string): Promise<{
36
+ confirmed: bigint;
37
+ unconfirmed: bigint;
38
+ }>;
39
+ listUnspent(address: string): Promise<Utxo[]>;
40
+ /** Raw transaction hex (any version — only used to read prevouts and for receipts). */
41
+ getTransaction(txid: string): Promise<string>;
42
+ /** Value + scriptPubKey of one output of an existing transaction (what signing a spend of it needs). */
43
+ getOutput(txid: string, vout: number): Promise<SpentOutput | undefined>;
44
+ getTransactionInfo(txid: string): Promise<ZcashTxInfo | undefined>;
45
+ /** Broadcast raw hex; returns the txid. */
46
+ broadcast(rawTx: string): Promise<string>;
47
+ /** Current chain tip height (expiry height, anti-fee-sniping lock time, consensus branch selection). */
48
+ getBlockHeight(): Promise<number>;
49
+ }
50
+ /** One transport to a Zcash indexer: Blockchair or a Blockbook instance. */
51
+ type ZcashClientConfig =
52
+ /** Blockchair's public REST API (`https://api.blockchair.com/zcash`; optional API key). Mainnet only. */
53
+ {
54
+ type: 'blockchair';
55
+ clientConfig?: {
56
+ url?: string;
57
+ key?: string;
58
+ };
59
+ }
60
+ /** A Zcash Blockbook (NOWNodes `https://zec-blockbook.nownodes.io` with an `api-key` header, a self-hosted instance, …). */
61
+ | {
62
+ type: 'blockbook-http';
63
+ clientConfig: {
64
+ url: string;
65
+ headers?: Record<string, string>;
66
+ };
67
+ };
68
+ /**
69
+ * Options for a Zcash wallet manager or account: transports, network and fee limits. Transparent
70
+ * addresses only.
71
+ */
72
+ interface ZcashConfig {
73
+ /** One or more transports (config objects or ready `ZcashClient`s). A list fails over in order. Omit for an offline (sign-only) wallet. */
74
+ client?: ZcashClientConfig | ZcashClient | Array<ZcashClientConfig | ZcashClient>;
75
+ network?: ZcashNetwork;
76
+ /** Extra attempts across the client list after the first failure (default 3). */
77
+ retries?: number;
78
+ /** Per-request timeout in ms (default 15000). */
79
+ timeoutMs?: number;
80
+ /** Max fee (zatoshis) for `transfer`. */
81
+ transferMaxFee?: bigint | number;
82
+ /** Max fee (zatoshis) for `sendTransaction` / `signTransaction`. */
83
+ transactionMaxFee?: bigint | number;
84
+ /** Hard fee ceiling in zatoshis for any transaction this account signs or broadcasts (default 1 000 000 = 0.01 ZEC). */
85
+ maxFee?: bigint | number;
86
+ /** Blocks after the tip at which an unmined transaction expires (ZIP-203; default 40, the zcashd/Zebra default). 0 = never. */
87
+ expiryDelta?: number;
88
+ /** Set nLockTime to the tip height so the transaction cannot be mined into a reorged block (default true). */
89
+ antiFeeSniping?: boolean;
90
+ /**
91
+ * Consensus branch id to sign under. Default: picked from the tip height
92
+ * (`branchIdForHeight`) — set this when a network upgrade activates before
93
+ * the package learns its id.
94
+ */
95
+ consensusBranchId?: number;
96
+ /** Coin-selection input cap (default 200). */
97
+ maxInputs?: number;
98
+ /** Injectable fetch (tests, custom agents). Defaults to globalThis.fetch. */
99
+ fetch?: typeof fetch;
100
+ }
101
+ /** A spend. `value` in zatoshis. `fee` overrides the ZIP-317 conventional fee (still subject to `maxFee`). */
102
+ interface ZcashSpend {
103
+ to: string;
104
+ value: bigint | number | string;
105
+ fee?: bigint | number;
106
+ }
107
+ /** `sendTransaction` accepts a spend or an already signed raw transaction hex. */
108
+ type ZcashTransaction = ZcashSpend | string;
109
+ /** A transparent ZEC transfer. Amount in zatoshis. */
110
+ interface ZcashTransferOptions {
111
+ /** Not supported on Zcash; present for the shared account interface. */
112
+ token?: string;
113
+ recipient: string;
114
+ amount: bigint | number | string;
115
+ }
116
+ /** A mined Zcash transaction. */
117
+ interface ZcashReceipt {
118
+ hash: string;
119
+ /** Always 1 once mined — a transparent transaction cannot fail after inclusion. */
120
+ status: 1;
121
+ blockNumber: bigint;
122
+ confirmations: number;
123
+ fee?: bigint;
124
+ }
125
+ /** The most one transaction can send (a sweep of every UTXO), after the fee. */
126
+ interface ZcashMaxSpendableResult {
127
+ /** Max zatoshis one transaction can send after the fee. 0n when nothing is spendable. */
128
+ amount: bigint;
129
+ fee: bigint;
130
+ /** Always 0n: a sweep leaves no change. */
131
+ changeValue: bigint;
132
+ inputs: number;
133
+ }
134
+ /** Problems a described transaction is flagged with. */
135
+ type ZcashWarning =
136
+ /** Fee exceeds 10 % of the amount sent. */
137
+ 'fee-over-10pct-of-amount'
138
+ /** Fee is below the ZIP-317 conventional fee — nodes may not relay it. */
139
+ | 'fee-below-conventional'
140
+ /** An output is below the dust floor. */
141
+ | 'dust-output'
142
+ /** Change was below dust and folded into the fee. */
143
+ | 'no-change'
144
+ /** No expiry height: the transaction stays valid in mempools indefinitely. */
145
+ | 'no-expiry';
146
+ /** One input of a described transaction: the UTXO it spends. */
147
+ interface ZcashTxInputDescription {
148
+ txid: string;
149
+ vout: number;
150
+ value: bigint;
151
+ address: string | undefined;
152
+ }
153
+ /** One output of a described transaction, tagged as the recipient, our change, or unknown. */
154
+ interface ZcashTxOutputDescription {
155
+ /** Undefined for scripts without an address form. */
156
+ address: string | undefined;
157
+ value: bigint;
158
+ role: 'recipient' | 'change' | 'unknown';
159
+ }
160
+ /** "What you sign": the fully resolved transaction before (or after) signing. */
161
+ interface ZcashTxDescription {
162
+ kind: 'zcash-transfer';
163
+ version: 5;
164
+ consensusBranchId: number;
165
+ inputs: ZcashTxInputDescription[];
166
+ outputs: ZcashTxOutputDescription[];
167
+ /** Zatoshis sent to non-change outputs. */
168
+ amount: bigint;
169
+ fee: bigint;
170
+ /** The ZIP-317 fee this transaction's shape calls for. */
171
+ conventionalFee: bigint;
172
+ /** Serialized size in bytes. */
173
+ size: number;
174
+ lockTime: number;
175
+ expiryHeight: number;
176
+ /** Present once the transaction is signed. */
177
+ txid?: string;
178
+ warnings: ZcashWarning[];
179
+ }
180
+
181
+ /** Default Blockchair API root for Zcash. */
182
+ declare const BLOCKCHAIR_URL = "https://api.blockchair.com/zcash";
183
+ interface BlockchairTxRow {
184
+ block_id: number;
185
+ hash: string;
186
+ time?: string;
187
+ fee?: number;
188
+ input_count?: number;
189
+ output_count?: number;
190
+ }
191
+ interface BlockchairOutput {
192
+ index: number;
193
+ value: number;
194
+ script_hex: string;
195
+ recipient?: string;
196
+ }
197
+ interface BlockchairInput extends BlockchairOutput {
198
+ transaction_hash: string;
199
+ spending_index?: number;
200
+ spending_sequence?: number;
201
+ }
202
+ interface BlockchairTxDashboard {
203
+ transaction: BlockchairTxRow;
204
+ inputs: BlockchairInput[];
205
+ outputs: BlockchairOutput[];
206
+ }
207
+ /** "2026-10-18 10:05:14" (UTC) → unix seconds. */
208
+ declare function blockchairTime(s: string | undefined): number | undefined;
209
+ declare class BlockchairClient implements ZcashClient {
210
+ private readonly base;
211
+ private readonly key;
212
+ private readonly fetchFn;
213
+ private readonly timeoutMs;
214
+ constructor(config?: {
215
+ url?: string;
216
+ key?: string;
217
+ }, fetchFn?: typeof fetch, timeoutMs?: number);
218
+ connect(): Promise<void>;
219
+ close(): Promise<void>;
220
+ private url;
221
+ private request;
222
+ private dashboard;
223
+ /** Transaction hashes of an address, newest first, paged by offset (what the activity history walks). */
224
+ listTransactions(address: string, limit: number, offset: number): Promise<{
225
+ hashes: string[];
226
+ total: number | undefined;
227
+ }>;
228
+ /** Confirmed = the UTXOs mined so far; unconfirmed = incoming mempool outputs. (Beyond 1000 UTXOs the dashboard balance is used.) */
229
+ getBalance(address: string): Promise<{
230
+ confirmed: bigint;
231
+ unconfirmed: bigint;
232
+ }>;
233
+ listUnspent(address: string): Promise<Utxo[]>;
234
+ getTransaction(txid: string): Promise<string>;
235
+ /** Inputs / outputs with addresses, values and scripts — what the activity history and prevout lookups read. */
236
+ getTransactionDashboard(txid: string): Promise<BlockchairTxDashboard | undefined>;
237
+ /** Several transactions in one call (Blockchair takes up to 10 comma-separated hashes). */
238
+ getTransactionDashboards(txids: string[]): Promise<Map<string, BlockchairTxDashboard>>;
239
+ getOutput(txid: string, vout: number): Promise<SpentOutput | undefined>;
240
+ getTransactionInfo(txid: string): Promise<ZcashTxInfo | undefined>;
241
+ broadcast(rawTx: string): Promise<string>;
242
+ getBlockHeight(): Promise<number>;
243
+ }
244
+
245
+ /**
246
+ * Activity history for Zcash transparent addresses: a `HistorySource` over
247
+ * Blockchair's address dashboard (transaction hashes, newest first) and
248
+ * transaction dashboards (inputs / outputs with addresses and values, fetched
249
+ * ten at a time). Shielded legs of a transaction show up only as the
250
+ * transparent value that entered or left it.
251
+ */
252
+
253
+ /** Options for {@link createZcashHistory}. */
254
+ interface ZcashHistoryOptions {
255
+ /** Blockchair base (`https://api.blockchair.com/zcash`); optional API key. */
256
+ blockchairUrl?: string;
257
+ key?: string;
258
+ fetch?: typeof fetch;
259
+ timeoutMs?: number;
260
+ /** Rows per page (max 100). Default: the query limit, capped at 100. */
261
+ pageSize?: number;
262
+ }
263
+ interface ZcashHistoryRaw {
264
+ tx: BlockchairTxDashboard;
265
+ ownIn: bigint;
266
+ ownOut: bigint;
267
+ }
268
+ interface ZcashChainTx extends ChainTx {
269
+ raw: ZcashHistoryRaw;
270
+ }
271
+ interface ZcashHistoryPage extends HistoryPage {
272
+ items: ZcashChainTx[];
273
+ offset: number;
274
+ total?: number;
275
+ }
276
+ /** Zcash transparent-address history from Blockchair. Build it with {@link createZcashHistory}. */
277
+ interface ZcashHistorySource extends HistorySource {
278
+ listActivity(address: string, query?: HistoryQuery): Promise<ZcashHistoryPage>;
279
+ getTransaction(hash: string, address: string): Promise<ZcashChainTx | undefined>;
280
+ }
281
+ /** The history backend failed. */
282
+ declare class HistoryUnavailableError extends Error {
283
+ readonly chain: string;
284
+ readonly reason: string;
285
+ constructor(chain: string, reason: string);
286
+ }
287
+ interface ZcashHistoryCursor {
288
+ v: 1;
289
+ o: number;
290
+ s: number;
291
+ }
292
+ declare function encodeCursor(c: ZcashHistoryCursor): string;
293
+ declare function decodeCursor(s: string): ZcashHistoryCursor;
294
+ declare function mapDashboardTx(chain: string, address: string, d: BlockchairTxDashboard): ZcashChainTx;
295
+ /** Blockchair link for a transaction. */
296
+ declare function zcashExplorerTxUrl(hash: string): string;
297
+ /**
298
+ * A history source for transparent Zcash addresses backed by Blockchair (mainnet).
299
+ *
300
+ * @throws Error when no `fetch` is available.
301
+ */
302
+ declare function createZcashHistory(options?: ZcashHistoryOptions): ZcashHistorySource;
303
+
304
+ export { zcashExplorerTxUrl as A, BLOCKCHAIR_URL as B, CAIP2 as C, HistoryUnavailableError as H, type SpentOutput as S, type Utxo as U, type ZcashNetwork as Z, type ZcashTxDescription as a, type ZcashClient as b, type ZcashTxInfo as c, type ZcashConfig as d, type ZcashSpend as e, type ZcashTransferOptions as f, type ZcashMaxSpendableResult as g, type ZcashReceipt as h, type ZcashTransaction as i, BlockchairClient as j, type BlockchairTxDashboard as k, type ZcashChainTx as l, type ZcashClientConfig as m, type ZcashHistoryCursor as n, type ZcashHistoryOptions as o, type ZcashHistoryPage as p, type ZcashHistoryRaw as q, type ZcashHistorySource as r, type ZcashTxInputDescription as s, type ZcashTxOutputDescription as t, type ZcashWarning as u, blockchairTime as v, createZcashHistory as w, decodeCursor as x, encodeCursor as y, mapDashboardTx as z };
@@ -0,0 +1,304 @@
1
+ import { ChainTx, HistoryPage, HistorySource, HistoryQuery } from '@anywalletkit/core';
2
+
3
+ /** Zcash mainnet or testnet. */
4
+ type ZcashNetwork = 'mainnet' | 'testnet';
5
+ /** CAIP-2 ids the SDK uses for Zcash (the swap2 catalog already names `zcash:mainnet`). */
6
+ declare const CAIP2: Record<ZcashNetwork, string>;
7
+ /** An unspent transparent output the account can spend. */
8
+ interface Utxo {
9
+ txid: string;
10
+ vout: number;
11
+ /** Zatoshis. */
12
+ value: bigint;
13
+ /** Block height; -1 while in the mempool. */
14
+ height: number;
15
+ }
16
+ /** A previous output a transaction spends — ZIP-244 signs its value AND script. */
17
+ interface SpentOutput {
18
+ value: bigint;
19
+ script: Uint8Array;
20
+ }
21
+ /** Transport-neutral transaction record (receipts, confirmations). */
22
+ interface ZcashTxInfo {
23
+ txid: string;
24
+ /** -1 or 0 while unconfirmed. */
25
+ blockHeight: number;
26
+ confirmations: number;
27
+ fee?: bigint;
28
+ /** Unix seconds. */
29
+ blockTime?: number;
30
+ }
31
+ /** Minimal chain-data client every transport implements. Values in zatoshis. */
32
+ interface ZcashClient {
33
+ connect(): Promise<void>;
34
+ close(): Promise<void>;
35
+ getBalance(address: string): Promise<{
36
+ confirmed: bigint;
37
+ unconfirmed: bigint;
38
+ }>;
39
+ listUnspent(address: string): Promise<Utxo[]>;
40
+ /** Raw transaction hex (any version — only used to read prevouts and for receipts). */
41
+ getTransaction(txid: string): Promise<string>;
42
+ /** Value + scriptPubKey of one output of an existing transaction (what signing a spend of it needs). */
43
+ getOutput(txid: string, vout: number): Promise<SpentOutput | undefined>;
44
+ getTransactionInfo(txid: string): Promise<ZcashTxInfo | undefined>;
45
+ /** Broadcast raw hex; returns the txid. */
46
+ broadcast(rawTx: string): Promise<string>;
47
+ /** Current chain tip height (expiry height, anti-fee-sniping lock time, consensus branch selection). */
48
+ getBlockHeight(): Promise<number>;
49
+ }
50
+ /** One transport to a Zcash indexer: Blockchair or a Blockbook instance. */
51
+ type ZcashClientConfig =
52
+ /** Blockchair's public REST API (`https://api.blockchair.com/zcash`; optional API key). Mainnet only. */
53
+ {
54
+ type: 'blockchair';
55
+ clientConfig?: {
56
+ url?: string;
57
+ key?: string;
58
+ };
59
+ }
60
+ /** A Zcash Blockbook (NOWNodes `https://zec-blockbook.nownodes.io` with an `api-key` header, a self-hosted instance, …). */
61
+ | {
62
+ type: 'blockbook-http';
63
+ clientConfig: {
64
+ url: string;
65
+ headers?: Record<string, string>;
66
+ };
67
+ };
68
+ /**
69
+ * Options for a Zcash wallet manager or account: transports, network and fee limits. Transparent
70
+ * addresses only.
71
+ */
72
+ interface ZcashConfig {
73
+ /** One or more transports (config objects or ready `ZcashClient`s). A list fails over in order. Omit for an offline (sign-only) wallet. */
74
+ client?: ZcashClientConfig | ZcashClient | Array<ZcashClientConfig | ZcashClient>;
75
+ network?: ZcashNetwork;
76
+ /** Extra attempts across the client list after the first failure (default 3). */
77
+ retries?: number;
78
+ /** Per-request timeout in ms (default 15000). */
79
+ timeoutMs?: number;
80
+ /** Max fee (zatoshis) for `transfer`. */
81
+ transferMaxFee?: bigint | number;
82
+ /** Max fee (zatoshis) for `sendTransaction` / `signTransaction`. */
83
+ transactionMaxFee?: bigint | number;
84
+ /** Hard fee ceiling in zatoshis for any transaction this account signs or broadcasts (default 1 000 000 = 0.01 ZEC). */
85
+ maxFee?: bigint | number;
86
+ /** Blocks after the tip at which an unmined transaction expires (ZIP-203; default 40, the zcashd/Zebra default). 0 = never. */
87
+ expiryDelta?: number;
88
+ /** Set nLockTime to the tip height so the transaction cannot be mined into a reorged block (default true). */
89
+ antiFeeSniping?: boolean;
90
+ /**
91
+ * Consensus branch id to sign under. Default: picked from the tip height
92
+ * (`branchIdForHeight`) — set this when a network upgrade activates before
93
+ * the package learns its id.
94
+ */
95
+ consensusBranchId?: number;
96
+ /** Coin-selection input cap (default 200). */
97
+ maxInputs?: number;
98
+ /** Injectable fetch (tests, custom agents). Defaults to globalThis.fetch. */
99
+ fetch?: typeof fetch;
100
+ }
101
+ /** A spend. `value` in zatoshis. `fee` overrides the ZIP-317 conventional fee (still subject to `maxFee`). */
102
+ interface ZcashSpend {
103
+ to: string;
104
+ value: bigint | number | string;
105
+ fee?: bigint | number;
106
+ }
107
+ /** `sendTransaction` accepts a spend or an already signed raw transaction hex. */
108
+ type ZcashTransaction = ZcashSpend | string;
109
+ /** A transparent ZEC transfer. Amount in zatoshis. */
110
+ interface ZcashTransferOptions {
111
+ /** Not supported on Zcash; present for the shared account interface. */
112
+ token?: string;
113
+ recipient: string;
114
+ amount: bigint | number | string;
115
+ }
116
+ /** A mined Zcash transaction. */
117
+ interface ZcashReceipt {
118
+ hash: string;
119
+ /** Always 1 once mined — a transparent transaction cannot fail after inclusion. */
120
+ status: 1;
121
+ blockNumber: bigint;
122
+ confirmations: number;
123
+ fee?: bigint;
124
+ }
125
+ /** The most one transaction can send (a sweep of every UTXO), after the fee. */
126
+ interface ZcashMaxSpendableResult {
127
+ /** Max zatoshis one transaction can send after the fee. 0n when nothing is spendable. */
128
+ amount: bigint;
129
+ fee: bigint;
130
+ /** Always 0n: a sweep leaves no change. */
131
+ changeValue: bigint;
132
+ inputs: number;
133
+ }
134
+ /** Problems a described transaction is flagged with. */
135
+ type ZcashWarning =
136
+ /** Fee exceeds 10 % of the amount sent. */
137
+ 'fee-over-10pct-of-amount'
138
+ /** Fee is below the ZIP-317 conventional fee — nodes may not relay it. */
139
+ | 'fee-below-conventional'
140
+ /** An output is below the dust floor. */
141
+ | 'dust-output'
142
+ /** Change was below dust and folded into the fee. */
143
+ | 'no-change'
144
+ /** No expiry height: the transaction stays valid in mempools indefinitely. */
145
+ | 'no-expiry';
146
+ /** One input of a described transaction: the UTXO it spends. */
147
+ interface ZcashTxInputDescription {
148
+ txid: string;
149
+ vout: number;
150
+ value: bigint;
151
+ address: string | undefined;
152
+ }
153
+ /** One output of a described transaction, tagged as the recipient, our change, or unknown. */
154
+ interface ZcashTxOutputDescription {
155
+ /** Undefined for scripts without an address form. */
156
+ address: string | undefined;
157
+ value: bigint;
158
+ role: 'recipient' | 'change' | 'unknown';
159
+ }
160
+ /** "What you sign": the fully resolved transaction before (or after) signing. */
161
+ interface ZcashTxDescription {
162
+ kind: 'zcash-transfer';
163
+ version: 5;
164
+ consensusBranchId: number;
165
+ inputs: ZcashTxInputDescription[];
166
+ outputs: ZcashTxOutputDescription[];
167
+ /** Zatoshis sent to non-change outputs. */
168
+ amount: bigint;
169
+ fee: bigint;
170
+ /** The ZIP-317 fee this transaction's shape calls for. */
171
+ conventionalFee: bigint;
172
+ /** Serialized size in bytes. */
173
+ size: number;
174
+ lockTime: number;
175
+ expiryHeight: number;
176
+ /** Present once the transaction is signed. */
177
+ txid?: string;
178
+ warnings: ZcashWarning[];
179
+ }
180
+
181
+ /** Default Blockchair API root for Zcash. */
182
+ declare const BLOCKCHAIR_URL = "https://api.blockchair.com/zcash";
183
+ interface BlockchairTxRow {
184
+ block_id: number;
185
+ hash: string;
186
+ time?: string;
187
+ fee?: number;
188
+ input_count?: number;
189
+ output_count?: number;
190
+ }
191
+ interface BlockchairOutput {
192
+ index: number;
193
+ value: number;
194
+ script_hex: string;
195
+ recipient?: string;
196
+ }
197
+ interface BlockchairInput extends BlockchairOutput {
198
+ transaction_hash: string;
199
+ spending_index?: number;
200
+ spending_sequence?: number;
201
+ }
202
+ interface BlockchairTxDashboard {
203
+ transaction: BlockchairTxRow;
204
+ inputs: BlockchairInput[];
205
+ outputs: BlockchairOutput[];
206
+ }
207
+ /** "2026-10-18 10:05:14" (UTC) → unix seconds. */
208
+ declare function blockchairTime(s: string | undefined): number | undefined;
209
+ declare class BlockchairClient implements ZcashClient {
210
+ private readonly base;
211
+ private readonly key;
212
+ private readonly fetchFn;
213
+ private readonly timeoutMs;
214
+ constructor(config?: {
215
+ url?: string;
216
+ key?: string;
217
+ }, fetchFn?: typeof fetch, timeoutMs?: number);
218
+ connect(): Promise<void>;
219
+ close(): Promise<void>;
220
+ private url;
221
+ private request;
222
+ private dashboard;
223
+ /** Transaction hashes of an address, newest first, paged by offset (what the activity history walks). */
224
+ listTransactions(address: string, limit: number, offset: number): Promise<{
225
+ hashes: string[];
226
+ total: number | undefined;
227
+ }>;
228
+ /** Confirmed = the UTXOs mined so far; unconfirmed = incoming mempool outputs. (Beyond 1000 UTXOs the dashboard balance is used.) */
229
+ getBalance(address: string): Promise<{
230
+ confirmed: bigint;
231
+ unconfirmed: bigint;
232
+ }>;
233
+ listUnspent(address: string): Promise<Utxo[]>;
234
+ getTransaction(txid: string): Promise<string>;
235
+ /** Inputs / outputs with addresses, values and scripts — what the activity history and prevout lookups read. */
236
+ getTransactionDashboard(txid: string): Promise<BlockchairTxDashboard | undefined>;
237
+ /** Several transactions in one call (Blockchair takes up to 10 comma-separated hashes). */
238
+ getTransactionDashboards(txids: string[]): Promise<Map<string, BlockchairTxDashboard>>;
239
+ getOutput(txid: string, vout: number): Promise<SpentOutput | undefined>;
240
+ getTransactionInfo(txid: string): Promise<ZcashTxInfo | undefined>;
241
+ broadcast(rawTx: string): Promise<string>;
242
+ getBlockHeight(): Promise<number>;
243
+ }
244
+
245
+ /**
246
+ * Activity history for Zcash transparent addresses: a `HistorySource` over
247
+ * Blockchair's address dashboard (transaction hashes, newest first) and
248
+ * transaction dashboards (inputs / outputs with addresses and values, fetched
249
+ * ten at a time). Shielded legs of a transaction show up only as the
250
+ * transparent value that entered or left it.
251
+ */
252
+
253
+ /** Options for {@link createZcashHistory}. */
254
+ interface ZcashHistoryOptions {
255
+ /** Blockchair base (`https://api.blockchair.com/zcash`); optional API key. */
256
+ blockchairUrl?: string;
257
+ key?: string;
258
+ fetch?: typeof fetch;
259
+ timeoutMs?: number;
260
+ /** Rows per page (max 100). Default: the query limit, capped at 100. */
261
+ pageSize?: number;
262
+ }
263
+ interface ZcashHistoryRaw {
264
+ tx: BlockchairTxDashboard;
265
+ ownIn: bigint;
266
+ ownOut: bigint;
267
+ }
268
+ interface ZcashChainTx extends ChainTx {
269
+ raw: ZcashHistoryRaw;
270
+ }
271
+ interface ZcashHistoryPage extends HistoryPage {
272
+ items: ZcashChainTx[];
273
+ offset: number;
274
+ total?: number;
275
+ }
276
+ /** Zcash transparent-address history from Blockchair. Build it with {@link createZcashHistory}. */
277
+ interface ZcashHistorySource extends HistorySource {
278
+ listActivity(address: string, query?: HistoryQuery): Promise<ZcashHistoryPage>;
279
+ getTransaction(hash: string, address: string): Promise<ZcashChainTx | undefined>;
280
+ }
281
+ /** The history backend failed. */
282
+ declare class HistoryUnavailableError extends Error {
283
+ readonly chain: string;
284
+ readonly reason: string;
285
+ constructor(chain: string, reason: string);
286
+ }
287
+ interface ZcashHistoryCursor {
288
+ v: 1;
289
+ o: number;
290
+ s: number;
291
+ }
292
+ declare function encodeCursor(c: ZcashHistoryCursor): string;
293
+ declare function decodeCursor(s: string): ZcashHistoryCursor;
294
+ declare function mapDashboardTx(chain: string, address: string, d: BlockchairTxDashboard): ZcashChainTx;
295
+ /** Blockchair link for a transaction. */
296
+ declare function zcashExplorerTxUrl(hash: string): string;
297
+ /**
298
+ * A history source for transparent Zcash addresses backed by Blockchair (mainnet).
299
+ *
300
+ * @throws Error when no `fetch` is available.
301
+ */
302
+ declare function createZcashHistory(options?: ZcashHistoryOptions): ZcashHistorySource;
303
+
304
+ export { zcashExplorerTxUrl as A, BLOCKCHAIR_URL as B, CAIP2 as C, HistoryUnavailableError as H, type SpentOutput as S, type Utxo as U, type ZcashNetwork as Z, type ZcashTxDescription as a, type ZcashClient as b, type ZcashTxInfo as c, type ZcashConfig as d, type ZcashSpend as e, type ZcashTransferOptions as f, type ZcashMaxSpendableResult as g, type ZcashReceipt as h, type ZcashTransaction as i, BlockchairClient as j, type BlockchairTxDashboard as k, type ZcashChainTx as l, type ZcashClientConfig as m, type ZcashHistoryCursor as n, type ZcashHistoryOptions as o, type ZcashHistoryPage as p, type ZcashHistoryRaw as q, type ZcashHistorySource as r, type ZcashTxInputDescription as s, type ZcashTxOutputDescription as t, type ZcashWarning as u, blockchairTime as v, createZcashHistory as w, decodeCursor as x, encodeCursor as y, mapDashboardTx as z };