@totemsdk/omnia-splice 0.1.6 → 0.1.7

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.
@@ -18,7 +18,7 @@ import type { SpliceProposal, SpliceAcceptance, SplicedChannel, QuiescedChannel
18
18
  * ```ts
19
19
  * // Example test helper:
20
20
  * verifySignature: (sig, digest, pkd) => {
21
- * const expected = sha3_256(concatBytes(fromHex(pkd), digest));
21
+ * const expected = sha3_256(concatBytes(hexToBytes(pkd), digest));
22
22
  * return expected.length === sig.length
23
23
  * && expected.every((b, i) => b === sig[i]);
24
24
  * }
package/dist/finalize.js CHANGED
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.finalizeSplice = finalizeSplice;
4
4
  const core_1 = require("@totemsdk/core");
5
5
  const txpow_1 = require("@totemsdk/txpow");
6
- const core_2 = require("@totemsdk/core");
7
6
  const splice_tx_js_1 = require("./splice-tx.js");
8
7
  const errors_js_1 = require("./errors.js");
9
8
  function defaultWotsVerify(sig, digest, pkd) {
10
9
  try {
11
- return (0, core_1.wotsVerifyDigest)(sig, digest, (0, core_1.fromHex)(pkd));
10
+ return (0, core_1.wotsVerifyDigest)(sig, digest, (0, core_1.hexToBytes)(pkd));
12
11
  }
13
12
  catch {
14
13
  return false;
@@ -23,9 +22,9 @@ function assembleSpliceWitness(sig1, sig2) {
23
22
  const encodeVarBytes = (b) => {
24
23
  const lenBuf = new Uint8Array(4);
25
24
  new DataView(lenBuf.buffer).setInt32(0, b.length, false);
26
- return (0, core_2.concatBytes)(lenBuf, b);
25
+ return (0, core_1.concatBytes)(lenBuf, b);
27
26
  };
28
- return (0, core_2.concatBytes)(encodeMiniNumber(2), encodeVarBytes(sig1), encodeVarBytes(sig2), encodeMiniNumber(0), encodeMiniNumber(0));
27
+ return (0, core_1.concatBytes)((0, core_1.concatBytes)((0, core_1.concatBytes)((0, core_1.concatBytes)(encodeMiniNumber(2), encodeVarBytes(sig1)), encodeVarBytes(sig2)), encodeMiniNumber(0)), encodeMiniNumber(0));
29
28
  }
30
29
  /**
31
30
  * Structural authorization checks: both parties must be distinct channel
@@ -158,7 +157,7 @@ async function finalizeSplice(channel, proposal, acceptance, options) {
158
157
  const difficulty = options?.mineDifficulty ?? txpow_1.TX_POW_MIN_DIFFICULTY;
159
158
  const txBody = (0, txpow_1.serializeTxBody)(txBytes, witnessBytes);
160
159
  const mined = await (0, txpow_1.mineTxPoW)(txBody, difficulty);
161
- const fullTxPoW = (0, core_2.concatBytes)(mined.minedHeaderBytes, new Uint8Array([0x01]), txBody);
160
+ const fullTxPoW = (0, core_1.concatBytes)((0, core_1.concatBytes)(mined.minedHeaderBytes, new Uint8Array([0x01])), txBody);
162
161
  const txHex = Buffer.from(fullTxPoW).toString('hex');
163
162
  spliceFundingTxId = Buffer.from(mined.txpowId).toString('hex');
164
163
  if (options?.broadcast) {
package/dist/splice-tx.js CHANGED
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildSpliceTx = buildSpliceTx;
4
4
  exports.spliceDraftToMinimaBytes = spliceDraftToMinimaBytes;
5
5
  exports.computeSpliceTxDigest = computeSpliceTxDigest;
6
- const sha3_js_1 = require("@noble/hashes/sha3.js");
7
6
  const core_1 = require("@totemsdk/core");
7
+ const core_2 = require("@totemsdk/core");
8
8
  const omnia_1 = require("@totemsdk/omnia");
9
9
  const errors_js_1 = require("./errors.js");
10
10
  const STATE_SETTLEMENT_PORT = 100;
@@ -113,13 +113,13 @@ function buildSpliceTx(channel, params) {
113
113
  * the final splice TX assembles both signatures into the witness.
114
114
  */
115
115
  function spliceDraftToMinimaBytes(draft) {
116
- const tx = (0, core_1.createDefaultTransaction)();
116
+ const tx = (0, core_2.createDefaultTransaction)();
117
117
  for (const inp of draft.inputs) {
118
- tx.inputs.push((0, core_1.buildMinimaCoin)({
119
- coinId: (0, core_1.fromHex)(inp.coinId),
120
- address: (0, core_1.fromHex)(inp.address),
118
+ tx.inputs.push((0, core_2.buildMinimaCoin)({
119
+ coinId: (0, core_2.hexToBytes)(inp.coinId),
120
+ address: (0, core_2.hexToBytes)(inp.address),
121
121
  amount: inp.amount.toString(),
122
- tokenId: (0, core_1.fromHex)(inp.tokenId),
122
+ tokenId: (0, core_2.hexToBytes)(inp.tokenId),
123
123
  }));
124
124
  }
125
125
  for (const out of draft.outputs) {
@@ -129,10 +129,10 @@ function spliceDraftToMinimaBytes(draft) {
129
129
  { port: STATE_SEQUENCE_PORT, value: BigInt(out.stateVarSequence), type: 'number' },
130
130
  ]
131
131
  : [];
132
- tx.outputs.push((0, core_1.buildMinimaCoin)({
133
- address: (0, core_1.fromHex)(out.address),
132
+ tx.outputs.push((0, core_2.buildMinimaCoin)({
133
+ address: (0, core_2.hexToBytes)(out.address),
134
134
  amount: out.amount.toString(),
135
- tokenId: (0, core_1.fromHex)(out.tokenId),
135
+ tokenId: (0, core_2.hexToBytes)(out.tokenId),
136
136
  storeState: out.storeState,
137
137
  state,
138
138
  }));
@@ -141,7 +141,7 @@ function spliceDraftToMinimaBytes(draft) {
141
141
  { port: STATE_SETTLEMENT_PORT, value: false, type: 'bool' },
142
142
  { port: STATE_SEQUENCE_PORT, value: 0n, type: 'number' },
143
143
  ];
144
- return (0, core_1.serializeTransaction)(tx);
144
+ return (0, core_2.serializeTransaction)(JSON.stringify(tx));
145
145
  }
146
146
  /**
147
147
  * Compute a 32-byte digest over the splice TX draft for WOTS signing.
@@ -178,5 +178,5 @@ function computeSpliceTxDigest(draft) {
178
178
  .map(([k, v]) => [k, v.toString()]),
179
179
  },
180
180
  });
181
- return (0, sha3_js_1.sha3_256)(new TextEncoder().encode(canonical));
181
+ return (0, core_1.sha3_256)(new TextEncoder().encode(canonical));
182
182
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@totemsdk/omnia-splice",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Channel splicing for @totemsdk/omnia — resize Minima eltoo channels without a close+reopen cycle",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "scripts": {
15
15
  "build": "tsc",
16
- "prepare": "echo skipping pre-existing tsc failure",
16
+ "prepare": "tsc",
17
17
  "clean": "rm -rf dist",
18
18
  "test": "node ../../node_modules/jest/bin/jest.js --config jest.config.cjs --passWithNoTests"
19
19
  },