Repository navigation
Expand file tree
/
Copy pathZcashV6Transaction.ts
More file actions
78 lines (66 loc) · 2.38 KB
/
Copy pathZcashV6Transaction.ts
File metadata and controls
78 lines (66 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { ZcashV6Transaction as WasmZcashV6Transaction } from "../wasm/wasm_utxo.js";
/**
* A parsed Zcash v6 (Ironwood / NU6.3) transaction — for inspection and txid.
*
* The transaction id is an instance method ({@link getId}) returning the canonical
* display-order hex, consistent with the `getId()` convention on the other
* transaction/PSBT wrappers. Callers never pass raw bytes to a txid function or have
* to reverse internal byte order themselves.
*
* @example
* ```typescript
* const tx = ZcashV6Transaction.fromBytes(rawV6Bytes);
* tx.getId(); // canonical (display-order) txid hex
* tx.ironwoodActionCount; // 0 when the Ironwood slot is empty
* ```
*/
export class ZcashV6Transaction {
private constructor(private _wasm: WasmZcashV6Transaction) {}
/**
* Decode a v6 transaction from raw wire bytes.
* @throws If the bytes are not a valid v6 (Ironwood) transaction
*/
static fromBytes(bytes: Uint8Array): ZcashV6Transaction {
return new ZcashV6Transaction(WasmZcashV6Transaction.fromBytes(bytes));
}
/** Serialize back to raw v6 wire bytes. */
toBytes(): Uint8Array {
return this._wasm.toBytes();
}
/** The canonical (display-order) ZIP-244 txid as a lowercase hex string. */
getId(): string {
return this._wasm.getId();
}
/** The ZIP-244 txid in internal (non-reversed) byte order. */
txidBytes(): Uint8Array {
return this._wasm.txidBytes();
}
/** Consensus branch id carried in the v6 header. */
get consensusBranchId(): number {
return this._wasm.consensusBranchId;
}
/** Expiry height. */
get expiryHeight(): number {
return this._wasm.expiryHeight;
}
/** Number of Ironwood actions (0 when the Ironwood slot is empty). */
get ironwoodActionCount(): number {
return this._wasm.ironwoodActionCount;
}
/** Net value crossing the Ironwood pool boundary (0 when there is no bundle). */
get ironwoodValueBalance(): bigint {
return this._wasm.ironwoodValueBalance;
}
/** The Ironwood bundle flag byte, or `undefined` when there is no bundle. */
get ironwoodFlags(): number | undefined {
return this._wasm.ironwoodFlags;
}
/** The Ironwood note-commitment tree anchor (32 bytes), or `undefined`. */
get ironwoodAnchor(): Uint8Array | undefined {
return this._wasm.ironwoodAnchor;
}
/** @internal */
get wasm(): WasmZcashV6Transaction {
return this._wasm;
}
}