@ledgerhq/zcash-utils 0.2.0 → 0.3.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/index.d.ts CHANGED
@@ -33,8 +33,20 @@ export interface SyncParams {
33
33
  maxRetries?: number
34
34
  /** Emit per-phase timing diagnostics to stderr every 10 seconds. */
35
35
  verbose?: boolean
36
+ /**
37
+ * Hex-encoded nullifiers of notes received in previous scans that are still
38
+ * unspent. Enables spent detection across incremental sync boundaries.
39
+ */
40
+ knownNullifiers?: Array<string>
36
41
  }
37
- /** A single shielded note found during decryption. */
42
+ /**
43
+ * A single shielded note found during decryption.
44
+ *
45
+ * Shared between Orchard and Sapling. The spending fields (`nullifier`,
46
+ * `rseed`, `cmx`, `position`, `recipient`) are Orchard-specific and `None`
47
+ * for Sapling notes. A dedicated Sapling type is deferred until Sapling
48
+ * spending is needed.
49
+ */
38
50
  export interface ShieldedNote {
39
51
  /** Amount in zatoshis (f64 for JS Number compatibility). */
40
52
  amount: number
@@ -42,6 +54,24 @@ export interface ShieldedNote {
42
54
  transferType: string
43
55
  /** Memo text decoded from the note. */
44
56
  memo: string
57
+ /** Orchard nullifier (64-char hex = 32 bytes). Used for spent detection and PCZT. */
58
+ nullifier?: string
59
+ /** rho value (64-char hex = 32 bytes). Required with rseed for Note::from_parts. */
60
+ rho?: string
61
+ /** Random seed (64-char hex = 32 bytes). Required for spending. */
62
+ rseed?: string
63
+ /** Extracted note commitment cmx (64-char hex = 32 bytes). Required for Merkle witness. */
64
+ cmx?: string
65
+ /**
66
+ * Leaf position in the Orchard commitment tree (decimal string).
67
+ * None when ChainMetadata is absent.
68
+ * String avoids f64 precision loss on u64 -> f64 -> u64 round-trips.
69
+ */
70
+ position?: string
71
+ /** Recipient bytes (86-char hex = 43 bytes: 11-byte d + 32-byte pk_d). For note reconstruction. */
72
+ recipient?: string
73
+ /** True if this note was spent in a later block within the scanned range. */
74
+ isSpent: boolean
45
75
  }
46
76
  /** A matched and fully-decrypted shielded transaction. */
47
77
  export interface ShieldedTransaction {
@@ -66,6 +96,11 @@ export interface ShieldedTransaction {
66
96
  export interface SyncStats {
67
97
  blocksScanned: number
68
98
  elapsedMs: number
99
+ /**
100
+ * Hex-encoded nullifiers from `knownNullifiers` that were spent in the scanned range.
101
+ * JS uses this to mark previously-stored notes as spent.
102
+ */
103
+ spentKnownNullifiers: Array<string>
69
104
  }
70
105
  /**
71
106
  * Start scanning a range of compact blocks and return a transaction stream.
@@ -105,7 +140,9 @@ export declare class TransactionStream {
105
140
  /**
106
141
  * Returns the next matched transaction, or `null` when the scan is complete.
107
142
  *
108
- * Safety: napi-rs requires `unsafe` for `&mut self` in async methods.
143
+ * # Safety
144
+ *
145
+ * napi-rs requires `unsafe` for `&mut self` in async methods.
109
146
  * This method is safe to call — it only mutates the internal channel receiver.
110
147
  */
111
148
  next(): Promise<ShieldedTransaction | null>
@@ -123,7 +160,9 @@ export declare class TransactionStream {
123
160
  * returns `null`). Calling this before the stream is done will wait until
124
161
  * the background sync task finishes.
125
162
  *
126
- * Safety: napi-rs requires `unsafe` for `&mut self` in async methods.
163
+ * # Safety
164
+ *
165
+ * napi-rs requires `unsafe` for `&mut self` in async methods.
127
166
  */
128
167
  stats(): Promise<SyncStats>
129
168
  }
Binary file
Binary file
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": "0.2.0",
3
+ "version": "0.3.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",