@totemsdk/omnia-splice 0.3.2 → 0.3.3

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.
@@ -200,9 +200,10 @@ async function finalizeSplice(channel, proposal, acceptance, options) {
200
200
  const params = proposal.params;
201
201
  // Observe the actual successor. The old channel coin is spent by the splice,
202
202
  // so `txid-0` is only a placeholder; the live coin id comes from the funding
203
- // address. Until it is confirmed the channel must not be reported active.
203
+ // address. Until it is confirmed the channel must not be reported active —
204
+ // with no observer we cannot know, so it stays funding_pending (CAN-011).
204
205
  let spliceFundingCoinId = `${spliceFundingTxId}-0`;
205
- let successorStatus = 'active';
206
+ let successorStatus = 'funding_pending';
206
207
  if (options?.chainProvider) {
207
208
  const observed = await (0, successor_js_1.observeSpliceSuccessor)(options.chainProvider, {
208
209
  address: channel.fundingAddress,
@@ -28,10 +28,19 @@ async function observeSpliceSuccessor(chain, options) {
28
28
  const deadline = now() + timeoutMs;
29
29
  for (;;) {
30
30
  const coins = await chain.getCoins({ address: options.address, tokenId: options.tokenId });
31
- const candidate = coins.find((coin) => !coin.spent
31
+ const candidates = coins.filter((coin) => !coin.spent
32
32
  && coin.address.toLowerCase() === options.address.toLowerCase()
33
33
  && coin.tokenid.toLowerCase() === options.tokenId.toLowerCase()
34
34
  && BigInt(coin.amount) === options.amount);
35
+ // CAN-012: the channel input floats (COINID_ELTOO), so the coin id cannot be
36
+ // predicted from the transaction. Two coins matching the same address, token
37
+ // and amount are indistinguishable here; picking the first would silently
38
+ // adopt a coin the channel does not control.
39
+ if (candidates.length > 1) {
40
+ throw new Error(`Ambiguous splice successor: ${candidates.length} unspent coins match `
41
+ + `${options.address} token ${options.tokenId} amount ${options.amount}`);
42
+ }
43
+ const candidate = candidates[0];
35
44
  if (candidate) {
36
45
  const tip = await chain.getTip();
37
46
  const created = candidate.created !== undefined ? Number(candidate.created) : NaN;
package/dist/finalize.js CHANGED
@@ -197,9 +197,10 @@ export async function finalizeSplice(channel, proposal, acceptance, options) {
197
197
  const params = proposal.params;
198
198
  // Observe the actual successor. The old channel coin is spent by the splice,
199
199
  // so `txid-0` is only a placeholder; the live coin id comes from the funding
200
- // address. Until it is confirmed the channel must not be reported active.
200
+ // address. Until it is confirmed the channel must not be reported active —
201
+ // with no observer we cannot know, so it stays funding_pending (CAN-011).
201
202
  let spliceFundingCoinId = `${spliceFundingTxId}-0`;
202
- let successorStatus = 'active';
203
+ let successorStatus = 'funding_pending';
203
204
  if (options?.chainProvider) {
204
205
  const observed = await observeSpliceSuccessor(options.chainProvider, {
205
206
  address: channel.fundingAddress,
package/dist/successor.js CHANGED
@@ -24,10 +24,19 @@ export async function observeSpliceSuccessor(chain, options) {
24
24
  const deadline = now() + timeoutMs;
25
25
  for (;;) {
26
26
  const coins = await chain.getCoins({ address: options.address, tokenId: options.tokenId });
27
- const candidate = coins.find((coin) => !coin.spent
27
+ const candidates = coins.filter((coin) => !coin.spent
28
28
  && coin.address.toLowerCase() === options.address.toLowerCase()
29
29
  && coin.tokenid.toLowerCase() === options.tokenId.toLowerCase()
30
30
  && BigInt(coin.amount) === options.amount);
31
+ // CAN-012: the channel input floats (COINID_ELTOO), so the coin id cannot be
32
+ // predicted from the transaction. Two coins matching the same address, token
33
+ // and amount are indistinguishable here; picking the first would silently
34
+ // adopt a coin the channel does not control.
35
+ if (candidates.length > 1) {
36
+ throw new Error(`Ambiguous splice successor: ${candidates.length} unspent coins match `
37
+ + `${options.address} token ${options.tokenId} amount ${options.amount}`);
38
+ }
39
+ const candidate = candidates[0];
31
40
  if (candidate) {
32
41
  const tip = await chain.getTip();
33
42
  const created = candidate.created !== undefined ? Number(candidate.created) : NaN;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@totemsdk/omnia-splice",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Channel splicing for @totemsdk/omnia — resize Minima eltoo channels without a close+reopen cycle",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",
@@ -25,11 +25,11 @@
25
25
  "NOTICE"
26
26
  ],
27
27
  "dependencies": {
28
- "@totemsdk/omnia": "^2.4.1",
29
- "@totemsdk/core": "^1.4.2",
28
+ "@totemsdk/omnia": "^2.4.4",
29
+ "@totemsdk/core": "^1.5.0",
30
+ "@totemsdk/wots-lease": "^1.0.3",
30
31
  "@totemsdk/txpow": "^1.1.1",
31
- "@totemsdk/wots-lease": "^1.0.2",
32
- "@totemsdk/tx-builder": "^0.3.1",
32
+ "@totemsdk/tx-builder": "^0.3.3",
33
33
  "@totemsdk/storage": "^0.2.2"
34
34
  },
35
35
  "devDependencies": {
@@ -74,6 +74,7 @@
74
74
  "build": "tsc && tsc -p tsconfig.cjs.json && node -e \"require('fs').writeFileSync('dist/cjs/package.json', JSON.stringify({type:'commonjs'})+'\\n')\"",
75
75
  "clean": "rm -rf dist rust/pkg rust/pkg-node rust/target",
76
76
  "test": "jest --config ../../tests/jest/omnia-splice.cjs",
77
- "build:wasm": "cd rust && wasm-pack build --target bundler --out-dir pkg && wasm-pack build --target nodejs --out-dir pkg-node"
77
+ "build:wasm": "cd rust && wasm-pack build --target bundler --out-dir pkg && wasm-pack build --target nodejs --out-dir pkg-node",
78
+ "test:integration": "node --test ../../tests/qualification/security-train/test/omnia-splice-sequence.test.mjs"
78
79
  }
79
80
  }