@totemsdk/omnia-vtxo 0.5.2 → 0.5.4

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.
@@ -4,13 +4,13 @@
4
4
  * The pool is an on-chain state output holding `totalCapacity`. An epoch's batch
5
5
  * root is committed as STATE(100), the epoch number in STATE(101), the absolute
6
6
  * exit-eligibility block in STATE(102), and each holder's committed share in
7
- * STATE(200+k).
7
+ * STATE(base+k).
8
8
  *
9
9
  * Custody (RFC-039 / CUSTODY-POLICY §2):
10
10
  * - **Per-share unilateral exit.** After `@BLOCK GT PREVSTATE(102)` each holder
11
- * may withdraw **only its own committed share** (`PREVSTATE(200+k)`, the spent
11
+ * may withdraw **only its own committed share** (`PREVSTATE(base+k)`, the spent
12
12
  * coin's share), to its own key, zeroing that share in the successor
13
- * (`STATE(200+k) EQ 0`) and returning the remainder to the pool. A holder
13
+ * (`STATE(base+k) EQ 0`) and returning the remainder to the pool. A holder
14
14
  * cannot pay itself more than its share, so one holder can never rug the others.
15
15
  * - **Cooperative update.** Before the exit window the pool may only move by
16
16
  * `MULTISIG(operator + all holders)`, epoch-monotone (`ASSERT EPOCH GT
@@ -22,8 +22,20 @@
22
22
  * The operator holds no unilateral path: it cannot move funds, cannot advance the
23
23
  * exit block, and cannot stop a holder's exit. It is a liveness-only peer.
24
24
  */
25
- /** State port base for per-holder shares: holder k ⇒ port 200+k (ports are bytes, ≤255). */
26
- export declare const POOL_SHARE_PORT_BASE = 200;
25
+ /**
26
+ * State port base for per-holder shares: holder k ⇒ `base + k`. Kept below the
27
+ * MSHS-2 floor so Omnia ports never collide with MASH (ports are bytes, 0–255).
28
+ * See RFC-048 §12 / RFC-049 §5.
29
+ */
30
+ export declare const POOL_SHARE_PORT_BASE = 128;
31
+ /** Lowest port reserved for MSHS-2 (MASH); Omnia ports MUST stay below this.
32
+ * The node installs the MASH authorization bundle at ports **230–255**
33
+ * (`bundleBase = 256 − (4 + k) = 230`): the header R / ROOTS_BLOB /
34
+ * SECRETS_BLOB / TREE_SIG at 230–233 and PROOF at 234–255. A composite
35
+ * MASH + Omnia coin must therefore keep Omnia ports ≤ 229. */
36
+ export declare const MSHS_PORT_FLOOR = 230;
37
+ /** Maximum holders whose share ports remain below the MSHS floor. */
38
+ export declare const POOL_MAX_HOLDERS: number;
27
39
  export interface PoolScriptParams {
28
40
  /** Operator WOTS public-key digest (64 hex). */
29
41
  operatorPublicKeyDigest: string;
@@ -5,13 +5,13 @@
5
5
  * The pool is an on-chain state output holding `totalCapacity`. An epoch's batch
6
6
  * root is committed as STATE(100), the epoch number in STATE(101), the absolute
7
7
  * exit-eligibility block in STATE(102), and each holder's committed share in
8
- * STATE(200+k).
8
+ * STATE(base+k).
9
9
  *
10
10
  * Custody (RFC-039 / CUSTODY-POLICY §2):
11
11
  * - **Per-share unilateral exit.** After `@BLOCK GT PREVSTATE(102)` each holder
12
- * may withdraw **only its own committed share** (`PREVSTATE(200+k)`, the spent
12
+ * may withdraw **only its own committed share** (`PREVSTATE(base+k)`, the spent
13
13
  * coin's share), to its own key, zeroing that share in the successor
14
- * (`STATE(200+k) EQ 0`) and returning the remainder to the pool. A holder
14
+ * (`STATE(base+k) EQ 0`) and returning the remainder to the pool. A holder
15
15
  * cannot pay itself more than its share, so one holder can never rug the others.
16
16
  * - **Cooperative update.** Before the exit window the pool may only move by
17
17
  * `MULTISIG(operator + all holders)`, epoch-monotone (`ASSERT EPOCH GT
@@ -24,13 +24,25 @@
24
24
  * exit block, and cannot stop a holder's exit. It is a liveness-only peer.
25
25
  */
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.POOL_SHARE_PORT_BASE = void 0;
27
+ exports.POOL_MAX_HOLDERS = exports.MSHS_PORT_FLOOR = exports.POOL_SHARE_PORT_BASE = void 0;
28
28
  exports.buildPoolScript = buildPoolScript;
29
29
  exports.poolScriptAddress = poolScriptAddress;
30
30
  exports.buildAndHashPoolScript = buildAndHashPoolScript;
31
31
  const core_1 = require("@totemsdk/core");
32
- /** State port base for per-holder shares: holder k ⇒ port 200+k (ports are bytes, ≤255). */
33
- exports.POOL_SHARE_PORT_BASE = 200;
32
+ /**
33
+ * State port base for per-holder shares: holder k ⇒ `base + k`. Kept below the
34
+ * MSHS-2 floor so Omnia ports never collide with MASH (ports are bytes, 0–255).
35
+ * See RFC-048 §12 / RFC-049 §5.
36
+ */
37
+ exports.POOL_SHARE_PORT_BASE = 128;
38
+ /** Lowest port reserved for MSHS-2 (MASH); Omnia ports MUST stay below this.
39
+ * The node installs the MASH authorization bundle at ports **230–255**
40
+ * (`bundleBase = 256 − (4 + k) = 230`): the header R / ROOTS_BLOB /
41
+ * SECRETS_BLOB / TREE_SIG at 230–233 and PROOF at 234–255. A composite
42
+ * MASH + Omnia coin must therefore keep Omnia ports ≤ 229. */
43
+ exports.MSHS_PORT_FLOOR = 230;
44
+ /** Maximum holders whose share ports remain below the MSHS floor. */
45
+ exports.POOL_MAX_HOLDERS = exports.MSHS_PORT_FLOOR - exports.POOL_SHARE_PORT_BASE;
34
46
  function pkHex(digest, label) {
35
47
  const raw = digest.replace(/^0x/i, '');
36
48
  if (!/^[0-9a-fA-F]{64}$/.test(raw)) {
@@ -44,6 +56,9 @@ function buildPoolScript(params) {
44
56
  if (!Array.isArray(params.holders) || params.holders.length < 1) {
45
57
  throw new Error('pool requires at least one holder');
46
58
  }
59
+ if (params.holders.length > exports.POOL_MAX_HOLDERS) {
60
+ throw new Error(`pool supports at most ${exports.POOL_MAX_HOLDERS} holders (got ${params.holders.length}) — share ports would reach the MSHS-2 band (≥${exports.MSHS_PORT_FLOOR})`);
61
+ }
47
62
  const holders = params.holders.map((h, i) => pkHex(h, `holder[${i}]`));
48
63
  if (!Number.isInteger(params.exitBlock) || params.exitBlock < 0) {
49
64
  throw new Error(`exitBlock must be a non-negative integer, got ${JSON.stringify(params.exitBlock)}`);
@@ -4,13 +4,13 @@
4
4
  * The pool is an on-chain state output holding `totalCapacity`. An epoch's batch
5
5
  * root is committed as STATE(100), the epoch number in STATE(101), the absolute
6
6
  * exit-eligibility block in STATE(102), and each holder's committed share in
7
- * STATE(200+k).
7
+ * STATE(base+k).
8
8
  *
9
9
  * Custody (RFC-039 / CUSTODY-POLICY §2):
10
10
  * - **Per-share unilateral exit.** After `@BLOCK GT PREVSTATE(102)` each holder
11
- * may withdraw **only its own committed share** (`PREVSTATE(200+k)`, the spent
11
+ * may withdraw **only its own committed share** (`PREVSTATE(base+k)`, the spent
12
12
  * coin's share), to its own key, zeroing that share in the successor
13
- * (`STATE(200+k) EQ 0`) and returning the remainder to the pool. A holder
13
+ * (`STATE(base+k) EQ 0`) and returning the remainder to the pool. A holder
14
14
  * cannot pay itself more than its share, so one holder can never rug the others.
15
15
  * - **Cooperative update.** Before the exit window the pool may only move by
16
16
  * `MULTISIG(operator + all holders)`, epoch-monotone (`ASSERT EPOCH GT
@@ -22,8 +22,20 @@
22
22
  * The operator holds no unilateral path: it cannot move funds, cannot advance the
23
23
  * exit block, and cannot stop a holder's exit. It is a liveness-only peer.
24
24
  */
25
- /** State port base for per-holder shares: holder k ⇒ port 200+k (ports are bytes, ≤255). */
26
- export declare const POOL_SHARE_PORT_BASE = 200;
25
+ /**
26
+ * State port base for per-holder shares: holder k ⇒ `base + k`. Kept below the
27
+ * MSHS-2 floor so Omnia ports never collide with MASH (ports are bytes, 0–255).
28
+ * See RFC-048 §12 / RFC-049 §5.
29
+ */
30
+ export declare const POOL_SHARE_PORT_BASE = 128;
31
+ /** Lowest port reserved for MSHS-2 (MASH); Omnia ports MUST stay below this.
32
+ * The node installs the MASH authorization bundle at ports **230–255**
33
+ * (`bundleBase = 256 − (4 + k) = 230`): the header R / ROOTS_BLOB /
34
+ * SECRETS_BLOB / TREE_SIG at 230–233 and PROOF at 234–255. A composite
35
+ * MASH + Omnia coin must therefore keep Omnia ports ≤ 229. */
36
+ export declare const MSHS_PORT_FLOOR = 230;
37
+ /** Maximum holders whose share ports remain below the MSHS floor. */
38
+ export declare const POOL_MAX_HOLDERS: number;
27
39
  export interface PoolScriptParams {
28
40
  /** Operator WOTS public-key digest (64 hex). */
29
41
  operatorPublicKeyDigest: string;
@@ -4,13 +4,13 @@
4
4
  * The pool is an on-chain state output holding `totalCapacity`. An epoch's batch
5
5
  * root is committed as STATE(100), the epoch number in STATE(101), the absolute
6
6
  * exit-eligibility block in STATE(102), and each holder's committed share in
7
- * STATE(200+k).
7
+ * STATE(base+k).
8
8
  *
9
9
  * Custody (RFC-039 / CUSTODY-POLICY §2):
10
10
  * - **Per-share unilateral exit.** After `@BLOCK GT PREVSTATE(102)` each holder
11
- * may withdraw **only its own committed share** (`PREVSTATE(200+k)`, the spent
11
+ * may withdraw **only its own committed share** (`PREVSTATE(base+k)`, the spent
12
12
  * coin's share), to its own key, zeroing that share in the successor
13
- * (`STATE(200+k) EQ 0`) and returning the remainder to the pool. A holder
13
+ * (`STATE(base+k) EQ 0`) and returning the remainder to the pool. A holder
14
14
  * cannot pay itself more than its share, so one holder can never rug the others.
15
15
  * - **Cooperative update.** Before the exit window the pool may only move by
16
16
  * `MULTISIG(operator + all holders)`, epoch-monotone (`ASSERT EPOCH GT
@@ -23,8 +23,20 @@
23
23
  * exit block, and cannot stop a holder's exit. It is a liveness-only peer.
24
24
  */
25
25
  import { computeScriptAddress } from '@totemsdk/core';
26
- /** State port base for per-holder shares: holder k ⇒ port 200+k (ports are bytes, ≤255). */
27
- export const POOL_SHARE_PORT_BASE = 200;
26
+ /**
27
+ * State port base for per-holder shares: holder k ⇒ `base + k`. Kept below the
28
+ * MSHS-2 floor so Omnia ports never collide with MASH (ports are bytes, 0–255).
29
+ * See RFC-048 §12 / RFC-049 §5.
30
+ */
31
+ export const POOL_SHARE_PORT_BASE = 128;
32
+ /** Lowest port reserved for MSHS-2 (MASH); Omnia ports MUST stay below this.
33
+ * The node installs the MASH authorization bundle at ports **230–255**
34
+ * (`bundleBase = 256 − (4 + k) = 230`): the header R / ROOTS_BLOB /
35
+ * SECRETS_BLOB / TREE_SIG at 230–233 and PROOF at 234–255. A composite
36
+ * MASH + Omnia coin must therefore keep Omnia ports ≤ 229. */
37
+ export const MSHS_PORT_FLOOR = 230;
38
+ /** Maximum holders whose share ports remain below the MSHS floor. */
39
+ export const POOL_MAX_HOLDERS = MSHS_PORT_FLOOR - POOL_SHARE_PORT_BASE;
28
40
  function pkHex(digest, label) {
29
41
  const raw = digest.replace(/^0x/i, '');
30
42
  if (!/^[0-9a-fA-F]{64}$/.test(raw)) {
@@ -38,6 +50,9 @@ export function buildPoolScript(params) {
38
50
  if (!Array.isArray(params.holders) || params.holders.length < 1) {
39
51
  throw new Error('pool requires at least one holder');
40
52
  }
53
+ if (params.holders.length > POOL_MAX_HOLDERS) {
54
+ throw new Error(`pool supports at most ${POOL_MAX_HOLDERS} holders (got ${params.holders.length}) — share ports would reach the MSHS-2 band (≥${MSHS_PORT_FLOOR})`);
55
+ }
41
56
  const holders = params.holders.map((h, i) => pkHex(h, `holder[${i}]`));
42
57
  if (!Number.isInteger(params.exitBlock) || params.exitBlock < 0) {
43
58
  throw new Error(`exitBlock must be a non-negative integer, got ${JSON.stringify(params.exitBlock)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@totemsdk/omnia-vtxo",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "Virtual UTXO / payment-pool claim layer for Omnia — cash-like off-chain balance primitive for Totem Edge",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",
@@ -25,10 +25,10 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "@totemsdk/chain-provider": "^0.2.1",
28
+ "@totemsdk/core": "^1.3.0",
28
29
  "@totemsdk/omnia": "^2.0.1",
29
- "@totemsdk/txpow": "^1.0.2",
30
30
  "@totemsdk/storage": "^0.1.0",
31
- "@totemsdk/core": "^1.3.0",
31
+ "@totemsdk/txpow": "^1.0.2",
32
32
  "@totemsdk/wots-lease": "^1.0.1"
33
33
  },
34
34
  "devDependencies": {