@ledgerhq/zcash-utils 1.0.3 → 1.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @ledgerhq/zcash-utils
2
2
 
3
+ ## 1.0.4
4
+
5
+ ### Minor Changes
6
+
7
+ - Report the fee a transaction actually paid and the addresses its shielded outputs paid, through the new `transactionDetails` function
8
+ - Report the transparent bundle of a scanned transaction, via `transparentOut` and `hasTransparentInputs` on `ShieldedTransaction`
9
+
10
+ # @ledgerhq/zcash-utils
11
+
3
12
  ## 1.0.3
4
13
 
5
14
  ### Patch Changes
package/index.d.ts CHANGED
@@ -94,6 +94,19 @@ export interface ShieldedTransaction {
94
94
  blockTime: number
95
95
  /** Transaction fee in zatoshis (shielded bundles only). */
96
96
  fee: number
97
+ /**
98
+ * Sum of the transparent outputs, in zatoshis. Zero without a transparent bundle.
99
+ *
100
+ * A shielded→transparent send leaves no decrypted output to account for the
101
+ * value it moved — only an `internal` change note, or none at all. This is
102
+ * what tells such a send apart from a self-transfer.
103
+ */
104
+ transparentOut: number
105
+ /**
106
+ * Whether the transaction spends transparent inputs, in which case those
107
+ * inputs — rather than the shielded pools — may be paying `transparentOut`.
108
+ */
109
+ hasTransparentInputs: boolean
97
110
  /** Decrypted Sapling notes belonging to this account. */
98
111
  saplingNotes: Array<ShieldedNote>
99
112
  /** Decrypted Orchard notes belonging to this account. */
@@ -251,6 +264,92 @@ export interface BuildTransactionResult {
251
264
  * single `spawn_blocking` call — the proving cost is borne inline.
252
265
  */
253
266
  export declare function buildTransaction(params: BuildTransactionParams): Promise<BuildTransactionResult>
267
+ /**
268
+ * One Ironwood note to spend. Identical shape to [`OrchardSpendInputJs`];
269
+ * kept as a distinct type for clarity on the JS side.
270
+ */
271
+ export interface IronwoodSpendInputJs {
272
+ /** 86-char hex (43 bytes: 11-byte diversifier + 32-byte pk_d). */
273
+ recipient: string
274
+ /** Decimal u64 (string to avoid f64 precision loss). */
275
+ valueZat: string
276
+ /** 64-char hex (32 bytes). */
277
+ rho: string
278
+ /** 64-char hex. */
279
+ rseed: string
280
+ /** 64-char hex. */
281
+ cmx: string
282
+ /** Decimal u64 leaf position in the Ironwood commitment tree. */
283
+ position: string
284
+ }
285
+ export interface IronwoodOutputRequestJs {
286
+ /**
287
+ * Destination address: t-addr (P2PKH/P2SH) or u-addr (Orchard receiver —
288
+ * the same receiver selects the Ironwood pool here). Sapling z-addresses
289
+ * and TEX (ZIP-320) addresses are rejected.
290
+ */
291
+ address: string
292
+ valueZat: string
293
+ memo?: string
294
+ }
295
+ export interface BuildIronwoodTransactionParams {
296
+ grpcUrl: string
297
+ ufvk: string
298
+ network?: string
299
+ /**
300
+ * 64-char hex (32 bytes): ZIP-32 seed fingerprint of the wallet seed,
301
+ * read from the device. Stamped onto each real spend so the device can
302
+ * confirm the PCZT belongs to its seed before signing.
303
+ */
304
+ seedFingerprint: string
305
+ /** ZIP-32 account index the UFVK was derived at. */
306
+ accountIndex: number
307
+ /**
308
+ * Caller-owned fee in zatoshis (decimal string to avoid f64 precision
309
+ * loss). Per FR-4 the fee is selected by ledger-live; this
310
+ * crate validates it against ZIP-317 Rev 1 and derives the (always
311
+ * Ironwood) change from it rather than computing a fee itself.
312
+ */
313
+ feeZat: string
314
+ spends: Array<IronwoodSpendInputJs>
315
+ /** Transparent (P2PKH) UTXOs to spend. Empty for Ironwood→* flows. */
316
+ transparentInputs: Array<TransparentInputJs>
317
+ outputs: Array<IronwoodOutputRequestJs>
318
+ anchorHeight?: number
319
+ }
320
+ export interface BuildIronwoodTransactionResult {
321
+ /**
322
+ * Hex-encoded canonical PCZT bytes (`PCZT` magic + u32 LE version +
323
+ * postcard payload), serialized in the **v2** wire format and redacted
324
+ * (required for any V6 / Ironwood-bearing PCZT — see
325
+ * `zcash_crypto::craft::build_ironwood_transaction`).
326
+ */
327
+ pcztHex: string
328
+ /** Decimal fee in zatoshis. */
329
+ feeZat: string
330
+ /** Block height the Merkle paths were computed against. */
331
+ anchorHeight: number
332
+ /** Ironwood action count after dummy padding. */
333
+ nActionsIronwood: number
334
+ /** Transparent input count. */
335
+ nTransparentInputs: number
336
+ /** Transparent output count. */
337
+ nTransparentOutputs: number
338
+ }
339
+ /**
340
+ * Build, prove, and serialize a redacted V6 PCZT for an Ironwood send.
341
+ *
342
+ * Rust-only crafting is dry-run pending the NU6.3 wallet-side crates
343
+ * stabilizing (`pczt`, `zcash_client_backend` are release candidates); this
344
+ * NAPI wrapper is exposed now so the JS side can be wired up in parallel and
345
+ * re-pinned when those crates stabilize (see `docs/architecture.md`).
346
+ *
347
+ * Same proving-cost profile as `buildTransaction`: Halo 2 proof generation
348
+ * happens here for the Ironwood bundle (~2-5 s first call against the
349
+ * `PostNu6_3` circuit, ~hundreds of ms thereafter via the process-global
350
+ * proving-key cache).
351
+ */
352
+ export declare function buildIronwoodTransaction(params: BuildIronwoodTransactionParams): Promise<BuildIronwoodTransactionResult>
254
353
  /** Parameters for finalizing a PCZT with device-provided signatures. */
255
354
  export interface FinalizeTransactionParams {
256
355
  /** Hex-encoded canonical PCZT bytes from `buildTransaction`. */
@@ -293,6 +392,65 @@ export declare function finalizeTransaction(params: FinalizeTransactionParams):
293
392
  * `errorMessage`) or on a gRPC transport failure.
294
393
  */
295
394
  export declare function broadcastTransaction(grpcUrl: string, txHex: string): Promise<string>
395
+ /** A transparent output being spent, and its value. */
396
+ export interface TransparentPrevout {
397
+ /**
398
+ * 64-char hex txid of the transaction that created the output, in
399
+ * big-endian display order.
400
+ */
401
+ txid: string
402
+ index: number
403
+ /** Value in zatoshis, as a decimal string (avoids f64 precision loss). */
404
+ value: string
405
+ }
406
+ /** A transaction to be resolved. */
407
+ export interface TransactionDetailsRequest {
408
+ /** 64-char hex txid, big-endian display order. */
409
+ txid: string
410
+ /**
411
+ * Height of the block containing the transaction — determines the
412
+ * consensus branch the transaction is parsed against.
413
+ */
414
+ height: number
415
+ /**
416
+ * Value of every transparent output the transaction spends. Omitting any
417
+ * of them makes the fee unknown; a fully-shielded transaction needs none.
418
+ */
419
+ prevouts: Array<TransparentPrevout>
420
+ }
421
+ /** What a transaction's raw bytes reveal that an explorer cannot see. */
422
+ export interface TransactionDetailsResult {
423
+ txid: string
424
+ /**
425
+ * Fee in zatoshis as a decimal string, or `null` when it could not be
426
+ * established (missing prevout value, or the transaction could not be
427
+ * fetched or parsed).
428
+ */
429
+ fee?: string
430
+ /**
431
+ * Addresses of the shielded outputs the account created, in bundle order.
432
+ * Empty without a viewing key, or when the transaction pays no shielded
433
+ * address of someone else's.
434
+ */
435
+ payees: Array<string>
436
+ }
437
+ /**
438
+ * Read from each transaction what only its raw bytes hold: the fee it paid,
439
+ * and where its shielded outputs went. Transactions are fetched by txid.
440
+ *
441
+ * A transaction's fee spans every pool: value entering the shielded pools is
442
+ * not a fee, and value leaving them is not an output the transparent bundle
443
+ * can account for. Deriving the fee from transparent inputs and outputs alone
444
+ * is therefore wrong for any transaction that crosses that boundary.
445
+ *
446
+ * The payees of shielded outputs are encrypted, and recoverable only by the
447
+ * account that created them — pass `ufvk` to recover them, omit it to skip.
448
+ *
449
+ * Both answers come from the same fetched transaction. One that cannot be
450
+ * fetched, parsed, or fully priced yields a `null` fee and no payees, rather
451
+ * than an approximation.
452
+ */
453
+ export declare function transactionDetails(grpcUrl: string, requests: Array<TransactionDetailsRequest>, network?: string | undefined | null, ufvk?: string | undefined | null): Promise<Array<TransactionDetailsResult>>
296
454
  /** PCZT header (`common::Global`) fields. */
297
455
  export interface PcztGlobal {
298
456
  /** Transaction version (V5 = 5). */
Binary file
Binary file
package/index.js CHANGED
@@ -310,13 +310,15 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { TransactionStream, startSync, getChainTip, findBlockHeight, buildTransaction, finalizeTransaction, broadcastTransaction, parsePczt } = nativeBinding
313
+ const { TransactionStream, startSync, getChainTip, findBlockHeight, buildTransaction, buildIronwoodTransaction, finalizeTransaction, broadcastTransaction, transactionDetails, parsePczt } = nativeBinding
314
314
 
315
315
  module.exports.TransactionStream = TransactionStream
316
316
  module.exports.startSync = startSync
317
317
  module.exports.getChainTip = getChainTip
318
318
  module.exports.findBlockHeight = findBlockHeight
319
319
  module.exports.buildTransaction = buildTransaction
320
+ module.exports.buildIronwoodTransaction = buildIronwoodTransaction
320
321
  module.exports.finalizeTransaction = finalizeTransaction
321
322
  module.exports.broadcastTransaction = broadcastTransaction
323
+ module.exports.transactionDetails = transactionDetails
322
324
  module.exports.parsePczt = parsePczt
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/zcash-utils",
3
- "version": "1.0.3",
3
+ "version": "1.1.1",
4
4
  "description": "Native Zcash key derivation and shielded sync — Node.js (NAPI)",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",