@totemsdk/txpow 1.0.2 → 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.
Files changed (61) hide show
  1. package/LICENSE +202 -21
  2. package/NOTICE +60 -0
  3. package/dist/admission/challenge.js +14 -21
  4. package/dist/admission/commitment.js +9 -13
  5. package/dist/admission/index.js +6 -34
  6. package/dist/admission/mine.js +14 -17
  7. package/dist/admission/template.js +32 -47
  8. package/dist/admission/types.js +2 -5
  9. package/dist/admission/verify.js +12 -15
  10. package/dist/calibrate.js +4 -8
  11. package/dist/cjs/admission/challenge.d.ts +66 -0
  12. package/dist/cjs/admission/challenge.js +155 -0
  13. package/dist/cjs/admission/commitment.d.ts +34 -0
  14. package/dist/cjs/admission/commitment.js +73 -0
  15. package/dist/cjs/admission/index.d.ts +14 -0
  16. package/dist/cjs/admission/index.js +42 -0
  17. package/dist/cjs/admission/mine.d.ts +60 -0
  18. package/dist/cjs/admission/mine.js +146 -0
  19. package/dist/cjs/admission/template.d.ts +138 -0
  20. package/dist/cjs/admission/template.js +247 -0
  21. package/dist/cjs/admission/types.d.ts +224 -0
  22. package/dist/cjs/admission/types.js +24 -0
  23. package/dist/cjs/admission/verify.d.ts +50 -0
  24. package/dist/cjs/admission/verify.js +156 -0
  25. package/dist/cjs/calibrate.d.ts +35 -0
  26. package/dist/cjs/calibrate.js +68 -0
  27. package/dist/cjs/constants.d.ts +27 -0
  28. package/dist/cjs/constants.js +47 -0
  29. package/dist/cjs/difficulty.d.ts +44 -0
  30. package/dist/cjs/difficulty.js +111 -0
  31. package/dist/cjs/index.d.ts +28 -0
  32. package/dist/cjs/index.js +88 -0
  33. package/dist/cjs/magic.d.ts +19 -0
  34. package/dist/cjs/magic.js +35 -0
  35. package/dist/cjs/mine-wasm.d.ts +69 -0
  36. package/dist/cjs/mine-wasm.js +214 -0
  37. package/dist/cjs/mine.d.ts +131 -0
  38. package/dist/cjs/mine.js +407 -0
  39. package/dist/cjs/package.json +1 -0
  40. package/dist/cjs/serialization.d.ts +106 -0
  41. package/dist/cjs/serialization.js +160 -0
  42. package/dist/cjs/verify.d.ts +76 -0
  43. package/dist/cjs/verify.js +232 -0
  44. package/dist/cjs/wasm/miner.wasm +0 -0
  45. package/dist/cjs/workers/browser.worker.d.ts +26 -0
  46. package/dist/cjs/workers/browser.worker.js +63 -0
  47. package/dist/cjs/workers/node.worker.d.ts +33 -0
  48. package/dist/cjs/workers/node.worker.js +47 -0
  49. package/dist/constants.js +5 -8
  50. package/dist/difficulty.d.ts +24 -0
  51. package/dist/difficulty.js +54 -6
  52. package/dist/index.d.ts +1 -1
  53. package/dist/index.js +9 -62
  54. package/dist/magic.js +12 -15
  55. package/dist/mine-wasm.js +8 -15
  56. package/dist/mine.js +23 -31
  57. package/dist/serialization.js +28 -34
  58. package/dist/verify.js +15 -20
  59. package/dist/workers/browser.worker.js +4 -6
  60. package/dist/workers/node.worker.js +2 -3
  61. package/package.json +34 -15
@@ -8,6 +8,30 @@
8
8
  export interface TxPowParams {
9
9
  minTxPowWork: string;
10
10
  }
11
+ /** Anything that can expose a node's live minimum TxPoW work (hex). */
12
+ export interface MinWorkSource {
13
+ getMinTxPowWork?(): Promise<string | null>;
14
+ }
15
+ /**
16
+ * Convert a live `currentmintxpowwork` value (32-byte hex target) into a mining
17
+ * target, applying the same 10% margin the node's own wallet uses
18
+ * (`minwork * 10 / 11`, see Java `TxPoWGenerator.generateTxPoW`).
19
+ *
20
+ * `TxPoWChecker.checkTxPoWSimple` rejects only when
21
+ * `txnDifficulty > magic.getMinTxPowWork()`, so a target that is harder than
22
+ * the live minimum is always accepted; the margin absorbs the tiny per-block
23
+ * Magic retarget.
24
+ */
25
+ export declare function targetFromMinWork(minWorkHex: string): Uint8Array;
26
+ /**
27
+ * Resolve the TxPoW mining target from a live node when it exposes
28
+ * `getMinTxPowWork()`, otherwise fall back to `TX_POW_MIN_DIFFICULTY`.
29
+ *
30
+ * Never throws: a node/protocol hiccup must not block transaction
31
+ * construction. The fallback is the protocol default target (MAX/1e6), which
32
+ * is harder than the network hard floor (`Magic.MIN_HASHES = 10000`).
33
+ */
34
+ export declare function resolveTxPowTarget(source?: MinWorkSource | null, fallback?: Uint8Array): Promise<Uint8Array>;
11
35
  /**
12
36
  * Fetch the current minimum TxPoW work from the Axia API.
13
37
  *
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * difficulty.ts — Fetch and manage the TxPoW difficulty target.
4
3
  *
@@ -6,9 +5,58 @@
6
5
  * On any error (timeout, network failure, invalid response) we fall back to
7
6
  * the hardcoded TX_POW_MIN_DIFFICULTY constant, which is the protocol floor.
8
7
  */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.fetchTxPowTarget = fetchTxPowTarget;
11
- const constants_js_1 = require("./constants.js");
8
+ import { TX_POW_MIN_DIFFICULTY } from './constants.js';
9
+ /**
10
+ * Convert a live `currentmintxpowwork` value (32-byte hex target) into a mining
11
+ * target, applying the same 10% margin the node's own wallet uses
12
+ * (`minwork * 10 / 11`, see Java `TxPoWGenerator.generateTxPoW`).
13
+ *
14
+ * `TxPoWChecker.checkTxPoWSimple` rejects only when
15
+ * `txnDifficulty > magic.getMinTxPowWork()`, so a target that is harder than
16
+ * the live minimum is always accepted; the margin absorbs the tiny per-block
17
+ * Magic retarget.
18
+ */
19
+ export function targetFromMinWork(minWorkHex) {
20
+ const clean = minWorkHex.replace(/^0x/i, '').trim();
21
+ if (clean.length === 0 || clean.length > 64 || !/^[0-9a-fA-F]+$/.test(clean)) {
22
+ throw new Error(`Invalid minTxPowWork: ${minWorkHex}`);
23
+ }
24
+ const value = BigInt('0x' + clean);
25
+ const adjusted = (value * 10n) / 11n;
26
+ const target = adjusted > 0n ? adjusted : value;
27
+ let hex = target.toString(16);
28
+ if (hex.length % 2 !== 0)
29
+ hex = '0' + hex;
30
+ while (hex.length < 64)
31
+ hex = '0' + hex;
32
+ const out = new Uint8Array(32);
33
+ for (let i = 0; i < 32; i++) {
34
+ out[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
35
+ }
36
+ return out;
37
+ }
38
+ /**
39
+ * Resolve the TxPoW mining target from a live node when it exposes
40
+ * `getMinTxPowWork()`, otherwise fall back to `TX_POW_MIN_DIFFICULTY`.
41
+ *
42
+ * Never throws: a node/protocol hiccup must not block transaction
43
+ * construction. The fallback is the protocol default target (MAX/1e6), which
44
+ * is harder than the network hard floor (`Magic.MIN_HASHES = 10000`).
45
+ */
46
+ export async function resolveTxPowTarget(source, fallback = TX_POW_MIN_DIFFICULTY) {
47
+ try {
48
+ const hex = await source?.getMinTxPowWork?.();
49
+ if (hex) {
50
+ const target = targetFromMinWork(hex);
51
+ if (target.some((b) => b !== 0))
52
+ return target;
53
+ }
54
+ }
55
+ catch {
56
+ // fall through to the constant
57
+ }
58
+ return new Uint8Array(fallback);
59
+ }
12
60
  function hexToBytes(hex) {
13
61
  const h = hex.startsWith('0x') ? hex.slice(2) : hex;
14
62
  const out = new Uint8Array(h.length / 2);
@@ -26,7 +74,7 @@ function hexToBytes(hex) {
26
74
  * @param axiaBaseUrl Base URL of the Axia API, e.g. "https://api.axia.to"
27
75
  * @param timeoutMs Request timeout in ms (default: 3000)
28
76
  */
29
- async function fetchTxPowTarget(axiaBaseUrl, timeoutMs = 3000) {
77
+ export async function fetchTxPowTarget(axiaBaseUrl, timeoutMs = 3000) {
30
78
  try {
31
79
  const base = axiaBaseUrl.replace(/\/$/, '');
32
80
  const url = `${base}/v1/wallet/txpow-params`;
@@ -53,6 +101,6 @@ async function fetchTxPowTarget(axiaBaseUrl, timeoutMs = 3000) {
53
101
  return hexToBytes(clean);
54
102
  }
55
103
  catch {
56
- return new Uint8Array(constants_js_1.TX_POW_MIN_DIFFICULTY);
104
+ return new Uint8Array(TX_POW_MIN_DIFFICULTY);
57
105
  }
58
106
  }
package/dist/index.d.ts CHANGED
@@ -22,7 +22,7 @@ export { MAX_HASH, ZERO_HASH, TX_POW_MIN_DIFFICULTY, CASCADE_LEVELS, MAIN_NET_CH
22
22
  export { serializeMagic } from './magic.js';
23
23
  export { mineTxPoW, mineTxPoWInProcess, mineHeaderTail, buildHeaderTail, isLessThan, setBrowserWorkerUrl, type MineResult, type MineOptions, } from './mine.js';
24
24
  export { setWasmUrl, getBrowserWasmUrl, isWasmAvailable } from './mine-wasm.js';
25
- export { fetchTxPowTarget, type TxPowParams } from './difficulty.js';
25
+ export { fetchTxPowTarget, targetFromMinWork, resolveTxPowTarget, type TxPowParams, type MinWorkSource, } from './difficulty.js';
26
26
  export { verifyProofOfWork, verifyTxPoWWork, verifyTxPoWParts, type VerifyResult } from './verify.js';
27
27
  export { calibrateHashRate, estimateMiningCost, type MiningEstimate, } from './calibrate.js';
28
28
  export { createWorkChallenge, validateWorkChallenge, challengeFingerprint, canonicalChallenge, computeActionCommitment, canonicalAction, mineWorkAdmission, verifyWorkAdmission, buildBlockHeaderTail, serializeSuperParents, isBlockWinner, computeSuperLevel, templateFreshness, computeBlockCandidateId, buildEmptyBlockBody, buildEmptyTransactionBytes, buildEmptyWitnessBytes, buildEmptyBurnTxBytes, buildEmptyBurnWitnessBytes, assembleTxPoWEnvelope, reconstructTxPoWEnvelope, MACHINE_WORK_ADMISSION_VERSION, MACHINE_WORK_DOMAIN, DEFAULT_CHALLENGE_TTL_MS, MAX_CHALLENGE_TTL_MS, type WorkChallenge, type MachineWorkAction, type MinimaWorkTemplate, type MinimaWorkTemplateProvider, type MinimaWorkRelay, type MachineWorkAdmissionProof, type WorkAdmissionVerification, type MineWorkAdmissionOptions, type VerifyWorkAdmissionOptions, } from './admission/index.js';
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * @totemsdk/txpow
4
3
  *
@@ -18,68 +17,16 @@
18
17
  * const check = verifyProofOfWork(txpowId, mTxnDifficulty);
19
18
  * if (!check.valid) drop(check.reason);
20
19
  */
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.MAX_CHALLENGE_TTL_MS = exports.DEFAULT_CHALLENGE_TTL_MS = exports.MACHINE_WORK_DOMAIN = exports.MACHINE_WORK_ADMISSION_VERSION = exports.reconstructTxPoWEnvelope = exports.assembleTxPoWEnvelope = exports.buildEmptyBurnWitnessBytes = exports.buildEmptyBurnTxBytes = exports.buildEmptyWitnessBytes = exports.buildEmptyTransactionBytes = exports.buildEmptyBlockBody = exports.computeBlockCandidateId = exports.templateFreshness = exports.computeSuperLevel = exports.isBlockWinner = exports.serializeSuperParents = exports.buildBlockHeaderTail = exports.verifyWorkAdmission = exports.mineWorkAdmission = exports.canonicalAction = exports.computeActionCommitment = exports.canonicalChallenge = exports.challengeFingerprint = exports.validateWorkChallenge = exports.createWorkChallenge = exports.estimateMiningCost = exports.calibrateHashRate = exports.verifyTxPoWParts = exports.verifyTxPoWWork = exports.verifyProofOfWork = exports.fetchTxPowTarget = exports.isWasmAvailable = exports.getBrowserWasmUrl = exports.setWasmUrl = exports.setBrowserWorkerUrl = exports.isLessThan = exports.buildHeaderTail = exports.mineHeaderTail = exports.mineTxPoWInProcess = exports.mineTxPoW = exports.serializeMagic = exports.MAIN_NET_CHAIN_ID = exports.CASCADE_LEVELS = exports.TX_POW_MIN_DIFFICULTY = exports.ZERO_HASH = exports.MAX_HASH = exports.computeTxPoWId = exports.serializeTxPoW = exports.serializeTxBody = exports.serializeTxHeader = void 0;
23
- var serialization_js_1 = require("./serialization.js");
24
- Object.defineProperty(exports, "serializeTxHeader", { enumerable: true, get: function () { return serialization_js_1.serializeTxHeader; } });
25
- Object.defineProperty(exports, "serializeTxBody", { enumerable: true, get: function () { return serialization_js_1.serializeTxBody; } });
26
- Object.defineProperty(exports, "serializeTxPoW", { enumerable: true, get: function () { return serialization_js_1.serializeTxPoW; } });
27
- Object.defineProperty(exports, "computeTxPoWId", { enumerable: true, get: function () { return serialization_js_1.computeTxPoWId; } });
28
- var constants_js_1 = require("./constants.js");
29
- Object.defineProperty(exports, "MAX_HASH", { enumerable: true, get: function () { return constants_js_1.MAX_HASH; } });
30
- Object.defineProperty(exports, "ZERO_HASH", { enumerable: true, get: function () { return constants_js_1.ZERO_HASH; } });
31
- Object.defineProperty(exports, "TX_POW_MIN_DIFFICULTY", { enumerable: true, get: function () { return constants_js_1.TX_POW_MIN_DIFFICULTY; } });
32
- Object.defineProperty(exports, "CASCADE_LEVELS", { enumerable: true, get: function () { return constants_js_1.CASCADE_LEVELS; } });
33
- Object.defineProperty(exports, "MAIN_NET_CHAIN_ID", { enumerable: true, get: function () { return constants_js_1.MAIN_NET_CHAIN_ID; } });
34
- var magic_js_1 = require("./magic.js");
35
- Object.defineProperty(exports, "serializeMagic", { enumerable: true, get: function () { return magic_js_1.serializeMagic; } });
36
- var mine_js_1 = require("./mine.js");
37
- Object.defineProperty(exports, "mineTxPoW", { enumerable: true, get: function () { return mine_js_1.mineTxPoW; } });
38
- Object.defineProperty(exports, "mineTxPoWInProcess", { enumerable: true, get: function () { return mine_js_1.mineTxPoWInProcess; } });
39
- Object.defineProperty(exports, "mineHeaderTail", { enumerable: true, get: function () { return mine_js_1.mineHeaderTail; } });
40
- Object.defineProperty(exports, "buildHeaderTail", { enumerable: true, get: function () { return mine_js_1.buildHeaderTail; } });
41
- Object.defineProperty(exports, "isLessThan", { enumerable: true, get: function () { return mine_js_1.isLessThan; } });
42
- Object.defineProperty(exports, "setBrowserWorkerUrl", { enumerable: true, get: function () { return mine_js_1.setBrowserWorkerUrl; } });
43
- var mine_wasm_js_1 = require("./mine-wasm.js");
44
- Object.defineProperty(exports, "setWasmUrl", { enumerable: true, get: function () { return mine_wasm_js_1.setWasmUrl; } });
45
- Object.defineProperty(exports, "getBrowserWasmUrl", { enumerable: true, get: function () { return mine_wasm_js_1.getBrowserWasmUrl; } });
46
- Object.defineProperty(exports, "isWasmAvailable", { enumerable: true, get: function () { return mine_wasm_js_1.isWasmAvailable; } });
47
- var difficulty_js_1 = require("./difficulty.js");
48
- Object.defineProperty(exports, "fetchTxPowTarget", { enumerable: true, get: function () { return difficulty_js_1.fetchTxPowTarget; } });
49
- var verify_js_1 = require("./verify.js");
50
- Object.defineProperty(exports, "verifyProofOfWork", { enumerable: true, get: function () { return verify_js_1.verifyProofOfWork; } });
51
- Object.defineProperty(exports, "verifyTxPoWWork", { enumerable: true, get: function () { return verify_js_1.verifyTxPoWWork; } });
52
- Object.defineProperty(exports, "verifyTxPoWParts", { enumerable: true, get: function () { return verify_js_1.verifyTxPoWParts; } });
53
- var calibrate_js_1 = require("./calibrate.js");
54
- Object.defineProperty(exports, "calibrateHashRate", { enumerable: true, get: function () { return calibrate_js_1.calibrateHashRate; } });
55
- Object.defineProperty(exports, "estimateMiningCost", { enumerable: true, get: function () { return calibrate_js_1.estimateMiningCost; } });
20
+ export { serializeTxHeader, serializeTxBody, serializeTxPoW, computeTxPoWId, } from './serialization.js';
21
+ export { MAX_HASH, ZERO_HASH, TX_POW_MIN_DIFFICULTY, CASCADE_LEVELS, MAIN_NET_CHAIN_ID, } from './constants.js';
22
+ export { serializeMagic } from './magic.js';
23
+ export { mineTxPoW, mineTxPoWInProcess, mineHeaderTail, buildHeaderTail, isLessThan, setBrowserWorkerUrl, } from './mine.js';
24
+ export { setWasmUrl, getBrowserWasmUrl, isWasmAvailable } from './mine-wasm.js';
25
+ export { fetchTxPowTarget, targetFromMinWork, resolveTxPowTarget, } from './difficulty.js';
26
+ export { verifyProofOfWork, verifyTxPoWWork, verifyTxPoWParts } from './verify.js';
27
+ export { calibrateHashRate, estimateMiningCost, } from './calibrate.js';
56
28
  // ── Machine Work Admission ──────────────────────────────────────────────────
57
29
  // Receiver-controlled computational admission bound to a real Minima block
58
30
  // candidate. The same nonce search that admits a machine action also searches
59
31
  // for Minima blocks (Super-0 … Super-31).
60
- var index_js_1 = require("./admission/index.js");
61
- Object.defineProperty(exports, "createWorkChallenge", { enumerable: true, get: function () { return index_js_1.createWorkChallenge; } });
62
- Object.defineProperty(exports, "validateWorkChallenge", { enumerable: true, get: function () { return index_js_1.validateWorkChallenge; } });
63
- Object.defineProperty(exports, "challengeFingerprint", { enumerable: true, get: function () { return index_js_1.challengeFingerprint; } });
64
- Object.defineProperty(exports, "canonicalChallenge", { enumerable: true, get: function () { return index_js_1.canonicalChallenge; } });
65
- Object.defineProperty(exports, "computeActionCommitment", { enumerable: true, get: function () { return index_js_1.computeActionCommitment; } });
66
- Object.defineProperty(exports, "canonicalAction", { enumerable: true, get: function () { return index_js_1.canonicalAction; } });
67
- Object.defineProperty(exports, "mineWorkAdmission", { enumerable: true, get: function () { return index_js_1.mineWorkAdmission; } });
68
- Object.defineProperty(exports, "verifyWorkAdmission", { enumerable: true, get: function () { return index_js_1.verifyWorkAdmission; } });
69
- Object.defineProperty(exports, "buildBlockHeaderTail", { enumerable: true, get: function () { return index_js_1.buildBlockHeaderTail; } });
70
- Object.defineProperty(exports, "serializeSuperParents", { enumerable: true, get: function () { return index_js_1.serializeSuperParents; } });
71
- Object.defineProperty(exports, "isBlockWinner", { enumerable: true, get: function () { return index_js_1.isBlockWinner; } });
72
- Object.defineProperty(exports, "computeSuperLevel", { enumerable: true, get: function () { return index_js_1.computeSuperLevel; } });
73
- Object.defineProperty(exports, "templateFreshness", { enumerable: true, get: function () { return index_js_1.templateFreshness; } });
74
- Object.defineProperty(exports, "computeBlockCandidateId", { enumerable: true, get: function () { return index_js_1.computeBlockCandidateId; } });
75
- Object.defineProperty(exports, "buildEmptyBlockBody", { enumerable: true, get: function () { return index_js_1.buildEmptyBlockBody; } });
76
- Object.defineProperty(exports, "buildEmptyTransactionBytes", { enumerable: true, get: function () { return index_js_1.buildEmptyTransactionBytes; } });
77
- Object.defineProperty(exports, "buildEmptyWitnessBytes", { enumerable: true, get: function () { return index_js_1.buildEmptyWitnessBytes; } });
78
- Object.defineProperty(exports, "buildEmptyBurnTxBytes", { enumerable: true, get: function () { return index_js_1.buildEmptyBurnTxBytes; } });
79
- Object.defineProperty(exports, "buildEmptyBurnWitnessBytes", { enumerable: true, get: function () { return index_js_1.buildEmptyBurnWitnessBytes; } });
80
- Object.defineProperty(exports, "assembleTxPoWEnvelope", { enumerable: true, get: function () { return index_js_1.assembleTxPoWEnvelope; } });
81
- Object.defineProperty(exports, "reconstructTxPoWEnvelope", { enumerable: true, get: function () { return index_js_1.reconstructTxPoWEnvelope; } });
82
- Object.defineProperty(exports, "MACHINE_WORK_ADMISSION_VERSION", { enumerable: true, get: function () { return index_js_1.MACHINE_WORK_ADMISSION_VERSION; } });
83
- Object.defineProperty(exports, "MACHINE_WORK_DOMAIN", { enumerable: true, get: function () { return index_js_1.MACHINE_WORK_DOMAIN; } });
84
- Object.defineProperty(exports, "DEFAULT_CHALLENGE_TTL_MS", { enumerable: true, get: function () { return index_js_1.DEFAULT_CHALLENGE_TTL_MS; } });
85
- Object.defineProperty(exports, "MAX_CHALLENGE_TTL_MS", { enumerable: true, get: function () { return index_js_1.MAX_CHALLENGE_TTL_MS; } });
32
+ export { createWorkChallenge, validateWorkChallenge, challengeFingerprint, canonicalChallenge, computeActionCommitment, canonicalAction, mineWorkAdmission, verifyWorkAdmission, buildBlockHeaderTail, serializeSuperParents, isBlockWinner, computeSuperLevel, templateFreshness, computeBlockCandidateId, buildEmptyBlockBody, buildEmptyTransactionBytes, buildEmptyWitnessBytes, buildEmptyBurnTxBytes, buildEmptyBurnWitnessBytes, assembleTxPoWEnvelope, reconstructTxPoWEnvelope, MACHINE_WORK_ADMISSION_VERSION, MACHINE_WORK_DOMAIN, DEFAULT_CHALLENGE_TTL_MS, MAX_CHALLENGE_TTL_MS, } from './admission/index.js';
package/dist/magic.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * magic.ts — Serialize the Minima Magic struct.
4
3
  *
@@ -17,19 +16,17 @@
17
16
  * maxTxnPerBlock = 256
18
17
  * minTxPoWWork = MAX_HASH (all 0xFF, 32 bytes) — placeholder in fresh TxPoW
19
18
  */
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.serializeMagic = serializeMagic;
22
- const core_1 = require("@totemsdk/core");
23
- const constants_js_1 = require("./constants.js");
24
- function serializeMagic() {
19
+ import { writeMiniNumber, writeMiniData, concat } from '@totemsdk/core';
20
+ import { MAX_HASH } from './constants.js';
21
+ export function serializeMagic() {
25
22
  const parts = [];
26
- parts.push((0, core_1.writeMiniNumber)(65536n, 0));
27
- parts.push((0, core_1.writeMiniNumber)(1024n, 0));
28
- parts.push((0, core_1.writeMiniNumber)(256n, 0));
29
- parts.push((0, core_1.writeMiniData)(constants_js_1.MAX_HASH));
30
- parts.push((0, core_1.writeMiniNumber)(65536n, 0));
31
- parts.push((0, core_1.writeMiniNumber)(1024n, 0));
32
- parts.push((0, core_1.writeMiniNumber)(256n, 0));
33
- parts.push((0, core_1.writeMiniData)(constants_js_1.MAX_HASH));
34
- return (0, core_1.concat)(...parts);
23
+ parts.push(writeMiniNumber(65536n, 0));
24
+ parts.push(writeMiniNumber(1024n, 0));
25
+ parts.push(writeMiniNumber(256n, 0));
26
+ parts.push(writeMiniData(MAX_HASH));
27
+ parts.push(writeMiniNumber(65536n, 0));
28
+ parts.push(writeMiniNumber(1024n, 0));
29
+ parts.push(writeMiniNumber(256n, 0));
30
+ parts.push(writeMiniData(MAX_HASH));
31
+ return concat(...parts);
35
32
  }
package/dist/mine-wasm.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * mine-wasm.ts — WASM mining loop loader and wrapper.
4
3
  *
@@ -26,17 +25,11 @@
26
25
  *
27
26
  * mine() returns the found nonce, or -1 (0xFFFFFFFF) if no nonce found in chunk.
28
27
  */
29
- Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.WASM_HEADER_OFFSET = void 0;
31
- exports.setWasmUrl = setWasmUrl;
32
- exports.getBrowserWasmUrl = getBrowserWasmUrl;
33
- exports.isWasmAvailable = isWasmAvailable;
34
- exports.mineChunkWasm = mineChunkWasm;
35
- const core_1 = require("@totemsdk/core");
28
+ import { sha3_256 as nobleSha3_256 } from '@totemsdk/core';
36
29
  /** Byte offset in WASM linear memory where the hash output is written. */
37
30
  const HASH_OUT_OFFSET = 0;
38
31
  /** First byte of the header region (after the 32-byte hash output buffer). */
39
- exports.WASM_HEADER_OFFSET = 32;
32
+ export const WASM_HEADER_OFFSET = 32;
40
33
  /**
41
34
  * Sentinel returned by WASM mine() when no nonce is found in the chunk.
42
35
  * The WAT uses `i32.const -1` (= 0xFFFFFFFF bit pattern).
@@ -58,7 +51,7 @@ let _browserWasmUrl = null;
58
51
  * import { setWasmUrl } from '@totemsdk/txpow';
59
52
  * setWasmUrl(browser.runtime.getURL('miner.wasm'));
60
53
  */
61
- function setWasmUrl(url) {
54
+ export function setWasmUrl(url) {
62
55
  _browserWasmUrl = url;
63
56
  _loadAttempted = false;
64
57
  _instance = null;
@@ -68,7 +61,7 @@ function setWasmUrl(url) {
68
61
  * Return the current browser WASM URL, or null if not yet configured.
69
62
  * Used by the main thread to pass the URL into spawned browser Web Workers.
70
63
  */
71
- function getBrowserWasmUrl() {
64
+ export function getBrowserWasmUrl() {
72
65
  return _browserWasmUrl;
73
66
  }
74
67
  let _instance = null;
@@ -89,7 +82,7 @@ function buildImports() {
89
82
  const memView = new Uint8Array(_memory.buffer);
90
83
  // Slice to get a clean copy unaffected by future mutations
91
84
  const input = memView.slice(headerPtr, headerPtr + headerLen);
92
- const hash = (0, core_1.sha3_256)(input);
85
+ const hash = nobleSha3_256(input);
93
86
  memView.set(hash, outPtr);
94
87
  },
95
88
  },
@@ -159,7 +152,7 @@ async function loadWasm() {
159
152
  * Returns true when the WASM binary is loaded and `mine` is ready to use.
160
153
  * Cached after the first call; subsequent calls are synchronous (via memoised flag).
161
154
  */
162
- async function isWasmAvailable() {
155
+ export async function isWasmAvailable() {
163
156
  return (await loadWasm()) !== null;
164
157
  }
165
158
  /**
@@ -180,7 +173,7 @@ async function isWasmAvailable() {
180
173
  * @param startNonce First nonce value to try.
181
174
  * @param chunkCount Number of consecutive nonce values to try.
182
175
  */
183
- async function mineChunkWasm(headerBuf, nonceOffset, nonceLen, target, startNonce, chunkCount) {
176
+ export async function mineChunkWasm(headerBuf, nonceOffset, nonceLen, target, startNonce, chunkCount) {
184
177
  const inst = await loadWasm();
185
178
  if (!inst || !_memory)
186
179
  return null;
@@ -189,7 +182,7 @@ async function mineChunkWasm(headerBuf, nonceOffset, nonceLen, target, startNonc
189
182
  // instance exports (which has no such property → undefined), making headerPtr=0.
190
183
  const wasmExports = inst.exports;
191
184
  // Memory layout: [0..31]=hash output, [32..32+headerLen-1]=header, [32+headerLen..32+headerLen+31]=target
192
- const headerPtr = exports.WASM_HEADER_OFFSET;
185
+ const headerPtr = WASM_HEADER_OFFSET;
193
186
  const targetPtr = headerPtr + headerBuf.length;
194
187
  const totalNeeded = targetPtr + 32;
195
188
  // Grow memory if necessary
package/dist/mine.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * mine.ts — Local TxPoW proof-of-work mining loop.
4
3
  *
@@ -27,18 +26,11 @@
27
26
  * This means `source` is always accurate: 'wasm' when the binary was used for
28
27
  * the winning chunk; 'js' when the JS path found the nonce.
29
28
  */
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.isLessThan = isLessThan;
32
- exports.buildHeaderTail = buildHeaderTail;
33
- exports.setBrowserWorkerUrl = setBrowserWorkerUrl;
34
- exports.mineHeaderTail = mineHeaderTail;
35
- exports.mineTxPoWInProcess = mineTxPoWInProcess;
36
- exports.mineTxPoW = mineTxPoW;
37
- const core_1 = require("@totemsdk/core");
38
- const core_2 = require("@totemsdk/core");
39
- const magic_js_1 = require("./magic.js");
40
- const constants_js_1 = require("./constants.js");
41
- const mine_wasm_js_1 = require("./mine-wasm.js");
29
+ import { sha3_256 } from '@totemsdk/core';
30
+ import { writeMiniNumber, writeMiniData, writeHashToStream, concat, } from '@totemsdk/core';
31
+ import { serializeMagic } from './magic.js';
32
+ import { MAX_HASH, ZERO_HASH, CASCADE_LEVELS, MAIN_NET_CHAIN_ID } from './constants.js';
33
+ import { mineChunkWasm, isWasmAvailable, getBrowserWasmUrl } from './mine-wasm.js';
42
34
  // ─────────────────────────────────────────────────────────────────────────────
43
35
  // Internal helpers
44
36
  // ─────────────────────────────────────────────────────────────────────────────
@@ -46,7 +38,7 @@ const mine_wasm_js_1 = require("./mine-wasm.js");
46
38
  * Big-endian 256-bit comparison: true if a < b.
47
39
  * Used to check: txpowId < mTxnDifficulty.
48
40
  */
49
- function isLessThan(a, b) {
41
+ export function isLessThan(a, b) {
50
42
  for (let i = 0; i < 32; i++) {
51
43
  if (a[i] < b[i])
52
44
  return true;
@@ -65,7 +57,7 @@ function isLessThan(a, b) {
65
57
  * k=3: 2^23 = 8388608
66
58
  */
67
59
  function nextNonceBoundary(nonce) {
68
- const nonceValueLen = (0, core_2.writeMiniNumber)(nonce, 0).length - 2;
60
+ const nonceValueLen = writeMiniNumber(nonce, 0).length - 2;
69
61
  return 2n ** BigInt(8 * nonceValueLen - 1);
70
62
  }
71
63
  /**
@@ -78,8 +70,8 @@ function nextNonceBoundary(nonce) {
78
70
  * mining (Machine Work Admission) builds its own tail via
79
71
  * `admission/template.ts` with real chain state and a customHash commitment.
80
72
  */
81
- function buildHeaderTail(txBodyHash, timeMilli) {
82
- return (0, core_2.concat)((0, core_2.writeMiniData)(constants_js_1.MAIN_NET_CHAIN_ID), (0, core_2.writeMiniNumber)(timeMilli, 0), (0, core_2.writeMiniNumber)(0n, 0), (0, core_2.writeMiniData)(constants_js_1.MAX_HASH), new Uint8Array([constants_js_1.CASCADE_LEVELS]), (0, core_2.writeHashToStream)(constants_js_1.ZERO_HASH), (0, core_2.writeHashToStream)(constants_js_1.ZERO_HASH), (0, core_2.writeMiniNumber)(0n, 0), (0, magic_js_1.serializeMagic)(), (0, core_2.writeHashToStream)(constants_js_1.ZERO_HASH), (0, core_2.writeHashToStream)(txBodyHash));
73
+ export function buildHeaderTail(txBodyHash, timeMilli) {
74
+ return concat(writeMiniData(MAIN_NET_CHAIN_ID), writeMiniNumber(timeMilli, 0), writeMiniNumber(0n, 0), writeMiniData(MAX_HASH), new Uint8Array([CASCADE_LEVELS]), writeHashToStream(ZERO_HASH), writeHashToStream(ZERO_HASH), writeMiniNumber(0n, 0), serializeMagic(), writeHashToStream(ZERO_HASH), writeHashToStream(txBodyHash));
83
75
  }
84
76
  /**
85
77
  * Synchronously mine a chunk of nonces within a fixed encoding boundary.
@@ -95,7 +87,7 @@ function mineChunkJs(headerBuf, nonceValueLen, target, startNonce, endNonce) {
95
87
  headerBuf[nonceValueOffset + i] = Number(n & 0xffn);
96
88
  n >>= 8n;
97
89
  }
98
- const hash = (0, core_1.sha3_256)(headerBuf);
90
+ const hash = sha3_256(headerBuf);
99
91
  if (isLessThan(hash, target))
100
92
  return nonce;
101
93
  }
@@ -116,7 +108,7 @@ let _browserWorkerUrl = null;
116
108
  * import { setBrowserWorkerUrl } from '@totemsdk/txpow';
117
109
  * setBrowserWorkerUrl(browser.runtime.getURL('mine-worker.js'));
118
110
  */
119
- function setBrowserWorkerUrl(url) {
111
+ export function setBrowserWorkerUrl(url) {
120
112
  _browserWorkerUrl = url;
121
113
  }
122
114
  /**
@@ -170,7 +162,7 @@ async function mineTxPoWViaBrowserWorker(txBodyBytes, txnDifficulty, options) {
170
162
  // Pass the WASM URL so the worker can call setWasmUrl() in its own JS context.
171
163
  // Web Workers have isolated module state — the main thread's setWasmUrl() call
172
164
  // does not carry over. Without this the worker mines in pure JS.
173
- const wasmUrl = (0, mine_wasm_js_1.getBrowserWasmUrl)();
165
+ const wasmUrl = getBrowserWasmUrl();
174
166
  worker.postMessage({
175
167
  txBodyBytes: Array.from(txBodyBytes),
176
168
  txnDifficulty: Array.from(txnDifficulty),
@@ -301,14 +293,14 @@ async function mineTxPoWViaNodeWorker(txBodyBytes, txnDifficulty, options) {
301
293
  * @param target 32-byte difficulty target (big-endian 256-bit).
302
294
  * @param options Chunk size, max iterations, abort signal, timeMilli override.
303
295
  */
304
- async function mineHeaderTail(headerTail, target, options) {
296
+ export async function mineHeaderTail(headerTail, target, options) {
305
297
  const chunkSize = BigInt(options?.chunkSize ?? 10000);
306
298
  const maxIterations = options?.maxIterations !== undefined
307
299
  ? BigInt(options.maxIterations)
308
300
  : undefined;
309
301
  const signal = options?.signal;
310
302
  const forceJs = options?.forceJs ?? false;
311
- const useWasm = !forceJs && (await (0, mine_wasm_js_1.isWasmAvailable)());
303
+ const useWasm = !forceJs && (await isWasmAvailable());
312
304
  const startTime = Date.now();
313
305
  let totalIterations = 0n;
314
306
  let nonce = 0n;
@@ -321,16 +313,16 @@ async function mineHeaderTail(headerTail, target, options) {
321
313
  }
322
314
  const boundary = nextNonceBoundary(nonce);
323
315
  const chunkEnd = nonce + chunkSize < boundary ? nonce + chunkSize : boundary;
324
- const nonceBytes = (0, core_2.writeMiniNumber)(nonce, 0);
316
+ const nonceBytes = writeMiniNumber(nonce, 0);
325
317
  const nonceValueLen = nonceBytes.length - 2;
326
- const headerBuf = (0, core_2.concat)(nonceBytes, headerTail);
318
+ const headerBuf = concat(nonceBytes, headerTail);
327
319
  // ── CRITICAL: WASM and JS are mutually exclusive per chunk ──────────────
328
320
  // When WASM returns null (no nonce in chunk), the chunk has been fully
329
321
  // scanned by WASM — we do NOT re-scan it with JS. Doing so would double
330
322
  // work and could incorrectly set source='wasm' on a JS-found nonce.
331
323
  let found;
332
324
  if (useWasm) {
333
- found = await (0, mine_wasm_js_1.mineChunkWasm)(headerBuf.slice(), // WASM gets its own copy to avoid aliasing
325
+ found = await mineChunkWasm(headerBuf.slice(), // WASM gets its own copy to avoid aliasing
334
326
  2, nonceValueLen, target, nonce, chunkEnd - nonce);
335
327
  }
336
328
  else {
@@ -338,9 +330,9 @@ async function mineHeaderTail(headerTail, target, options) {
338
330
  }
339
331
  // ── End mutually exclusive section ───────────────────────────────────────
340
332
  if (found !== null) {
341
- const finalNonceBytes = (0, core_2.writeMiniNumber)(found, 0);
342
- const finalHeader = (0, core_2.concat)(finalNonceBytes, headerTail);
343
- const txpowId = (0, core_1.sha3_256)(finalHeader);
333
+ const finalNonceBytes = writeMiniNumber(found, 0);
334
+ const finalHeader = concat(finalNonceBytes, headerTail);
335
+ const txpowId = sha3_256(finalHeader);
344
336
  return {
345
337
  minedHeaderBytes: finalHeader,
346
338
  txpowId,
@@ -365,9 +357,9 @@ async function mineHeaderTail(headerTail, target, options) {
365
357
  * Run the mining loop in the current thread/task.
366
358
  * Called directly by the Node.js worker, and by the browser code path.
367
359
  */
368
- async function mineTxPoWInProcess(txBodyBytes, txnDifficulty, options) {
360
+ export async function mineTxPoWInProcess(txBodyBytes, txnDifficulty, options) {
369
361
  const timeMilli = options?.timeMilli ?? BigInt(Date.now());
370
- const bodyHash = (0, core_1.sha3_256)(txBodyBytes);
362
+ const bodyHash = sha3_256(txBodyBytes);
371
363
  const headerTail = buildHeaderTail(bodyHash, timeMilli);
372
364
  return mineHeaderTail(headerTail, txnDifficulty, options);
373
365
  }
@@ -389,7 +381,7 @@ async function mineTxPoWInProcess(txBodyBytes, txnDifficulty, options) {
389
381
  * @param txnDifficulty 32-byte target. MUST be ≤ TX_POW_MIN_DIFFICULTY.
390
382
  * @param options Chunk size, max iterations, abort signal, timeMilli override.
391
383
  */
392
- async function mineTxPoW(txBodyBytes, txnDifficulty, options) {
384
+ export async function mineTxPoW(txBodyBytes, txnDifficulty, options) {
393
385
  // ── Node.js: spawn a worker_threads Worker (keeps event loop unblocked) ──
394
386
  if (shouldUseNodeWorker(options)) {
395
387
  return mineTxPoWViaNodeWorker(txBodyBytes, txnDifficulty, options);
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * serialization.ts — TxPoW envelope serialization.
4
3
  *
@@ -51,45 +50,40 @@
51
50
  * TxPoW ID:
52
51
  * SHA3-256( TxHeader bytes ) — Java: Crypto.getInstance().hashObject(mHeader)
53
52
  */
54
- Object.defineProperty(exports, "__esModule", { value: true });
55
- exports.serializeTxHeader = serializeTxHeader;
56
- exports.computeTxPoWId = computeTxPoWId;
57
- exports.serializeTxBody = serializeTxBody;
58
- exports.serializeTxPoW = serializeTxPoW;
59
- const core_1 = require("@totemsdk/core");
60
- const core_2 = require("@totemsdk/core");
61
- const magic_js_1 = require("./magic.js");
62
- const constants_js_1 = require("./constants.js");
53
+ import { sha3_256 } from '@totemsdk/core';
54
+ import { writeMiniNumber, writeMiniData, concat, writeHashToStream, } from '@totemsdk/core';
55
+ import { serializeMagic } from './magic.js';
56
+ import { MAX_HASH, ZERO_HASH, CASCADE_LEVELS, MAIN_NET_CHAIN_ID, } from './constants.js';
63
57
  /**
64
58
  * Serialize a TxHeader per Minima's TxHeader.writeDataStream().
65
59
  *
66
60
  * @param txBodyHash SHA3-256 of the serialized TxBody (32 bytes)
67
61
  * @param options Optional nonce and timeMilli overrides
68
62
  */
69
- function serializeTxHeader(txBodyHash, options) {
63
+ export function serializeTxHeader(txBodyHash, options) {
70
64
  const nonce = options?.nonce ?? 0n;
71
65
  const timeMilli = options?.timeMilli ?? BigInt(Date.now());
72
66
  const parts = [];
73
- parts.push((0, core_2.writeMiniNumber)(nonce, 0));
74
- parts.push((0, core_2.writeMiniData)(constants_js_1.MAIN_NET_CHAIN_ID));
75
- parts.push((0, core_2.writeMiniNumber)(timeMilli, 0));
76
- parts.push((0, core_2.writeMiniNumber)(0n, 0));
77
- parts.push((0, core_2.writeMiniData)(constants_js_1.MAX_HASH));
78
- parts.push(new Uint8Array([constants_js_1.CASCADE_LEVELS]));
79
- parts.push((0, core_2.writeHashToStream)(constants_js_1.ZERO_HASH));
80
- parts.push((0, core_2.writeHashToStream)(constants_js_1.ZERO_HASH));
81
- parts.push((0, core_2.writeMiniNumber)(0n, 0));
82
- parts.push((0, magic_js_1.serializeMagic)());
83
- parts.push((0, core_2.writeHashToStream)(constants_js_1.ZERO_HASH));
84
- parts.push((0, core_2.writeHashToStream)(txBodyHash));
85
- return (0, core_2.concat)(...parts);
67
+ parts.push(writeMiniNumber(nonce, 0));
68
+ parts.push(writeMiniData(MAIN_NET_CHAIN_ID));
69
+ parts.push(writeMiniNumber(timeMilli, 0));
70
+ parts.push(writeMiniNumber(0n, 0));
71
+ parts.push(writeMiniData(MAX_HASH));
72
+ parts.push(new Uint8Array([CASCADE_LEVELS]));
73
+ parts.push(writeHashToStream(ZERO_HASH));
74
+ parts.push(writeHashToStream(ZERO_HASH));
75
+ parts.push(writeMiniNumber(0n, 0));
76
+ parts.push(serializeMagic());
77
+ parts.push(writeHashToStream(ZERO_HASH));
78
+ parts.push(writeHashToStream(txBodyHash));
79
+ return concat(...parts);
86
80
  }
87
81
  /**
88
82
  * Compute TxPoW ID = SHA3-256(TxHeader bytes).
89
83
  * Matches Java: Crypto.getInstance().hashObject(mHeader) via SHA3Digest(256).
90
84
  */
91
- function computeTxPoWId(headerBytes) {
92
- return (0, core_1.sha3_256)(headerBytes);
85
+ export function computeTxPoWId(headerBytes) {
86
+ return sha3_256(headerBytes);
93
87
  }
94
88
  /**
95
89
  * Build the empty burn transaction bytes.
@@ -103,7 +97,7 @@ function computeTxPoWId(headerBytes) {
103
97
  * writeHashToStream([0x00]) linkHash = ZERO_TXPOWID (1 byte)
104
98
  */
105
99
  function buildEmptyBurnTxBytes() {
106
- return (0, core_2.concat)((0, core_2.writeMiniNumber)(0n, 0), (0, core_2.writeMiniNumber)(0n, 0), (0, core_2.writeMiniNumber)(0n, 0), (0, core_2.writeHashToStream)(new Uint8Array([0x00])));
100
+ return concat(writeMiniNumber(0n, 0), writeMiniNumber(0n, 0), writeMiniNumber(0n, 0), writeHashToStream(new Uint8Array([0x00])));
107
101
  }
108
102
  /**
109
103
  * Build the empty burn witness bytes.
@@ -114,7 +108,7 @@ function buildEmptyBurnTxBytes() {
114
108
  * writeMiniNumber(0n) scriptproof count
115
109
  */
116
110
  function buildEmptyBurnWitnessBytes() {
117
- return (0, core_2.concat)((0, core_2.writeMiniNumber)(0n, 0), (0, core_2.writeMiniNumber)(0n, 0), (0, core_2.writeMiniNumber)(0n, 0));
111
+ return concat(writeMiniNumber(0n, 0), writeMiniNumber(0n, 0), writeMiniNumber(0n, 0));
118
112
  }
119
113
  /**
120
114
  * Serialize a TxBody per Minima's TxBody.writeDataStream().
@@ -123,8 +117,8 @@ function buildEmptyBurnWitnessBytes() {
123
117
  * @param witnessBytes Pre-serialized Witness bytes (from extension's serializeWitness)
124
118
  * @param options Optional txnDifficulty override and test PRNG
125
119
  */
126
- function serializeTxBody(txBytes, witnessBytes, options) {
127
- const txnDifficulty = options?.txnDifficulty ?? constants_js_1.MAX_HASH;
120
+ export function serializeTxBody(txBytes, witnessBytes, options) {
121
+ const txnDifficulty = options?.txnDifficulty ?? MAX_HASH;
128
122
  let prng;
129
123
  if (options?.prng) {
130
124
  prng = options.prng;
@@ -137,7 +131,7 @@ function serializeTxBody(txBytes, witnessBytes, options) {
137
131
  crypto.getRandomValues(fresh);
138
132
  prng = fresh;
139
133
  }
140
- return (0, core_2.concat)((0, core_2.writeHashToStream)(prng), (0, core_2.writeMiniData)(txnDifficulty), txBytes, witnessBytes, buildEmptyBurnTxBytes(), buildEmptyBurnWitnessBytes(), (0, core_2.writeMiniNumber)(0n, 0));
134
+ return concat(writeHashToStream(prng), writeMiniData(txnDifficulty), txBytes, witnessBytes, buildEmptyBurnTxBytes(), buildEmptyBurnWitnessBytes(), writeMiniNumber(0n, 0));
141
135
  }
142
136
  /**
143
137
  * Serialize a complete TxPoW per Minima's TxPoW.writeDataStream().
@@ -153,8 +147,8 @@ function serializeTxBody(txBytes, witnessBytes, options) {
153
147
  * @param witnessBytes Pre-serialized Witness bytes
154
148
  * @param options Optional txnDifficulty, nonce, timeMilli, prng
155
149
  */
156
- function serializeTxPoW(txBytes, witnessBytes, options) {
150
+ export function serializeTxPoW(txBytes, witnessBytes, options) {
157
151
  const txBody = serializeTxBody(txBytes, witnessBytes, options);
158
- const txBodyHash = (0, core_1.sha3_256)(txBody);
159
- return (0, core_2.concat)(serializeTxHeader(txBodyHash, options), new Uint8Array([0x01]), txBody);
152
+ const txBodyHash = sha3_256(txBody);
153
+ return concat(serializeTxHeader(txBodyHash, options), new Uint8Array([0x01]), txBody);
160
154
  }