@totemsdk/omnia-splice 0.1.1 → 0.1.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.
- package/README.md +90 -0
- package/package.json +14 -6
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# @totemsdk/omnia-splice
|
|
2
|
+
|
|
3
|
+
**Resize channels without closing them.**
|
|
4
|
+
|
|
5
|
+
Channel splicing lets you add or remove funds from an active Omnia channel without the disruptive close → reopen cycle. A splice produces a new on-chain UTXO with the adjusted balance while keeping the channel's off-chain state intact.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @totemsdk/omnia-splice
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## What's inside
|
|
14
|
+
|
|
15
|
+
| Export | What it does |
|
|
16
|
+
|--------|-------------|
|
|
17
|
+
| `proposeSpliceIn(channel, amount)` | Propose adding funds to a channel |
|
|
18
|
+
| `proposeSpliceOut(channel, amount)` | Propose withdrawing funds from a channel |
|
|
19
|
+
| `acceptSplice(proposal, signer)` | Co-sign a splice proposal |
|
|
20
|
+
| `quiesceChannel(channel)` | Drain all in-flight HTLCs before splicing (required safety step) |
|
|
21
|
+
| `buildSpliceTx(proposal)` | Construct the on-chain splice transaction |
|
|
22
|
+
| `finalizeSplice(proposal, signatures)` | Finalize and return the broadcast-ready hex |
|
|
23
|
+
|
|
24
|
+
### Error taxonomy
|
|
25
|
+
|
|
26
|
+
| Error | Cause |
|
|
27
|
+
|-------|-------|
|
|
28
|
+
| `SpliceBalanceConservationError` | Output amounts don't sum correctly — prevents funds from disappearing |
|
|
29
|
+
| `PendingHTLCError` | Splice attempted while HTLCs are still in-flight (quiesce first) |
|
|
30
|
+
| `SpliceChannelStatusError` | Channel is not in a state that permits splicing |
|
|
31
|
+
| `SpliceSignatureMismatchError` | Co-signature does not match the proposal |
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
### Splice in (add funds)
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { quiesceChannel, proposeSpliceIn, acceptSplice, buildSpliceTx, finalizeSplice } from '@totemsdk/omnia-splice';
|
|
39
|
+
|
|
40
|
+
// 1. Drain HTLCs (both sides must stop sending)
|
|
41
|
+
await quiesceChannel(channel);
|
|
42
|
+
|
|
43
|
+
// 2. Local side proposes adding 50 MIN
|
|
44
|
+
const proposal = await proposeSpliceIn(channel, { amount: '50', tokenid: '0x00' });
|
|
45
|
+
|
|
46
|
+
// 3. Remote side accepts
|
|
47
|
+
const remoteSig = await remoteAccept(proposal); // out-of-band exchange
|
|
48
|
+
|
|
49
|
+
// 4. Build and finalize the on-chain transaction
|
|
50
|
+
const spliceTx = buildSpliceTx(proposal);
|
|
51
|
+
const finalHex = finalizeSplice(proposal, [localSig, remoteSig]);
|
|
52
|
+
|
|
53
|
+
// 5. Broadcast
|
|
54
|
+
await provider.broadcastTxPoW(finalHex);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Splice out (withdraw funds)
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { proposeSpliceOut } from '@totemsdk/omnia-splice';
|
|
61
|
+
|
|
62
|
+
await quiesceChannel(channel);
|
|
63
|
+
const proposal = await proposeSpliceOut(channel, {
|
|
64
|
+
amount: '20',
|
|
65
|
+
withdrawTo: 'MxDEF...', // on-chain destination for the withdrawn funds
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Error handling
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { PendingHTLCError, SpliceBalanceConservationError } from '@totemsdk/omnia-splice';
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
await proposeSpliceIn(channel, { amount: '50', tokenid: '0x00' });
|
|
76
|
+
} catch (err) {
|
|
77
|
+
if (err instanceof PendingHTLCError) {
|
|
78
|
+
console.error('Must quiesce channel first — there are in-flight HTLCs');
|
|
79
|
+
}
|
|
80
|
+
if (err instanceof SpliceBalanceConservationError) {
|
|
81
|
+
console.error('Balance mismatch in splice proposal');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## See also
|
|
87
|
+
|
|
88
|
+
- [`@totemsdk/omnia`](../omnia) — the channel state machine being spliced
|
|
89
|
+
- [`@totemsdk/tx-builder`](../tx-builder) — used internally by `buildSpliceTx`
|
|
90
|
+
- [`@totemsdk/wots-lease`](../wots-lease) — signing slots managed during splice
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@totemsdk/omnia-splice",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Channel splicing for @totemsdk/omnia — resize Minima eltoo channels without a close+reopen cycle",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,11 +17,19 @@
|
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@noble/hashes": "^1.3.0",
|
|
20
|
-
"@totemsdk/
|
|
21
|
-
"@totemsdk/
|
|
22
|
-
"@totemsdk/
|
|
23
|
-
"@totemsdk/
|
|
24
|
-
"@totemsdk/wots-lease": "0.1.
|
|
20
|
+
"@totemsdk/omnia": "0.1.3",
|
|
21
|
+
"@totemsdk/core": "1.0.9",
|
|
22
|
+
"@totemsdk/txpow": "0.1.3",
|
|
23
|
+
"@totemsdk/tx-builder": "0.1.4",
|
|
24
|
+
"@totemsdk/wots-lease": "0.1.2"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@noble/hashes": ">=1.3.0 <2.0.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependenciesMeta": {
|
|
30
|
+
"@noble/hashes": {
|
|
31
|
+
"optional": false
|
|
32
|
+
}
|
|
25
33
|
},
|
|
26
34
|
"devDependencies": {
|
|
27
35
|
"@types/jest": "^29.0.0",
|