forked from ElementsProject/lightning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathonion_printgen.c
862 lines (697 loc) · 22.2 KB
/
onion_printgen.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the .csv file it was generated from. */
#include "wire/onion_printgen.h"
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <inttypes.h>
#include <stdio.h>
void printonion_wire_message(const u8 *msg)
{
switch ((enum onion_wire)fromwire_peektype(msg)) {
case WIRE_INVALID_REALM:
printf("WIRE_INVALID_REALM:\n");
printwire_invalid_realm("invalid_realm", msg);
return;
case WIRE_TEMPORARY_NODE_FAILURE:
printf("WIRE_TEMPORARY_NODE_FAILURE:\n");
printwire_temporary_node_failure("temporary_node_failure", msg);
return;
case WIRE_PERMANENT_NODE_FAILURE:
printf("WIRE_PERMANENT_NODE_FAILURE:\n");
printwire_permanent_node_failure("permanent_node_failure", msg);
return;
case WIRE_REQUIRED_NODE_FEATURE_MISSING:
printf("WIRE_REQUIRED_NODE_FEATURE_MISSING:\n");
printwire_required_node_feature_missing("required_node_feature_missing", msg);
return;
case WIRE_INVALID_ONION_VERSION:
printf("WIRE_INVALID_ONION_VERSION:\n");
printwire_invalid_onion_version("invalid_onion_version", msg);
return;
case WIRE_INVALID_ONION_HMAC:
printf("WIRE_INVALID_ONION_HMAC:\n");
printwire_invalid_onion_hmac("invalid_onion_hmac", msg);
return;
case WIRE_INVALID_ONION_KEY:
printf("WIRE_INVALID_ONION_KEY:\n");
printwire_invalid_onion_key("invalid_onion_key", msg);
return;
case WIRE_TEMPORARY_CHANNEL_FAILURE:
printf("WIRE_TEMPORARY_CHANNEL_FAILURE:\n");
printwire_temporary_channel_failure("temporary_channel_failure", msg);
return;
case WIRE_PERMANENT_CHANNEL_FAILURE:
printf("WIRE_PERMANENT_CHANNEL_FAILURE:\n");
printwire_permanent_channel_failure("permanent_channel_failure", msg);
return;
case WIRE_REQUIRED_CHANNEL_FEATURE_MISSING:
printf("WIRE_REQUIRED_CHANNEL_FEATURE_MISSING:\n");
printwire_required_channel_feature_missing("required_channel_feature_missing", msg);
return;
case WIRE_UNKNOWN_NEXT_PEER:
printf("WIRE_UNKNOWN_NEXT_PEER:\n");
printwire_unknown_next_peer("unknown_next_peer", msg);
return;
case WIRE_AMOUNT_BELOW_MINIMUM:
printf("WIRE_AMOUNT_BELOW_MINIMUM:\n");
printwire_amount_below_minimum("amount_below_minimum", msg);
return;
case WIRE_FEE_INSUFFICIENT:
printf("WIRE_FEE_INSUFFICIENT:\n");
printwire_fee_insufficient("fee_insufficient", msg);
return;
case WIRE_INCORRECT_CLTV_EXPIRY:
printf("WIRE_INCORRECT_CLTV_EXPIRY:\n");
printwire_incorrect_cltv_expiry("incorrect_cltv_expiry", msg);
return;
case WIRE_EXPIRY_TOO_SOON:
printf("WIRE_EXPIRY_TOO_SOON:\n");
printwire_expiry_too_soon("expiry_too_soon", msg);
return;
case WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS:
printf("WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS:\n");
printwire_incorrect_or_unknown_payment_details("incorrect_or_unknown_payment_details", msg);
return;
case WIRE_FINAL_INCORRECT_CLTV_EXPIRY:
printf("WIRE_FINAL_INCORRECT_CLTV_EXPIRY:\n");
printwire_final_incorrect_cltv_expiry("final_incorrect_cltv_expiry", msg);
return;
case WIRE_FINAL_INCORRECT_HTLC_AMOUNT:
printf("WIRE_FINAL_INCORRECT_HTLC_AMOUNT:\n");
printwire_final_incorrect_htlc_amount("final_incorrect_htlc_amount", msg);
return;
case WIRE_CHANNEL_DISABLED:
printf("WIRE_CHANNEL_DISABLED:\n");
printwire_channel_disabled("channel_disabled", msg);
return;
case WIRE_EXPIRY_TOO_FAR:
printf("WIRE_EXPIRY_TOO_FAR:\n");
printwire_expiry_too_far("expiry_too_far", msg);
return;
case WIRE_INVALID_ONION_PAYLOAD:
printf("WIRE_INVALID_ONION_PAYLOAD:\n");
printwire_invalid_onion_payload("invalid_onion_payload", msg);
return;
case WIRE_MPP_TIMEOUT:
printf("WIRE_MPP_TIMEOUT:\n");
printwire_mpp_timeout("mpp_timeout", msg);
return;
}
printf("UNKNOWN: %s\\n", tal_hex(msg, msg));
}
void printwire_onionmsg_path(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("node_id=");
struct pubkey node_id;
fromwire_pubkey(cursor, plen, &node_id);
printwire_pubkey(tal_fmt(NULL, "%s.node_id", fieldname), &node_id);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
u16 enclen = fromwire_u16(cursor, plen);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("enctlv=");
printwire_u8_array(tal_fmt(NULL, "%s.enctlv", fieldname), cursor, plen, enclen);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static void printwire_tlv_tlv_payload_amt_to_forward(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "amt_to_forward");
printf("amt_to_forward=");
u64 amt_to_forward = fromwire_tu64(cursor, plen);
printwire_u64(tal_fmt(NULL, "%s.amt_to_forward", fieldname), &amt_to_forward);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static void printwire_tlv_tlv_payload_outgoing_cltv_value(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "outgoing_cltv_value");
printf("outgoing_cltv_value=");
u32 outgoing_cltv_value = fromwire_tu32(cursor, plen);
printwire_u32(tal_fmt(NULL, "%s.outgoing_cltv_value", fieldname), &outgoing_cltv_value);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static void printwire_tlv_tlv_payload_short_channel_id(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "short_channel_id");
printf("short_channel_id=");
struct short_channel_id short_channel_id;
fromwire_short_channel_id(cursor, plen, &short_channel_id);
printwire_short_channel_id(tal_fmt(NULL, "%s.short_channel_id", fieldname), &short_channel_id);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static void printwire_tlv_tlv_payload_payment_data(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "payment_data");
printf("payment_secret=");
struct secret payment_secret;
fromwire_secret(cursor, plen, &payment_secret);
printwire_secret(tal_fmt(NULL, "%s.payment_secret", fieldname), &payment_secret);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("total_msat=");
u64 total_msat = fromwire_tu64(cursor, plen);
printwire_u64(tal_fmt(NULL, "%s.total_msat", fieldname), &total_msat);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static const struct tlv_print_record_type print_tlvs_tlv_payload[] = {
{ 2, printwire_tlv_tlv_payload_amt_to_forward },
{ 4, printwire_tlv_tlv_payload_outgoing_cltv_value },
{ 6, printwire_tlv_tlv_payload_short_channel_id },
{ 8, printwire_tlv_tlv_payload_payment_data },
};
static void printwire_tlv_onionmsg_payload_next_node_id(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "next_node_id");
printf("node_id=");
struct pubkey node_id;
fromwire_pubkey(cursor, plen, &node_id);
printwire_pubkey(tal_fmt(NULL, "%s.node_id", fieldname), &node_id);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static void printwire_tlv_onionmsg_payload_next_short_channel_id(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "next_short_channel_id");
printf("short_channel_id=");
struct short_channel_id short_channel_id;
fromwire_short_channel_id(cursor, plen, &short_channel_id);
printwire_short_channel_id(tal_fmt(NULL, "%s.short_channel_id", fieldname), &short_channel_id);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static void printwire_tlv_onionmsg_payload_reply_path(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "reply_path");
printf("blinding=");
struct pubkey blinding;
fromwire_pubkey(cursor, plen, &blinding);
printwire_pubkey(tal_fmt(NULL, "%s.blinding", fieldname), &blinding);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("path=");
printf("[");
for (size_t i = 0; i < *plen; i++) {
printf("{\n");
printwire_onionmsg_path(tal_fmt(NULL, "%s.path", fieldname), cursor, plen);
printf("}\n");
}
printf("]");
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static void printwire_tlv_onionmsg_payload_enctlv(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "enctlv");
printf("enctlv=");
printwire_u8_array(tal_fmt(NULL, "%s.enctlv", fieldname), cursor, plen, *plen);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static void printwire_tlv_onionmsg_payload_blinding(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "blinding");
printf("blinding=");
struct pubkey blinding;
fromwire_pubkey(cursor, plen, &blinding);
printwire_pubkey(tal_fmt(NULL, "%s.blinding", fieldname), &blinding);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static void printwire_tlv_onionmsg_payload_invoice_request(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "invoice_request");
printf("invoice_request=");
printwire_u8_array(tal_fmt(NULL, "%s.invoice_request", fieldname), cursor, plen, *plen);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static void printwire_tlv_onionmsg_payload_invoice(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "invoice");
printf("invoice=");
printwire_u8_array(tal_fmt(NULL, "%s.invoice", fieldname), cursor, plen, *plen);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static void printwire_tlv_onionmsg_payload_invoice_error(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "invoice_error");
printf("invoice_error=");
printwire_u8_array(tal_fmt(NULL, "%s.invoice_error", fieldname), cursor, plen, *plen);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static const struct tlv_print_record_type print_tlvs_onionmsg_payload[] = {
{ 4, printwire_tlv_onionmsg_payload_next_node_id },
{ 6, printwire_tlv_onionmsg_payload_next_short_channel_id },
{ 8, printwire_tlv_onionmsg_payload_reply_path },
{ 10, printwire_tlv_onionmsg_payload_enctlv },
{ 12, printwire_tlv_onionmsg_payload_blinding },
{ 64, printwire_tlv_onionmsg_payload_invoice_request },
{ 66, printwire_tlv_onionmsg_payload_invoice },
{ 68, printwire_tlv_onionmsg_payload_invoice_error },
};
static void printwire_tlv_encmsg_tlvs_next_node_id(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "next_node_id");
printf("node_id=");
struct pubkey node_id;
fromwire_pubkey(cursor, plen, &node_id);
printwire_pubkey(tal_fmt(NULL, "%s.node_id", fieldname), &node_id);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static void printwire_tlv_encmsg_tlvs_next_short_channel_id(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "next_short_channel_id");
printf("short_channel_id=");
struct short_channel_id short_channel_id;
fromwire_short_channel_id(cursor, plen, &short_channel_id);
printwire_short_channel_id(tal_fmt(NULL, "%s.short_channel_id", fieldname), &short_channel_id);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static const struct tlv_print_record_type print_tlvs_encmsg_tlvs[] = {
{ 4, printwire_tlv_encmsg_tlvs_next_node_id },
{ 6, printwire_tlv_encmsg_tlvs_next_short_channel_id },
};
void printwire_invalid_realm(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_INVALID_REALM) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_temporary_node_failure(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_TEMPORARY_NODE_FAILURE) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_permanent_node_failure(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_PERMANENT_NODE_FAILURE) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_required_node_feature_missing(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_REQUIRED_NODE_FEATURE_MISSING) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_invalid_onion_version(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_INVALID_ONION_VERSION) {
printf("WRONG TYPE?!\n");
return;
}
printf("sha256_of_onion=");
struct sha256 sha256_of_onion;
fromwire_sha256(&cursor, &plen, &sha256_of_onion);
printwire_sha256(tal_fmt(NULL, "%s.sha256_of_onion", fieldname), &sha256_of_onion);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_invalid_onion_hmac(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_INVALID_ONION_HMAC) {
printf("WRONG TYPE?!\n");
return;
}
printf("sha256_of_onion=");
struct sha256 sha256_of_onion;
fromwire_sha256(&cursor, &plen, &sha256_of_onion);
printwire_sha256(tal_fmt(NULL, "%s.sha256_of_onion", fieldname), &sha256_of_onion);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_invalid_onion_key(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_INVALID_ONION_KEY) {
printf("WRONG TYPE?!\n");
return;
}
printf("sha256_of_onion=");
struct sha256 sha256_of_onion;
fromwire_sha256(&cursor, &plen, &sha256_of_onion);
printwire_sha256(tal_fmt(NULL, "%s.sha256_of_onion", fieldname), &sha256_of_onion);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_temporary_channel_failure(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_TEMPORARY_CHANNEL_FAILURE) {
printf("WRONG TYPE?!\n");
return;
}
u16 len = fromwire_u16(&cursor, &plen);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("channel_update=");
printwire_u8_array(tal_fmt(NULL, "%s.channel_update", fieldname), &cursor, &plen, len);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_permanent_channel_failure(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_PERMANENT_CHANNEL_FAILURE) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_required_channel_feature_missing(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_REQUIRED_CHANNEL_FEATURE_MISSING) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_unknown_next_peer(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_UNKNOWN_NEXT_PEER) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_amount_below_minimum(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_AMOUNT_BELOW_MINIMUM) {
printf("WRONG TYPE?!\n");
return;
}
printf("htlc_msat=");
struct amount_msat htlc_msat = fromwire_amount_msat(&cursor, &plen);
printwire_amount_msat(tal_fmt(NULL, "%s.htlc_msat", fieldname), &htlc_msat);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
u16 len = fromwire_u16(&cursor, &plen);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("channel_update=");
printwire_u8_array(tal_fmt(NULL, "%s.channel_update", fieldname), &cursor, &plen, len);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_fee_insufficient(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_FEE_INSUFFICIENT) {
printf("WRONG TYPE?!\n");
return;
}
printf("htlc_msat=");
struct amount_msat htlc_msat = fromwire_amount_msat(&cursor, &plen);
printwire_amount_msat(tal_fmt(NULL, "%s.htlc_msat", fieldname), &htlc_msat);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
u16 len = fromwire_u16(&cursor, &plen);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("channel_update=");
printwire_u8_array(tal_fmt(NULL, "%s.channel_update", fieldname), &cursor, &plen, len);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_incorrect_cltv_expiry(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_INCORRECT_CLTV_EXPIRY) {
printf("WRONG TYPE?!\n");
return;
}
printf("cltv_expiry=");
u32 cltv_expiry = fromwire_u32(&cursor, &plen);
printwire_u32(tal_fmt(NULL, "%s.cltv_expiry", fieldname), &cltv_expiry);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
u16 len = fromwire_u16(&cursor, &plen);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("channel_update=");
printwire_u8_array(tal_fmt(NULL, "%s.channel_update", fieldname), &cursor, &plen, len);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_expiry_too_soon(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_EXPIRY_TOO_SOON) {
printf("WRONG TYPE?!\n");
return;
}
u16 len = fromwire_u16(&cursor, &plen);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("channel_update=");
printwire_u8_array(tal_fmt(NULL, "%s.channel_update", fieldname), &cursor, &plen, len);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_incorrect_or_unknown_payment_details(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS) {
printf("WRONG TYPE?!\n");
return;
}
printf("htlc_msat=");
struct amount_msat htlc_msat = fromwire_amount_msat(&cursor, &plen);
printwire_amount_msat(tal_fmt(NULL, "%s.htlc_msat", fieldname), &htlc_msat);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("height=");
u32 height = fromwire_u32(&cursor, &plen);
printwire_u32(tal_fmt(NULL, "%s.height", fieldname), &height);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_final_incorrect_cltv_expiry(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_FINAL_INCORRECT_CLTV_EXPIRY) {
printf("WRONG TYPE?!\n");
return;
}
printf("cltv_expiry=");
u32 cltv_expiry = fromwire_u32(&cursor, &plen);
printwire_u32(tal_fmt(NULL, "%s.cltv_expiry", fieldname), &cltv_expiry);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_final_incorrect_htlc_amount(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_FINAL_INCORRECT_HTLC_AMOUNT) {
printf("WRONG TYPE?!\n");
return;
}
printf("incoming_htlc_amt=");
struct amount_msat incoming_htlc_amt = fromwire_amount_msat(&cursor, &plen);
printwire_amount_msat(tal_fmt(NULL, "%s.incoming_htlc_amt", fieldname), &incoming_htlc_amt);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_channel_disabled(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_CHANNEL_DISABLED) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_expiry_too_far(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_EXPIRY_TOO_FAR) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_invalid_onion_payload(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_INVALID_ONION_PAYLOAD) {
printf("WRONG TYPE?!\n");
return;
}
printf("type=");
bigsize type = fromwire_bigsize(&cursor, &plen);
printwire_bigsize(tal_fmt(NULL, "%s.type", fieldname), &type);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("offset=");
u16 offset = fromwire_u16(&cursor, &plen);
printwire_u16(tal_fmt(NULL, "%s.offset", fieldname), &offset);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_mpp_timeout(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_MPP_TIMEOUT) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printonion_wire_tlv_message(const char *tlv_name, const u8 *msg) {
size_t plen = tal_count(msg);
if (strcmp(tlv_name, "tlv_payload") == 0) {
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_tlv_payload, ARRAY_SIZE(print_tlvs_tlv_payload));
}
if (strcmp(tlv_name, "onionmsg_payload") == 0) {
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_onionmsg_payload, ARRAY_SIZE(print_tlvs_onionmsg_payload));
}
if (strcmp(tlv_name, "encmsg_tlvs") == 0) {
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_encmsg_tlvs, ARRAY_SIZE(print_tlvs_encmsg_tlvs));
}
}
// SHA256STAMP:897accc52196e69cffeee8386a5e1af8754fe49baefd58460c788024e4e8dd6f