@totemsdk/omnia-splice 0.1.3 → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +3 -3
- package/dist/errors.js +17 -7
- package/dist/finalize.js +29 -26
- package/dist/index.js +23 -5
- package/dist/quiesce.js +10 -7
- package/dist/splice-tx.js +26 -21
- package/dist/splice.js +26 -21
- package/dist/types.js +2 -1
- package/package.json +36 -8
- package/src/__tests__/omnia-splice.test.ts +0 -919
- package/src/errors.ts +0 -63
- package/src/finalize.ts +0 -344
- package/src/index.ts +0 -29
- package/src/quiesce.ts +0 -103
- package/src/splice-tx.ts +0 -208
- package/src/splice.ts +0 -385
- package/src/types.ts +0 -136
package/src/types.ts
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import type { WotsLeaseProvider, SigningIndices } from '@totemsdk/wots-lease';
|
|
2
|
-
import type { OmniaChannel, ChannelSigner, SignedChannelState } from '@totemsdk/omnia';
|
|
3
|
-
|
|
4
|
-
export type { OmniaChannel, ChannelSigner, SignedChannelState };
|
|
5
|
-
export type { WotsLeaseProvider, SigningIndices };
|
|
6
|
-
|
|
7
|
-
export type WotsSignature = Uint8Array;
|
|
8
|
-
|
|
9
|
-
export type SpliceType = 'splice_in' | 'splice_out';
|
|
10
|
-
|
|
11
|
-
export interface SpliceParams {
|
|
12
|
-
type: SpliceType;
|
|
13
|
-
newTotalValue: bigint;
|
|
14
|
-
newBalances: Record<string, bigint>;
|
|
15
|
-
additionalCoinId?: string;
|
|
16
|
-
additionalCoinAddress?: string;
|
|
17
|
-
additionalAmount?: bigint;
|
|
18
|
-
withdrawAmount?: bigint;
|
|
19
|
-
withdrawAddress?: string;
|
|
20
|
-
extraOutputs?: Array<{ address: string; amount: bigint; tokenId?: string }>;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface SpliceTxInput {
|
|
24
|
-
coinId: string;
|
|
25
|
-
address: string;
|
|
26
|
-
amount: bigint;
|
|
27
|
-
tokenId: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface SpliceTxOutput {
|
|
31
|
-
address: string;
|
|
32
|
-
amount: bigint;
|
|
33
|
-
tokenId: string;
|
|
34
|
-
storeState: boolean;
|
|
35
|
-
stateVarSettlement: boolean;
|
|
36
|
-
stateVarSequence: number;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface SpliceTxDraft {
|
|
40
|
-
inputs: SpliceTxInput[];
|
|
41
|
-
outputs: SpliceTxOutput[];
|
|
42
|
-
channelId: string;
|
|
43
|
-
params: SpliceParams;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Splice proposal produced by the initiating party.
|
|
48
|
-
*
|
|
49
|
-
* `spliceTxHex` contains the canonical Minima TX bytes (hex) that both parties
|
|
50
|
-
* independently verify before signing. `spliceTxDraft` retains the structured
|
|
51
|
-
* representation needed for digest computation and output inspection by the
|
|
52
|
-
* acceptor; it is NOT sent over the wire in production but is included here for
|
|
53
|
-
* the v0.1.0 in-process protocol. Future relay integration will transmit only
|
|
54
|
-
* `spliceTxHex` + `params`.
|
|
55
|
-
*
|
|
56
|
-
* `proposerReservationId` and `proposerSigningIndices` carry the WOTS lease
|
|
57
|
-
* reservation used when producing `proposerSignature`. They are consumed by
|
|
58
|
-
* `finalizeSplice` to commit or burn the reservation after the splice TX is
|
|
59
|
-
* settled, preserving key-slot accounting and preventing one-time-key reuse.
|
|
60
|
-
*/
|
|
61
|
-
export interface SpliceProposal {
|
|
62
|
-
spliceId: string;
|
|
63
|
-
channelId: string;
|
|
64
|
-
params: SpliceParams;
|
|
65
|
-
spliceTxHex: string;
|
|
66
|
-
spliceTxDraft: SpliceTxDraft;
|
|
67
|
-
proposerPublicKeyDigest: string;
|
|
68
|
-
proposerSignature: WotsSignature;
|
|
69
|
-
proposerReservationId: string;
|
|
70
|
-
proposerSigningIndices: SigningIndices;
|
|
71
|
-
proposedAt: number;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* `acceptorReservationId` and `acceptorSigningIndices` carry the WOTS lease
|
|
76
|
-
* reservation used when producing `acceptorSignature`. Consumed by
|
|
77
|
-
* `finalizeSplice` to commit or burn the acceptor's key-slot reservation.
|
|
78
|
-
*/
|
|
79
|
-
export interface SpliceAcceptance {
|
|
80
|
-
spliceId: string;
|
|
81
|
-
channelId: string;
|
|
82
|
-
acceptorPublicKeyDigest: string;
|
|
83
|
-
acceptorSignature: WotsSignature;
|
|
84
|
-
acceptorReservationId: string;
|
|
85
|
-
acceptorSigningIndices: SigningIndices;
|
|
86
|
-
acceptedAt: number;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* A channel returned by `quiesceChannel`.
|
|
91
|
-
*
|
|
92
|
-
* - `status: 'quiesced'` — no new HTLCs may be added until the splice confirms.
|
|
93
|
-
* - `pendingHTLCs: []` — all resolved HTLCs are cleared from the active list.
|
|
94
|
-
* - `quiesceSignedState` — the local party's partial signed state over the
|
|
95
|
-
* final pre-splice balance split (sequence incremented by one). Exchange this
|
|
96
|
-
* with the counterparty to obtain their co-signature before finalizing the splice.
|
|
97
|
-
*/
|
|
98
|
-
export type QuiescedChannel = Omit<OmniaChannel, 'status'> & {
|
|
99
|
-
status: 'quiesced';
|
|
100
|
-
quiesceSignedState: Partial<SignedChannelState>;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* A channel returned by `finalizeSplice`.
|
|
105
|
-
*
|
|
106
|
-
* Extends OmniaChannel with splice provenance fields. The returned channel is
|
|
107
|
-
* immediately usable for new payments: `status: 'active'`, `currentSequence: 0`,
|
|
108
|
-
* fresh WOTS budget. `splicedFrom` identifies the old channel and
|
|
109
|
-
* `spliceFundingCoinId` is the new on-chain UTXO.
|
|
110
|
-
*
|
|
111
|
-
* **Mutation side effect**: `finalizeSplice` mutates the `channel` argument
|
|
112
|
-
* (the `QuiescedChannel` passed in) by setting `status: 'spliced'` after the
|
|
113
|
-
* splice TX is confirmed. This invalidates the old channel in-place; the
|
|
114
|
-
* returned `SplicedChannel` (status: 'active') is the only valid live channel.
|
|
115
|
-
*/
|
|
116
|
-
export type SplicedChannel = OmniaChannel & {
|
|
117
|
-
splicedFrom: string;
|
|
118
|
-
spliceType: SpliceType;
|
|
119
|
-
spliceFundingTxId: string;
|
|
120
|
-
spliceFundingCoinId: string;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export interface SpliceLeaseProvider {
|
|
124
|
-
/** Local party's WOTS signer. */
|
|
125
|
-
signer: ChannelSigner;
|
|
126
|
-
/** WOTS lease provider for key slot reservation/commit (required for quiesceChannel). */
|
|
127
|
-
wotsLease: WotsLeaseProvider;
|
|
128
|
-
/** Optional function to broadcast the mined splice TxPoW to the chain. */
|
|
129
|
-
broadcast?: (txHex: string) => Promise<{ txpowid?: string; success?: boolean }>;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export interface SpliceSigningIndices {
|
|
133
|
-
l1: number;
|
|
134
|
-
l2: number;
|
|
135
|
-
addressIndex: number;
|
|
136
|
-
}
|