@t402/streaming-payments 1.0.0-beta.1

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.
@@ -0,0 +1,1560 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Chain identifier (CAIP-2)
5
+ */
6
+ type ChainId = string;
7
+ /**
8
+ * Asset identifier (contract address or native)
9
+ */
10
+ type AssetId = string;
11
+ /**
12
+ * Channel state
13
+ */
14
+ declare const ChannelState: z.ZodEnum<["created", "funding", "open", "paused", "closing", "disputing", "closed", "expired"]>;
15
+ type ChannelState = z.infer<typeof ChannelState>;
16
+ /**
17
+ * Channel configuration
18
+ */
19
+ declare const ChannelConfig: z.ZodObject<{
20
+ minDeposit: z.ZodDefault<z.ZodString>;
21
+ maxDeposit: z.ZodOptional<z.ZodString>;
22
+ challengePeriod: z.ZodDefault<z.ZodNumber>;
23
+ expirationTime: z.ZodOptional<z.ZodNumber>;
24
+ checkpointInterval: z.ZodDefault<z.ZodNumber>;
25
+ minCheckpointAmount: z.ZodDefault<z.ZodString>;
26
+ channelFee: z.ZodDefault<z.ZodString>;
27
+ settlementFee: z.ZodDefault<z.ZodString>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ minDeposit: string;
30
+ challengePeriod: number;
31
+ checkpointInterval: number;
32
+ minCheckpointAmount: string;
33
+ channelFee: string;
34
+ settlementFee: string;
35
+ maxDeposit?: string | undefined;
36
+ expirationTime?: number | undefined;
37
+ }, {
38
+ minDeposit?: string | undefined;
39
+ maxDeposit?: string | undefined;
40
+ challengePeriod?: number | undefined;
41
+ expirationTime?: number | undefined;
42
+ checkpointInterval?: number | undefined;
43
+ minCheckpointAmount?: string | undefined;
44
+ channelFee?: string | undefined;
45
+ settlementFee?: string | undefined;
46
+ }>;
47
+ type ChannelConfig = z.infer<typeof ChannelConfig>;
48
+ /**
49
+ * Channel participant
50
+ */
51
+ declare const ChannelParticipant: z.ZodObject<{
52
+ address: z.ZodString;
53
+ role: z.ZodEnum<["payer", "payee"]>;
54
+ publicKey: z.ZodOptional<z.ZodString>;
55
+ }, "strip", z.ZodTypeAny, {
56
+ address: string;
57
+ role: "payer" | "payee";
58
+ publicKey?: string | undefined;
59
+ }, {
60
+ address: string;
61
+ role: "payer" | "payee";
62
+ publicKey?: string | undefined;
63
+ }>;
64
+ type ChannelParticipant = z.infer<typeof ChannelParticipant>;
65
+ /**
66
+ * Channel balance
67
+ */
68
+ declare const ChannelBalance: z.ZodObject<{
69
+ payer: z.ZodString;
70
+ payee: z.ZodString;
71
+ total: z.ZodString;
72
+ locked: z.ZodDefault<z.ZodString>;
73
+ }, "strip", z.ZodTypeAny, {
74
+ payer: string;
75
+ payee: string;
76
+ total: string;
77
+ locked: string;
78
+ }, {
79
+ payer: string;
80
+ payee: string;
81
+ total: string;
82
+ locked?: string | undefined;
83
+ }>;
84
+ type ChannelBalance = z.infer<typeof ChannelBalance>;
85
+ /**
86
+ * Payment channel checkpoint
87
+ */
88
+ declare const ChannelCheckpoint: z.ZodObject<{
89
+ channelId: z.ZodString;
90
+ sequence: z.ZodNumber;
91
+ timestamp: z.ZodNumber;
92
+ balance: z.ZodObject<{
93
+ payer: z.ZodString;
94
+ payee: z.ZodString;
95
+ total: z.ZodString;
96
+ locked: z.ZodDefault<z.ZodString>;
97
+ }, "strip", z.ZodTypeAny, {
98
+ payer: string;
99
+ payee: string;
100
+ total: string;
101
+ locked: string;
102
+ }, {
103
+ payer: string;
104
+ payee: string;
105
+ total: string;
106
+ locked?: string | undefined;
107
+ }>;
108
+ amountStreamed: z.ZodString;
109
+ payerSignature: z.ZodString;
110
+ payeeSignature: z.ZodOptional<z.ZodString>;
111
+ stateRoot: z.ZodOptional<z.ZodString>;
112
+ }, "strip", z.ZodTypeAny, {
113
+ channelId: string;
114
+ sequence: number;
115
+ timestamp: number;
116
+ balance: {
117
+ payer: string;
118
+ payee: string;
119
+ total: string;
120
+ locked: string;
121
+ };
122
+ amountStreamed: string;
123
+ payerSignature: string;
124
+ payeeSignature?: string | undefined;
125
+ stateRoot?: string | undefined;
126
+ }, {
127
+ channelId: string;
128
+ sequence: number;
129
+ timestamp: number;
130
+ balance: {
131
+ payer: string;
132
+ payee: string;
133
+ total: string;
134
+ locked?: string | undefined;
135
+ };
136
+ amountStreamed: string;
137
+ payerSignature: string;
138
+ payeeSignature?: string | undefined;
139
+ stateRoot?: string | undefined;
140
+ }>;
141
+ type ChannelCheckpoint = z.infer<typeof ChannelCheckpoint>;
142
+ /**
143
+ * Streaming payment channel
144
+ */
145
+ declare const StreamingChannel: z.ZodObject<{
146
+ id: z.ZodString;
147
+ state: z.ZodEnum<["created", "funding", "open", "paused", "closing", "disputing", "closed", "expired"]>;
148
+ chain: z.ZodString;
149
+ asset: z.ZodString;
150
+ payer: z.ZodObject<{
151
+ address: z.ZodString;
152
+ role: z.ZodEnum<["payer", "payee"]>;
153
+ publicKey: z.ZodOptional<z.ZodString>;
154
+ }, "strip", z.ZodTypeAny, {
155
+ address: string;
156
+ role: "payer" | "payee";
157
+ publicKey?: string | undefined;
158
+ }, {
159
+ address: string;
160
+ role: "payer" | "payee";
161
+ publicKey?: string | undefined;
162
+ }>;
163
+ payee: z.ZodObject<{
164
+ address: z.ZodString;
165
+ role: z.ZodEnum<["payer", "payee"]>;
166
+ publicKey: z.ZodOptional<z.ZodString>;
167
+ }, "strip", z.ZodTypeAny, {
168
+ address: string;
169
+ role: "payer" | "payee";
170
+ publicKey?: string | undefined;
171
+ }, {
172
+ address: string;
173
+ role: "payer" | "payee";
174
+ publicKey?: string | undefined;
175
+ }>;
176
+ balance: z.ZodObject<{
177
+ payer: z.ZodString;
178
+ payee: z.ZodString;
179
+ total: z.ZodString;
180
+ locked: z.ZodDefault<z.ZodString>;
181
+ }, "strip", z.ZodTypeAny, {
182
+ payer: string;
183
+ payee: string;
184
+ total: string;
185
+ locked: string;
186
+ }, {
187
+ payer: string;
188
+ payee: string;
189
+ total: string;
190
+ locked?: string | undefined;
191
+ }>;
192
+ ratePerSecond: z.ZodString;
193
+ startTime: z.ZodOptional<z.ZodNumber>;
194
+ pausedAt: z.ZodOptional<z.ZodNumber>;
195
+ config: z.ZodObject<{
196
+ minDeposit: z.ZodDefault<z.ZodString>;
197
+ maxDeposit: z.ZodOptional<z.ZodString>;
198
+ challengePeriod: z.ZodDefault<z.ZodNumber>;
199
+ expirationTime: z.ZodOptional<z.ZodNumber>;
200
+ checkpointInterval: z.ZodDefault<z.ZodNumber>;
201
+ minCheckpointAmount: z.ZodDefault<z.ZodString>;
202
+ channelFee: z.ZodDefault<z.ZodString>;
203
+ settlementFee: z.ZodDefault<z.ZodString>;
204
+ }, "strip", z.ZodTypeAny, {
205
+ minDeposit: string;
206
+ challengePeriod: number;
207
+ checkpointInterval: number;
208
+ minCheckpointAmount: string;
209
+ channelFee: string;
210
+ settlementFee: string;
211
+ maxDeposit?: string | undefined;
212
+ expirationTime?: number | undefined;
213
+ }, {
214
+ minDeposit?: string | undefined;
215
+ maxDeposit?: string | undefined;
216
+ challengePeriod?: number | undefined;
217
+ expirationTime?: number | undefined;
218
+ checkpointInterval?: number | undefined;
219
+ minCheckpointAmount?: string | undefined;
220
+ channelFee?: string | undefined;
221
+ settlementFee?: string | undefined;
222
+ }>;
223
+ contractAddress: z.ZodOptional<z.ZodString>;
224
+ fundingTxHash: z.ZodOptional<z.ZodString>;
225
+ closingTxHash: z.ZodOptional<z.ZodString>;
226
+ checkpoints: z.ZodArray<z.ZodObject<{
227
+ channelId: z.ZodString;
228
+ sequence: z.ZodNumber;
229
+ timestamp: z.ZodNumber;
230
+ balance: z.ZodObject<{
231
+ payer: z.ZodString;
232
+ payee: z.ZodString;
233
+ total: z.ZodString;
234
+ locked: z.ZodDefault<z.ZodString>;
235
+ }, "strip", z.ZodTypeAny, {
236
+ payer: string;
237
+ payee: string;
238
+ total: string;
239
+ locked: string;
240
+ }, {
241
+ payer: string;
242
+ payee: string;
243
+ total: string;
244
+ locked?: string | undefined;
245
+ }>;
246
+ amountStreamed: z.ZodString;
247
+ payerSignature: z.ZodString;
248
+ payeeSignature: z.ZodOptional<z.ZodString>;
249
+ stateRoot: z.ZodOptional<z.ZodString>;
250
+ }, "strip", z.ZodTypeAny, {
251
+ channelId: string;
252
+ sequence: number;
253
+ timestamp: number;
254
+ balance: {
255
+ payer: string;
256
+ payee: string;
257
+ total: string;
258
+ locked: string;
259
+ };
260
+ amountStreamed: string;
261
+ payerSignature: string;
262
+ payeeSignature?: string | undefined;
263
+ stateRoot?: string | undefined;
264
+ }, {
265
+ channelId: string;
266
+ sequence: number;
267
+ timestamp: number;
268
+ balance: {
269
+ payer: string;
270
+ payee: string;
271
+ total: string;
272
+ locked?: string | undefined;
273
+ };
274
+ amountStreamed: string;
275
+ payerSignature: string;
276
+ payeeSignature?: string | undefined;
277
+ stateRoot?: string | undefined;
278
+ }>, "many">;
279
+ latestCheckpoint: z.ZodOptional<z.ZodObject<{
280
+ channelId: z.ZodString;
281
+ sequence: z.ZodNumber;
282
+ timestamp: z.ZodNumber;
283
+ balance: z.ZodObject<{
284
+ payer: z.ZodString;
285
+ payee: z.ZodString;
286
+ total: z.ZodString;
287
+ locked: z.ZodDefault<z.ZodString>;
288
+ }, "strip", z.ZodTypeAny, {
289
+ payer: string;
290
+ payee: string;
291
+ total: string;
292
+ locked: string;
293
+ }, {
294
+ payer: string;
295
+ payee: string;
296
+ total: string;
297
+ locked?: string | undefined;
298
+ }>;
299
+ amountStreamed: z.ZodString;
300
+ payerSignature: z.ZodString;
301
+ payeeSignature: z.ZodOptional<z.ZodString>;
302
+ stateRoot: z.ZodOptional<z.ZodString>;
303
+ }, "strip", z.ZodTypeAny, {
304
+ channelId: string;
305
+ sequence: number;
306
+ timestamp: number;
307
+ balance: {
308
+ payer: string;
309
+ payee: string;
310
+ total: string;
311
+ locked: string;
312
+ };
313
+ amountStreamed: string;
314
+ payerSignature: string;
315
+ payeeSignature?: string | undefined;
316
+ stateRoot?: string | undefined;
317
+ }, {
318
+ channelId: string;
319
+ sequence: number;
320
+ timestamp: number;
321
+ balance: {
322
+ payer: string;
323
+ payee: string;
324
+ total: string;
325
+ locked?: string | undefined;
326
+ };
327
+ amountStreamed: string;
328
+ payerSignature: string;
329
+ payeeSignature?: string | undefined;
330
+ stateRoot?: string | undefined;
331
+ }>>;
332
+ createdAt: z.ZodNumber;
333
+ updatedAt: z.ZodNumber;
334
+ closedAt: z.ZodOptional<z.ZodNumber>;
335
+ }, "strip", z.ZodTypeAny, {
336
+ payer: {
337
+ address: string;
338
+ role: "payer" | "payee";
339
+ publicKey?: string | undefined;
340
+ };
341
+ payee: {
342
+ address: string;
343
+ role: "payer" | "payee";
344
+ publicKey?: string | undefined;
345
+ };
346
+ balance: {
347
+ payer: string;
348
+ payee: string;
349
+ total: string;
350
+ locked: string;
351
+ };
352
+ id: string;
353
+ state: "created" | "funding" | "open" | "paused" | "closing" | "disputing" | "closed" | "expired";
354
+ chain: string;
355
+ asset: string;
356
+ ratePerSecond: string;
357
+ config: {
358
+ minDeposit: string;
359
+ challengePeriod: number;
360
+ checkpointInterval: number;
361
+ minCheckpointAmount: string;
362
+ channelFee: string;
363
+ settlementFee: string;
364
+ maxDeposit?: string | undefined;
365
+ expirationTime?: number | undefined;
366
+ };
367
+ checkpoints: {
368
+ channelId: string;
369
+ sequence: number;
370
+ timestamp: number;
371
+ balance: {
372
+ payer: string;
373
+ payee: string;
374
+ total: string;
375
+ locked: string;
376
+ };
377
+ amountStreamed: string;
378
+ payerSignature: string;
379
+ payeeSignature?: string | undefined;
380
+ stateRoot?: string | undefined;
381
+ }[];
382
+ createdAt: number;
383
+ updatedAt: number;
384
+ startTime?: number | undefined;
385
+ pausedAt?: number | undefined;
386
+ contractAddress?: string | undefined;
387
+ fundingTxHash?: string | undefined;
388
+ closingTxHash?: string | undefined;
389
+ latestCheckpoint?: {
390
+ channelId: string;
391
+ sequence: number;
392
+ timestamp: number;
393
+ balance: {
394
+ payer: string;
395
+ payee: string;
396
+ total: string;
397
+ locked: string;
398
+ };
399
+ amountStreamed: string;
400
+ payerSignature: string;
401
+ payeeSignature?: string | undefined;
402
+ stateRoot?: string | undefined;
403
+ } | undefined;
404
+ closedAt?: number | undefined;
405
+ }, {
406
+ payer: {
407
+ address: string;
408
+ role: "payer" | "payee";
409
+ publicKey?: string | undefined;
410
+ };
411
+ payee: {
412
+ address: string;
413
+ role: "payer" | "payee";
414
+ publicKey?: string | undefined;
415
+ };
416
+ balance: {
417
+ payer: string;
418
+ payee: string;
419
+ total: string;
420
+ locked?: string | undefined;
421
+ };
422
+ id: string;
423
+ state: "created" | "funding" | "open" | "paused" | "closing" | "disputing" | "closed" | "expired";
424
+ chain: string;
425
+ asset: string;
426
+ ratePerSecond: string;
427
+ config: {
428
+ minDeposit?: string | undefined;
429
+ maxDeposit?: string | undefined;
430
+ challengePeriod?: number | undefined;
431
+ expirationTime?: number | undefined;
432
+ checkpointInterval?: number | undefined;
433
+ minCheckpointAmount?: string | undefined;
434
+ channelFee?: string | undefined;
435
+ settlementFee?: string | undefined;
436
+ };
437
+ checkpoints: {
438
+ channelId: string;
439
+ sequence: number;
440
+ timestamp: number;
441
+ balance: {
442
+ payer: string;
443
+ payee: string;
444
+ total: string;
445
+ locked?: string | undefined;
446
+ };
447
+ amountStreamed: string;
448
+ payerSignature: string;
449
+ payeeSignature?: string | undefined;
450
+ stateRoot?: string | undefined;
451
+ }[];
452
+ createdAt: number;
453
+ updatedAt: number;
454
+ startTime?: number | undefined;
455
+ pausedAt?: number | undefined;
456
+ contractAddress?: string | undefined;
457
+ fundingTxHash?: string | undefined;
458
+ closingTxHash?: string | undefined;
459
+ latestCheckpoint?: {
460
+ channelId: string;
461
+ sequence: number;
462
+ timestamp: number;
463
+ balance: {
464
+ payer: string;
465
+ payee: string;
466
+ total: string;
467
+ locked?: string | undefined;
468
+ };
469
+ amountStreamed: string;
470
+ payerSignature: string;
471
+ payeeSignature?: string | undefined;
472
+ stateRoot?: string | undefined;
473
+ } | undefined;
474
+ closedAt?: number | undefined;
475
+ }>;
476
+ type StreamingChannel = z.infer<typeof StreamingChannel>;
477
+ /**
478
+ * Channel creation request
479
+ */
480
+ declare const ChannelCreateRequest: z.ZodObject<{
481
+ chain: z.ZodString;
482
+ asset: z.ZodString;
483
+ payerAddress: z.ZodString;
484
+ payeeAddress: z.ZodString;
485
+ depositAmount: z.ZodString;
486
+ ratePerSecond: z.ZodString;
487
+ config: z.ZodOptional<z.ZodObject<{
488
+ minDeposit: z.ZodDefault<z.ZodString>;
489
+ maxDeposit: z.ZodOptional<z.ZodString>;
490
+ challengePeriod: z.ZodDefault<z.ZodNumber>;
491
+ expirationTime: z.ZodOptional<z.ZodNumber>;
492
+ checkpointInterval: z.ZodDefault<z.ZodNumber>;
493
+ minCheckpointAmount: z.ZodDefault<z.ZodString>;
494
+ channelFee: z.ZodDefault<z.ZodString>;
495
+ settlementFee: z.ZodDefault<z.ZodString>;
496
+ }, "strip", z.ZodTypeAny, {
497
+ minDeposit: string;
498
+ challengePeriod: number;
499
+ checkpointInterval: number;
500
+ minCheckpointAmount: string;
501
+ channelFee: string;
502
+ settlementFee: string;
503
+ maxDeposit?: string | undefined;
504
+ expirationTime?: number | undefined;
505
+ }, {
506
+ minDeposit?: string | undefined;
507
+ maxDeposit?: string | undefined;
508
+ challengePeriod?: number | undefined;
509
+ expirationTime?: number | undefined;
510
+ checkpointInterval?: number | undefined;
511
+ minCheckpointAmount?: string | undefined;
512
+ channelFee?: string | undefined;
513
+ settlementFee?: string | undefined;
514
+ }>>;
515
+ }, "strip", z.ZodTypeAny, {
516
+ chain: string;
517
+ asset: string;
518
+ ratePerSecond: string;
519
+ payerAddress: string;
520
+ payeeAddress: string;
521
+ depositAmount: string;
522
+ config?: {
523
+ minDeposit: string;
524
+ challengePeriod: number;
525
+ checkpointInterval: number;
526
+ minCheckpointAmount: string;
527
+ channelFee: string;
528
+ settlementFee: string;
529
+ maxDeposit?: string | undefined;
530
+ expirationTime?: number | undefined;
531
+ } | undefined;
532
+ }, {
533
+ chain: string;
534
+ asset: string;
535
+ ratePerSecond: string;
536
+ payerAddress: string;
537
+ payeeAddress: string;
538
+ depositAmount: string;
539
+ config?: {
540
+ minDeposit?: string | undefined;
541
+ maxDeposit?: string | undefined;
542
+ challengePeriod?: number | undefined;
543
+ expirationTime?: number | undefined;
544
+ checkpointInterval?: number | undefined;
545
+ minCheckpointAmount?: string | undefined;
546
+ channelFee?: string | undefined;
547
+ settlementFee?: string | undefined;
548
+ } | undefined;
549
+ }>;
550
+ type ChannelCreateRequest = z.infer<typeof ChannelCreateRequest>;
551
+ /**
552
+ * Channel funding transaction
553
+ */
554
+ declare const FundingTransaction: z.ZodObject<{
555
+ channelId: z.ZodString;
556
+ txHash: z.ZodString;
557
+ amount: z.ZodString;
558
+ sender: z.ZodString;
559
+ blockNumber: z.ZodOptional<z.ZodNumber>;
560
+ timestamp: z.ZodNumber;
561
+ confirmed: z.ZodBoolean;
562
+ }, "strip", z.ZodTypeAny, {
563
+ channelId: string;
564
+ timestamp: number;
565
+ txHash: string;
566
+ amount: string;
567
+ sender: string;
568
+ confirmed: boolean;
569
+ blockNumber?: number | undefined;
570
+ }, {
571
+ channelId: string;
572
+ timestamp: number;
573
+ txHash: string;
574
+ amount: string;
575
+ sender: string;
576
+ confirmed: boolean;
577
+ blockNumber?: number | undefined;
578
+ }>;
579
+ type FundingTransaction = z.infer<typeof FundingTransaction>;
580
+ /**
581
+ * Channel close request
582
+ */
583
+ declare const ChannelCloseRequest: z.ZodObject<{
584
+ channelId: z.ZodString;
585
+ initiator: z.ZodString;
586
+ reason: z.ZodEnum<["mutual", "unilateral", "timeout", "dispute"]>;
587
+ finalCheckpoint: z.ZodOptional<z.ZodObject<{
588
+ channelId: z.ZodString;
589
+ sequence: z.ZodNumber;
590
+ timestamp: z.ZodNumber;
591
+ balance: z.ZodObject<{
592
+ payer: z.ZodString;
593
+ payee: z.ZodString;
594
+ total: z.ZodString;
595
+ locked: z.ZodDefault<z.ZodString>;
596
+ }, "strip", z.ZodTypeAny, {
597
+ payer: string;
598
+ payee: string;
599
+ total: string;
600
+ locked: string;
601
+ }, {
602
+ payer: string;
603
+ payee: string;
604
+ total: string;
605
+ locked?: string | undefined;
606
+ }>;
607
+ amountStreamed: z.ZodString;
608
+ payerSignature: z.ZodString;
609
+ payeeSignature: z.ZodOptional<z.ZodString>;
610
+ stateRoot: z.ZodOptional<z.ZodString>;
611
+ }, "strip", z.ZodTypeAny, {
612
+ channelId: string;
613
+ sequence: number;
614
+ timestamp: number;
615
+ balance: {
616
+ payer: string;
617
+ payee: string;
618
+ total: string;
619
+ locked: string;
620
+ };
621
+ amountStreamed: string;
622
+ payerSignature: string;
623
+ payeeSignature?: string | undefined;
624
+ stateRoot?: string | undefined;
625
+ }, {
626
+ channelId: string;
627
+ sequence: number;
628
+ timestamp: number;
629
+ balance: {
630
+ payer: string;
631
+ payee: string;
632
+ total: string;
633
+ locked?: string | undefined;
634
+ };
635
+ amountStreamed: string;
636
+ payerSignature: string;
637
+ payeeSignature?: string | undefined;
638
+ stateRoot?: string | undefined;
639
+ }>>;
640
+ signature: z.ZodString;
641
+ }, "strip", z.ZodTypeAny, {
642
+ channelId: string;
643
+ initiator: string;
644
+ reason: "mutual" | "unilateral" | "timeout" | "dispute";
645
+ signature: string;
646
+ finalCheckpoint?: {
647
+ channelId: string;
648
+ sequence: number;
649
+ timestamp: number;
650
+ balance: {
651
+ payer: string;
652
+ payee: string;
653
+ total: string;
654
+ locked: string;
655
+ };
656
+ amountStreamed: string;
657
+ payerSignature: string;
658
+ payeeSignature?: string | undefined;
659
+ stateRoot?: string | undefined;
660
+ } | undefined;
661
+ }, {
662
+ channelId: string;
663
+ initiator: string;
664
+ reason: "mutual" | "unilateral" | "timeout" | "dispute";
665
+ signature: string;
666
+ finalCheckpoint?: {
667
+ channelId: string;
668
+ sequence: number;
669
+ timestamp: number;
670
+ balance: {
671
+ payer: string;
672
+ payee: string;
673
+ total: string;
674
+ locked?: string | undefined;
675
+ };
676
+ amountStreamed: string;
677
+ payerSignature: string;
678
+ payeeSignature?: string | undefined;
679
+ stateRoot?: string | undefined;
680
+ } | undefined;
681
+ }>;
682
+ type ChannelCloseRequest = z.infer<typeof ChannelCloseRequest>;
683
+ /**
684
+ * Channel dispute
685
+ */
686
+ declare const ChannelDispute: z.ZodObject<{
687
+ channelId: z.ZodString;
688
+ disputeId: z.ZodString;
689
+ initiator: z.ZodString;
690
+ reason: z.ZodString;
691
+ claimedBalance: z.ZodObject<{
692
+ payer: z.ZodString;
693
+ payee: z.ZodString;
694
+ total: z.ZodString;
695
+ locked: z.ZodDefault<z.ZodString>;
696
+ }, "strip", z.ZodTypeAny, {
697
+ payer: string;
698
+ payee: string;
699
+ total: string;
700
+ locked: string;
701
+ }, {
702
+ payer: string;
703
+ payee: string;
704
+ total: string;
705
+ locked?: string | undefined;
706
+ }>;
707
+ evidence: z.ZodArray<z.ZodObject<{
708
+ type: z.ZodEnum<["checkpoint", "signature", "transaction"]>;
709
+ data: z.ZodString;
710
+ timestamp: z.ZodNumber;
711
+ }, "strip", z.ZodTypeAny, {
712
+ type: "signature" | "checkpoint" | "transaction";
713
+ timestamp: number;
714
+ data: string;
715
+ }, {
716
+ type: "signature" | "checkpoint" | "transaction";
717
+ timestamp: number;
718
+ data: string;
719
+ }>, "many">;
720
+ status: z.ZodEnum<["pending", "resolved", "rejected"]>;
721
+ resolution: z.ZodOptional<z.ZodObject<{
722
+ winner: z.ZodOptional<z.ZodString>;
723
+ finalBalance: z.ZodOptional<z.ZodObject<{
724
+ payer: z.ZodString;
725
+ payee: z.ZodString;
726
+ total: z.ZodString;
727
+ locked: z.ZodDefault<z.ZodString>;
728
+ }, "strip", z.ZodTypeAny, {
729
+ payer: string;
730
+ payee: string;
731
+ total: string;
732
+ locked: string;
733
+ }, {
734
+ payer: string;
735
+ payee: string;
736
+ total: string;
737
+ locked?: string | undefined;
738
+ }>>;
739
+ timestamp: z.ZodOptional<z.ZodNumber>;
740
+ }, "strip", z.ZodTypeAny, {
741
+ timestamp?: number | undefined;
742
+ winner?: string | undefined;
743
+ finalBalance?: {
744
+ payer: string;
745
+ payee: string;
746
+ total: string;
747
+ locked: string;
748
+ } | undefined;
749
+ }, {
750
+ timestamp?: number | undefined;
751
+ winner?: string | undefined;
752
+ finalBalance?: {
753
+ payer: string;
754
+ payee: string;
755
+ total: string;
756
+ locked?: string | undefined;
757
+ } | undefined;
758
+ }>>;
759
+ createdAt: z.ZodNumber;
760
+ expiresAt: z.ZodNumber;
761
+ }, "strip", z.ZodTypeAny, {
762
+ status: "pending" | "resolved" | "rejected";
763
+ channelId: string;
764
+ createdAt: number;
765
+ initiator: string;
766
+ reason: string;
767
+ disputeId: string;
768
+ claimedBalance: {
769
+ payer: string;
770
+ payee: string;
771
+ total: string;
772
+ locked: string;
773
+ };
774
+ evidence: {
775
+ type: "signature" | "checkpoint" | "transaction";
776
+ timestamp: number;
777
+ data: string;
778
+ }[];
779
+ expiresAt: number;
780
+ resolution?: {
781
+ timestamp?: number | undefined;
782
+ winner?: string | undefined;
783
+ finalBalance?: {
784
+ payer: string;
785
+ payee: string;
786
+ total: string;
787
+ locked: string;
788
+ } | undefined;
789
+ } | undefined;
790
+ }, {
791
+ status: "pending" | "resolved" | "rejected";
792
+ channelId: string;
793
+ createdAt: number;
794
+ initiator: string;
795
+ reason: string;
796
+ disputeId: string;
797
+ claimedBalance: {
798
+ payer: string;
799
+ payee: string;
800
+ total: string;
801
+ locked?: string | undefined;
802
+ };
803
+ evidence: {
804
+ type: "signature" | "checkpoint" | "transaction";
805
+ timestamp: number;
806
+ data: string;
807
+ }[];
808
+ expiresAt: number;
809
+ resolution?: {
810
+ timestamp?: number | undefined;
811
+ winner?: string | undefined;
812
+ finalBalance?: {
813
+ payer: string;
814
+ payee: string;
815
+ total: string;
816
+ locked?: string | undefined;
817
+ } | undefined;
818
+ } | undefined;
819
+ }>;
820
+ type ChannelDispute = z.infer<typeof ChannelDispute>;
821
+ /**
822
+ * Channel state transition
823
+ */
824
+ declare const StateTransition: z.ZodObject<{
825
+ from: z.ZodEnum<["created", "funding", "open", "paused", "closing", "disputing", "closed", "expired"]>;
826
+ to: z.ZodEnum<["created", "funding", "open", "paused", "closing", "disputing", "closed", "expired"]>;
827
+ trigger: z.ZodString;
828
+ timestamp: z.ZodNumber;
829
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
830
+ }, "strip", z.ZodTypeAny, {
831
+ timestamp: number;
832
+ from: "created" | "funding" | "open" | "paused" | "closing" | "disputing" | "closed" | "expired";
833
+ to: "created" | "funding" | "open" | "paused" | "closing" | "disputing" | "closed" | "expired";
834
+ trigger: string;
835
+ metadata?: Record<string, unknown> | undefined;
836
+ }, {
837
+ timestamp: number;
838
+ from: "created" | "funding" | "open" | "paused" | "closing" | "disputing" | "closed" | "expired";
839
+ to: "created" | "funding" | "open" | "paused" | "closing" | "disputing" | "closed" | "expired";
840
+ trigger: string;
841
+ metadata?: Record<string, unknown> | undefined;
842
+ }>;
843
+ type StateTransition = z.infer<typeof StateTransition>;
844
+ /**
845
+ * Recovery data for channel state restoration
846
+ */
847
+ declare const RecoveryData: z.ZodObject<{
848
+ channelId: z.ZodString;
849
+ checkpoints: z.ZodArray<z.ZodObject<{
850
+ channelId: z.ZodString;
851
+ sequence: z.ZodNumber;
852
+ timestamp: z.ZodNumber;
853
+ balance: z.ZodObject<{
854
+ payer: z.ZodString;
855
+ payee: z.ZodString;
856
+ total: z.ZodString;
857
+ locked: z.ZodDefault<z.ZodString>;
858
+ }, "strip", z.ZodTypeAny, {
859
+ payer: string;
860
+ payee: string;
861
+ total: string;
862
+ locked: string;
863
+ }, {
864
+ payer: string;
865
+ payee: string;
866
+ total: string;
867
+ locked?: string | undefined;
868
+ }>;
869
+ amountStreamed: z.ZodString;
870
+ payerSignature: z.ZodString;
871
+ payeeSignature: z.ZodOptional<z.ZodString>;
872
+ stateRoot: z.ZodOptional<z.ZodString>;
873
+ }, "strip", z.ZodTypeAny, {
874
+ channelId: string;
875
+ sequence: number;
876
+ timestamp: number;
877
+ balance: {
878
+ payer: string;
879
+ payee: string;
880
+ total: string;
881
+ locked: string;
882
+ };
883
+ amountStreamed: string;
884
+ payerSignature: string;
885
+ payeeSignature?: string | undefined;
886
+ stateRoot?: string | undefined;
887
+ }, {
888
+ channelId: string;
889
+ sequence: number;
890
+ timestamp: number;
891
+ balance: {
892
+ payer: string;
893
+ payee: string;
894
+ total: string;
895
+ locked?: string | undefined;
896
+ };
897
+ amountStreamed: string;
898
+ payerSignature: string;
899
+ payeeSignature?: string | undefined;
900
+ stateRoot?: string | undefined;
901
+ }>, "many">;
902
+ transactions: z.ZodArray<z.ZodObject<{
903
+ channelId: z.ZodString;
904
+ txHash: z.ZodString;
905
+ amount: z.ZodString;
906
+ sender: z.ZodString;
907
+ blockNumber: z.ZodOptional<z.ZodNumber>;
908
+ timestamp: z.ZodNumber;
909
+ confirmed: z.ZodBoolean;
910
+ }, "strip", z.ZodTypeAny, {
911
+ channelId: string;
912
+ timestamp: number;
913
+ txHash: string;
914
+ amount: string;
915
+ sender: string;
916
+ confirmed: boolean;
917
+ blockNumber?: number | undefined;
918
+ }, {
919
+ channelId: string;
920
+ timestamp: number;
921
+ txHash: string;
922
+ amount: string;
923
+ sender: string;
924
+ confirmed: boolean;
925
+ blockNumber?: number | undefined;
926
+ }>, "many">;
927
+ disputes: z.ZodArray<z.ZodObject<{
928
+ channelId: z.ZodString;
929
+ disputeId: z.ZodString;
930
+ initiator: z.ZodString;
931
+ reason: z.ZodString;
932
+ claimedBalance: z.ZodObject<{
933
+ payer: z.ZodString;
934
+ payee: z.ZodString;
935
+ total: z.ZodString;
936
+ locked: z.ZodDefault<z.ZodString>;
937
+ }, "strip", z.ZodTypeAny, {
938
+ payer: string;
939
+ payee: string;
940
+ total: string;
941
+ locked: string;
942
+ }, {
943
+ payer: string;
944
+ payee: string;
945
+ total: string;
946
+ locked?: string | undefined;
947
+ }>;
948
+ evidence: z.ZodArray<z.ZodObject<{
949
+ type: z.ZodEnum<["checkpoint", "signature", "transaction"]>;
950
+ data: z.ZodString;
951
+ timestamp: z.ZodNumber;
952
+ }, "strip", z.ZodTypeAny, {
953
+ type: "signature" | "checkpoint" | "transaction";
954
+ timestamp: number;
955
+ data: string;
956
+ }, {
957
+ type: "signature" | "checkpoint" | "transaction";
958
+ timestamp: number;
959
+ data: string;
960
+ }>, "many">;
961
+ status: z.ZodEnum<["pending", "resolved", "rejected"]>;
962
+ resolution: z.ZodOptional<z.ZodObject<{
963
+ winner: z.ZodOptional<z.ZodString>;
964
+ finalBalance: z.ZodOptional<z.ZodObject<{
965
+ payer: z.ZodString;
966
+ payee: z.ZodString;
967
+ total: z.ZodString;
968
+ locked: z.ZodDefault<z.ZodString>;
969
+ }, "strip", z.ZodTypeAny, {
970
+ payer: string;
971
+ payee: string;
972
+ total: string;
973
+ locked: string;
974
+ }, {
975
+ payer: string;
976
+ payee: string;
977
+ total: string;
978
+ locked?: string | undefined;
979
+ }>>;
980
+ timestamp: z.ZodOptional<z.ZodNumber>;
981
+ }, "strip", z.ZodTypeAny, {
982
+ timestamp?: number | undefined;
983
+ winner?: string | undefined;
984
+ finalBalance?: {
985
+ payer: string;
986
+ payee: string;
987
+ total: string;
988
+ locked: string;
989
+ } | undefined;
990
+ }, {
991
+ timestamp?: number | undefined;
992
+ winner?: string | undefined;
993
+ finalBalance?: {
994
+ payer: string;
995
+ payee: string;
996
+ total: string;
997
+ locked?: string | undefined;
998
+ } | undefined;
999
+ }>>;
1000
+ createdAt: z.ZodNumber;
1001
+ expiresAt: z.ZodNumber;
1002
+ }, "strip", z.ZodTypeAny, {
1003
+ status: "pending" | "resolved" | "rejected";
1004
+ channelId: string;
1005
+ createdAt: number;
1006
+ initiator: string;
1007
+ reason: string;
1008
+ disputeId: string;
1009
+ claimedBalance: {
1010
+ payer: string;
1011
+ payee: string;
1012
+ total: string;
1013
+ locked: string;
1014
+ };
1015
+ evidence: {
1016
+ type: "signature" | "checkpoint" | "transaction";
1017
+ timestamp: number;
1018
+ data: string;
1019
+ }[];
1020
+ expiresAt: number;
1021
+ resolution?: {
1022
+ timestamp?: number | undefined;
1023
+ winner?: string | undefined;
1024
+ finalBalance?: {
1025
+ payer: string;
1026
+ payee: string;
1027
+ total: string;
1028
+ locked: string;
1029
+ } | undefined;
1030
+ } | undefined;
1031
+ }, {
1032
+ status: "pending" | "resolved" | "rejected";
1033
+ channelId: string;
1034
+ createdAt: number;
1035
+ initiator: string;
1036
+ reason: string;
1037
+ disputeId: string;
1038
+ claimedBalance: {
1039
+ payer: string;
1040
+ payee: string;
1041
+ total: string;
1042
+ locked?: string | undefined;
1043
+ };
1044
+ evidence: {
1045
+ type: "signature" | "checkpoint" | "transaction";
1046
+ timestamp: number;
1047
+ data: string;
1048
+ }[];
1049
+ expiresAt: number;
1050
+ resolution?: {
1051
+ timestamp?: number | undefined;
1052
+ winner?: string | undefined;
1053
+ finalBalance?: {
1054
+ payer: string;
1055
+ payee: string;
1056
+ total: string;
1057
+ locked?: string | undefined;
1058
+ } | undefined;
1059
+ } | undefined;
1060
+ }>, "many">;
1061
+ stateHistory: z.ZodArray<z.ZodObject<{
1062
+ from: z.ZodEnum<["created", "funding", "open", "paused", "closing", "disputing", "closed", "expired"]>;
1063
+ to: z.ZodEnum<["created", "funding", "open", "paused", "closing", "disputing", "closed", "expired"]>;
1064
+ trigger: z.ZodString;
1065
+ timestamp: z.ZodNumber;
1066
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1067
+ }, "strip", z.ZodTypeAny, {
1068
+ timestamp: number;
1069
+ from: "created" | "funding" | "open" | "paused" | "closing" | "disputing" | "closed" | "expired";
1070
+ to: "created" | "funding" | "open" | "paused" | "closing" | "disputing" | "closed" | "expired";
1071
+ trigger: string;
1072
+ metadata?: Record<string, unknown> | undefined;
1073
+ }, {
1074
+ timestamp: number;
1075
+ from: "created" | "funding" | "open" | "paused" | "closing" | "disputing" | "closed" | "expired";
1076
+ to: "created" | "funding" | "open" | "paused" | "closing" | "disputing" | "closed" | "expired";
1077
+ trigger: string;
1078
+ metadata?: Record<string, unknown> | undefined;
1079
+ }>, "many">;
1080
+ recoveredAt: z.ZodNumber;
1081
+ }, "strip", z.ZodTypeAny, {
1082
+ channelId: string;
1083
+ checkpoints: {
1084
+ channelId: string;
1085
+ sequence: number;
1086
+ timestamp: number;
1087
+ balance: {
1088
+ payer: string;
1089
+ payee: string;
1090
+ total: string;
1091
+ locked: string;
1092
+ };
1093
+ amountStreamed: string;
1094
+ payerSignature: string;
1095
+ payeeSignature?: string | undefined;
1096
+ stateRoot?: string | undefined;
1097
+ }[];
1098
+ transactions: {
1099
+ channelId: string;
1100
+ timestamp: number;
1101
+ txHash: string;
1102
+ amount: string;
1103
+ sender: string;
1104
+ confirmed: boolean;
1105
+ blockNumber?: number | undefined;
1106
+ }[];
1107
+ disputes: {
1108
+ status: "pending" | "resolved" | "rejected";
1109
+ channelId: string;
1110
+ createdAt: number;
1111
+ initiator: string;
1112
+ reason: string;
1113
+ disputeId: string;
1114
+ claimedBalance: {
1115
+ payer: string;
1116
+ payee: string;
1117
+ total: string;
1118
+ locked: string;
1119
+ };
1120
+ evidence: {
1121
+ type: "signature" | "checkpoint" | "transaction";
1122
+ timestamp: number;
1123
+ data: string;
1124
+ }[];
1125
+ expiresAt: number;
1126
+ resolution?: {
1127
+ timestamp?: number | undefined;
1128
+ winner?: string | undefined;
1129
+ finalBalance?: {
1130
+ payer: string;
1131
+ payee: string;
1132
+ total: string;
1133
+ locked: string;
1134
+ } | undefined;
1135
+ } | undefined;
1136
+ }[];
1137
+ stateHistory: {
1138
+ timestamp: number;
1139
+ from: "created" | "funding" | "open" | "paused" | "closing" | "disputing" | "closed" | "expired";
1140
+ to: "created" | "funding" | "open" | "paused" | "closing" | "disputing" | "closed" | "expired";
1141
+ trigger: string;
1142
+ metadata?: Record<string, unknown> | undefined;
1143
+ }[];
1144
+ recoveredAt: number;
1145
+ }, {
1146
+ channelId: string;
1147
+ checkpoints: {
1148
+ channelId: string;
1149
+ sequence: number;
1150
+ timestamp: number;
1151
+ balance: {
1152
+ payer: string;
1153
+ payee: string;
1154
+ total: string;
1155
+ locked?: string | undefined;
1156
+ };
1157
+ amountStreamed: string;
1158
+ payerSignature: string;
1159
+ payeeSignature?: string | undefined;
1160
+ stateRoot?: string | undefined;
1161
+ }[];
1162
+ transactions: {
1163
+ channelId: string;
1164
+ timestamp: number;
1165
+ txHash: string;
1166
+ amount: string;
1167
+ sender: string;
1168
+ confirmed: boolean;
1169
+ blockNumber?: number | undefined;
1170
+ }[];
1171
+ disputes: {
1172
+ status: "pending" | "resolved" | "rejected";
1173
+ channelId: string;
1174
+ createdAt: number;
1175
+ initiator: string;
1176
+ reason: string;
1177
+ disputeId: string;
1178
+ claimedBalance: {
1179
+ payer: string;
1180
+ payee: string;
1181
+ total: string;
1182
+ locked?: string | undefined;
1183
+ };
1184
+ evidence: {
1185
+ type: "signature" | "checkpoint" | "transaction";
1186
+ timestamp: number;
1187
+ data: string;
1188
+ }[];
1189
+ expiresAt: number;
1190
+ resolution?: {
1191
+ timestamp?: number | undefined;
1192
+ winner?: string | undefined;
1193
+ finalBalance?: {
1194
+ payer: string;
1195
+ payee: string;
1196
+ total: string;
1197
+ locked?: string | undefined;
1198
+ } | undefined;
1199
+ } | undefined;
1200
+ }[];
1201
+ stateHistory: {
1202
+ timestamp: number;
1203
+ from: "created" | "funding" | "open" | "paused" | "closing" | "disputing" | "closed" | "expired";
1204
+ to: "created" | "funding" | "open" | "paused" | "closing" | "disputing" | "closed" | "expired";
1205
+ trigger: string;
1206
+ metadata?: Record<string, unknown> | undefined;
1207
+ }[];
1208
+ recoveredAt: number;
1209
+ }>;
1210
+ type RecoveryData = z.infer<typeof RecoveryData>;
1211
+
1212
+ /**
1213
+ * State machine event
1214
+ */
1215
+ type StateEvent = {
1216
+ type: 'FUND';
1217
+ txHash: string;
1218
+ amount: string;
1219
+ } | {
1220
+ type: 'CONFIRM_FUNDING';
1221
+ } | {
1222
+ type: 'START_STREAMING';
1223
+ } | {
1224
+ type: 'PAUSE';
1225
+ } | {
1226
+ type: 'RESUME';
1227
+ } | {
1228
+ type: 'INITIATE_CLOSE';
1229
+ initiator: string;
1230
+ } | {
1231
+ type: 'MUTUAL_CLOSE';
1232
+ signature: string;
1233
+ } | {
1234
+ type: 'DISPUTE';
1235
+ reason: string;
1236
+ } | {
1237
+ type: 'RESOLVE_DISPUTE';
1238
+ winner: string;
1239
+ } | {
1240
+ type: 'FINALIZE';
1241
+ } | {
1242
+ type: 'TIMEOUT';
1243
+ };
1244
+ /**
1245
+ * Channel state machine
1246
+ */
1247
+ declare class ChannelStateMachine {
1248
+ private channel;
1249
+ private transitions;
1250
+ private listeners;
1251
+ constructor(channel: StreamingChannel);
1252
+ /**
1253
+ * Get current channel state
1254
+ */
1255
+ getChannel(): StreamingChannel;
1256
+ /**
1257
+ * Get current state
1258
+ */
1259
+ getState(): ChannelState;
1260
+ /**
1261
+ * Get state history
1262
+ */
1263
+ getTransitions(): StateTransition[];
1264
+ /**
1265
+ * Check if a transition is valid
1266
+ */
1267
+ canTransition(to: ChannelState): boolean;
1268
+ /**
1269
+ * Get allowed transitions from current state
1270
+ */
1271
+ getAllowedTransitions(): ChannelState[];
1272
+ /**
1273
+ * Process a state event
1274
+ */
1275
+ process(event: StateEvent): {
1276
+ success: boolean;
1277
+ error?: string;
1278
+ };
1279
+ /**
1280
+ * Update channel balance
1281
+ */
1282
+ updateBalance(payerBalance: string, payeeBalance: string): void;
1283
+ /**
1284
+ * Add checkpoint
1285
+ */
1286
+ addCheckpoint(checkpoint: ChannelCheckpoint): void;
1287
+ /**
1288
+ * Get current streamed amount
1289
+ */
1290
+ getCurrentStreamedAmount(): string;
1291
+ /**
1292
+ * Calculate remaining balance
1293
+ */
1294
+ getRemainingBalance(): string;
1295
+ /**
1296
+ * Check if channel needs checkpoint
1297
+ */
1298
+ needsCheckpoint(): boolean;
1299
+ /**
1300
+ * Subscribe to state changes
1301
+ */
1302
+ onStateChange(state: ChannelState | '*', callback: (channel: StreamingChannel) => void): () => void;
1303
+ private notifyListeners;
1304
+ }
1305
+ /**
1306
+ * Check if channel is active (can stream)
1307
+ */
1308
+ declare function isChannelActive(channel: StreamingChannel): boolean;
1309
+ /**
1310
+ * Check if channel is terminal (cannot transition further)
1311
+ */
1312
+ declare function isChannelTerminal(channel: StreamingChannel): boolean;
1313
+ /**
1314
+ * Calculate channel utilization
1315
+ */
1316
+ declare function getChannelUtilization(channel: StreamingChannel): number;
1317
+
1318
+ /**
1319
+ * Channel opening configuration
1320
+ */
1321
+ interface ChannelOpeningConfig {
1322
+ fundingTimeout?: number;
1323
+ confirmations?: number;
1324
+ contractAddress?: string;
1325
+ }
1326
+ /**
1327
+ * Channel opening result
1328
+ */
1329
+ interface ChannelOpeningResult {
1330
+ channel: StreamingChannel;
1331
+ stateMachine: ChannelStateMachine;
1332
+ fundingRequired: {
1333
+ amount: string;
1334
+ to: string;
1335
+ data?: string;
1336
+ };
1337
+ }
1338
+ /**
1339
+ * Channel opener - handles channel creation and funding
1340
+ */
1341
+ declare class ChannelOpener {
1342
+ private config;
1343
+ constructor(config?: ChannelOpeningConfig);
1344
+ /**
1345
+ * Create a new channel
1346
+ */
1347
+ create(request: ChannelCreateRequest): ChannelOpeningResult;
1348
+ /**
1349
+ * Process funding transaction
1350
+ */
1351
+ processFunding(stateMachine: ChannelStateMachine, txHash: string, amount: string): {
1352
+ success: boolean;
1353
+ error?: string;
1354
+ };
1355
+ /**
1356
+ * Confirm funding (after required confirmations)
1357
+ */
1358
+ confirmFunding(stateMachine: ChannelStateMachine, _confirmation: FundingTransaction): {
1359
+ success: boolean;
1360
+ error?: string;
1361
+ };
1362
+ /**
1363
+ * Handle funding timeout
1364
+ */
1365
+ handleTimeout(stateMachine: ChannelStateMachine): {
1366
+ success: boolean;
1367
+ expired: boolean;
1368
+ };
1369
+ /**
1370
+ * Validate channel create request
1371
+ */
1372
+ private validateCreateRequest;
1373
+ /**
1374
+ * Generate unique channel ID
1375
+ */
1376
+ private generateChannelId;
1377
+ /**
1378
+ * Calculate funding requirements for channel
1379
+ */
1380
+ private calculateFundingRequirements;
1381
+ /**
1382
+ * Encode funding transaction data
1383
+ */
1384
+ private encodeFundingData;
1385
+ }
1386
+ /**
1387
+ * Estimate channel duration based on rate
1388
+ */
1389
+ declare function estimateChannelDuration(depositAmount: string, ratePerSecond: string): {
1390
+ seconds: number;
1391
+ formatted: string;
1392
+ };
1393
+ /**
1394
+ * Calculate required deposit for desired duration
1395
+ */
1396
+ declare function calculateRequiredDeposit(ratePerSecond: string, durationSeconds: number): string;
1397
+
1398
+ /**
1399
+ * Channel closing configuration
1400
+ */
1401
+ interface ChannelClosingConfig {
1402
+ challengePeriod?: number;
1403
+ gracePeriod?: number;
1404
+ autoFinalize?: boolean;
1405
+ }
1406
+ /**
1407
+ * Close initiation result
1408
+ */
1409
+ interface CloseInitiationResult {
1410
+ success: boolean;
1411
+ error?: string;
1412
+ challengeDeadline?: number;
1413
+ finalCheckpoint?: ChannelCheckpoint;
1414
+ settlementAmount?: {
1415
+ payer: string;
1416
+ payee: string;
1417
+ };
1418
+ }
1419
+ /**
1420
+ * Channel final settlement result
1421
+ */
1422
+ interface ChannelSettlementResult {
1423
+ success: boolean;
1424
+ error?: string;
1425
+ finalBalance: ChannelBalance;
1426
+ settlementTxHash?: string;
1427
+ gasCost?: string;
1428
+ }
1429
+ /**
1430
+ * Channel closer - handles channel closing and settlement
1431
+ */
1432
+ declare class ChannelCloser {
1433
+ private config;
1434
+ constructor(config?: ChannelClosingConfig);
1435
+ /**
1436
+ * Initiate channel close
1437
+ */
1438
+ initiateClose(stateMachine: ChannelStateMachine, initiator: string, signature: string): CloseInitiationResult;
1439
+ /**
1440
+ * Complete mutual close (both parties agree)
1441
+ */
1442
+ mutualClose(stateMachine: ChannelStateMachine, payerSignature: string, payeeSignature: string): CloseInitiationResult;
1443
+ /**
1444
+ * Finalize channel after challenge period
1445
+ */
1446
+ finalize(stateMachine: ChannelStateMachine): ChannelSettlementResult;
1447
+ /**
1448
+ * Validate close request
1449
+ */
1450
+ validateCloseRequest(channel: StreamingChannel, request: ChannelCloseRequest): {
1451
+ valid: boolean;
1452
+ errors: string[];
1453
+ };
1454
+ /**
1455
+ * Get settlement amounts for on-chain execution
1456
+ */
1457
+ getSettlementAmounts(channel: StreamingChannel): {
1458
+ payer: string;
1459
+ payee: string;
1460
+ fee: string;
1461
+ };
1462
+ /**
1463
+ * Calculate time until channel can be finalized
1464
+ */
1465
+ getTimeUntilFinalization(channel: StreamingChannel): number;
1466
+ /**
1467
+ * Check if channel close can be challenged
1468
+ */
1469
+ canChallenge(channel: StreamingChannel): boolean;
1470
+ private calculateFinalBalance;
1471
+ private createFinalCheckpoint;
1472
+ private validateCheckpoint;
1473
+ }
1474
+ /**
1475
+ * Build on-chain close transaction data
1476
+ */
1477
+ declare function buildCloseTransactionData(channel: StreamingChannel, checkpoint: ChannelCheckpoint): {
1478
+ to: string;
1479
+ data: string;
1480
+ value: string;
1481
+ };
1482
+
1483
+ /**
1484
+ * Recovery configuration
1485
+ */
1486
+ interface RecoveryConfig {
1487
+ maxCheckpointsToKeep?: number;
1488
+ verifySignatures?: boolean;
1489
+ onChainFallback?: boolean;
1490
+ }
1491
+ /**
1492
+ * Recovery result
1493
+ */
1494
+ interface RecoveryResult {
1495
+ success: boolean;
1496
+ error?: string;
1497
+ channel?: StreamingChannel;
1498
+ stateMachine?: ChannelStateMachine;
1499
+ recoveredFromCheckpoint?: ChannelCheckpoint;
1500
+ dataLoss?: boolean;
1501
+ }
1502
+ /**
1503
+ * Channel storage interface for recovery
1504
+ */
1505
+ interface IChannelStorage {
1506
+ getChannel(channelId: string): Promise<StreamingChannel | null>;
1507
+ getCheckpoints(channelId: string): Promise<ChannelCheckpoint[]>;
1508
+ getTransactions(channelId: string): Promise<FundingTransaction[]>;
1509
+ getDisputes(channelId: string): Promise<ChannelDispute[]>;
1510
+ getStateHistory(channelId: string): Promise<StateTransition[]>;
1511
+ }
1512
+ /**
1513
+ * Channel recovery manager
1514
+ */
1515
+ declare class ChannelRecovery {
1516
+ private config;
1517
+ private storage?;
1518
+ constructor(config?: RecoveryConfig, storage?: IChannelStorage);
1519
+ /**
1520
+ * Recover channel from checkpoints
1521
+ */
1522
+ recoverFromCheckpoints(baseChannel: StreamingChannel, checkpoints: ChannelCheckpoint[]): RecoveryResult;
1523
+ /**
1524
+ * Full recovery from storage
1525
+ */
1526
+ recoverFromStorage(channelId: string): Promise<RecoveryResult>;
1527
+ /**
1528
+ * Export recovery data for backup
1529
+ */
1530
+ exportRecoveryData(channel: StreamingChannel, stateMachine: ChannelStateMachine): RecoveryData;
1531
+ /**
1532
+ * Import recovery data
1533
+ */
1534
+ importRecoveryData(data: RecoveryData): RecoveryResult;
1535
+ /**
1536
+ * Verify checkpoint integrity
1537
+ */
1538
+ verifyCheckpointChain(checkpoints: ChannelCheckpoint[]): {
1539
+ valid: boolean;
1540
+ errors: string[];
1541
+ };
1542
+ /**
1543
+ * Prune old checkpoints keeping only recent ones
1544
+ */
1545
+ pruneCheckpoints(checkpoints: ChannelCheckpoint[]): ChannelCheckpoint[];
1546
+ private isCheckpointValid;
1547
+ private reconstructFromCheckpoint;
1548
+ private recoverFromOnChain;
1549
+ private createBaseChannelFromRecoveryData;
1550
+ }
1551
+ /**
1552
+ * Create a state snapshot for backup
1553
+ */
1554
+ declare function createStateSnapshot(_channel: StreamingChannel, stateMachine: ChannelStateMachine): string;
1555
+ /**
1556
+ * Restore from state snapshot
1557
+ */
1558
+ declare function restoreFromSnapshot(snapshotJson: string): RecoveryResult;
1559
+
1560
+ export { type AssetId, type ChainId, ChannelBalance, ChannelCheckpoint, ChannelCloseRequest, ChannelCloser, type ChannelClosingConfig, ChannelConfig, ChannelCreateRequest, ChannelDispute, ChannelOpener, type ChannelOpeningConfig, type ChannelOpeningResult, ChannelParticipant, ChannelRecovery, type ChannelSettlementResult, ChannelState, ChannelStateMachine, type CloseInitiationResult, FundingTransaction, type IChannelStorage, type RecoveryConfig, RecoveryData, type RecoveryResult, type StateEvent, StateTransition, StreamingChannel, buildCloseTransactionData, calculateRequiredDeposit, createStateSnapshot, estimateChannelDuration, getChannelUtilization, isChannelActive, isChannelTerminal, restoreFromSnapshot };