[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / PeeledOnion.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8 /**
9  * A processed incoming onion message, containing either a Forward (another onion message)
10  * or a Receive payload with decrypted contents.
11  */
12 public class PeeledOnion : CommonBase {
13         protected PeeledOnion(object _dummy, long ptr) : base(ptr) { }
14         ~PeeledOnion() {
15                 if (ptr != 0) { bindings.PeeledOnion_free(ptr); }
16         }
17
18         internal static PeeledOnion constr_from_ptr(long ptr) {
19                 long raw_ty = bindings.LDKPeeledOnion_ty_from_ptr(ptr);
20                 switch (raw_ty) {
21                         case 0: return new PeeledOnion_Forward(ptr);
22                         case 1: return new PeeledOnion_Receive(ptr);
23                         default:
24                                 throw new ArgumentException("Impossible enum variant");
25                 }
26         }
27
28         /** A PeeledOnion of type Forward */
29         public class PeeledOnion_Forward : PeeledOnion {
30                 public byte[] _0;
31                 public OnionMessage _1;
32                 internal PeeledOnion_Forward(long ptr) : base(null, ptr) {
33                         long _0 = bindings.LDKPeeledOnion_Forward_get__0(ptr);
34                         byte[] _0_conv = InternalUtils.decodeUint8Array(_0);
35                         this._0 = _0_conv;
36                         long _1 = bindings.LDKPeeledOnion_Forward_get__1(ptr);
37                         org.ldk.structs.OnionMessage _1_hu_conv = null; if (_1 < 0 || _1 > 4096) { _1_hu_conv = new org.ldk.structs.OnionMessage(null, _1); }
38                         if (_1_hu_conv != null) { _1_hu_conv.ptrs_to.AddLast(this); };
39                         this._1 = _1_hu_conv;
40                 }
41         }
42         /** A PeeledOnion of type Receive */
43         public class PeeledOnion_Receive : PeeledOnion {
44                 public ParsedOnionMessageContents _0;
45                 /**
46                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
47                  */
48                 public byte[] _1;
49                 /**
50                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
51                  */
52                 public BlindedPath _2;
53                 internal PeeledOnion_Receive(long ptr) : base(null, ptr) {
54                         long _0 = bindings.LDKPeeledOnion_Receive_get__0(ptr);
55                         org.ldk.structs.ParsedOnionMessageContents _0_hu_conv = org.ldk.structs.ParsedOnionMessageContents.constr_from_ptr(_0);
56                         if (_0_hu_conv != null) { _0_hu_conv.ptrs_to.AddLast(this); };
57                         this._0 = _0_hu_conv;
58                         long _1 = bindings.LDKPeeledOnion_Receive_get__1(ptr);
59                         byte[] _1_conv = InternalUtils.decodeUint8Array(_1);
60                         this._1 = _1_conv;
61                         long _2 = bindings.LDKPeeledOnion_Receive_get__2(ptr);
62                         org.ldk.structs.BlindedPath _2_hu_conv = null; if (_2 < 0 || _2 > 4096) { _2_hu_conv = new org.ldk.structs.BlindedPath(null, _2); }
63                         if (_2_hu_conv != null) { _2_hu_conv.ptrs_to.AddLast(this); };
64                         this._2 = _2_hu_conv;
65                 }
66         }
67         internal long clone_ptr() {
68                 long ret = bindings.PeeledOnion_clone_ptr(this.ptr);
69                 GC.KeepAlive(this);
70                 return ret;
71         }
72
73         /**
74          * Creates a copy of the PeeledOnion
75          */
76         public PeeledOnion clone() {
77                 long ret = bindings.PeeledOnion_clone(this.ptr);
78                 GC.KeepAlive(this);
79                 if (ret >= 0 && ret <= 4096) { return null; }
80                 org.ldk.structs.PeeledOnion ret_hu_conv = org.ldk.structs.PeeledOnion.constr_from_ptr(ret);
81                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
82                 return ret_hu_conv;
83         }
84
85         /**
86          * Utility method to constructs a new Forward-variant PeeledOnion
87          */
88         public static PeeledOnion forward(byte[] a, org.ldk.structs.OnionMessage b) {
89                 long ret = bindings.PeeledOnion_forward(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(a, 33)), b == null ? 0 : b.ptr);
90                 GC.KeepAlive(a);
91                 GC.KeepAlive(b);
92                 if (ret >= 0 && ret <= 4096) { return null; }
93                 org.ldk.structs.PeeledOnion ret_hu_conv = org.ldk.structs.PeeledOnion.constr_from_ptr(ret);
94                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
95                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(b); };
96                 return ret_hu_conv;
97         }
98
99         /**
100          * Utility method to constructs a new Receive-variant PeeledOnion
101          */
102         public static PeeledOnion receive(org.ldk.structs.ParsedOnionMessageContents a, byte[] b, org.ldk.structs.BlindedPath c) {
103                 long ret = bindings.PeeledOnion_receive(a.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(b, 32)), c == null ? 0 : c.ptr);
104                 GC.KeepAlive(a);
105                 GC.KeepAlive(b);
106                 GC.KeepAlive(c);
107                 if (ret >= 0 && ret <= 4096) { return null; }
108                 org.ldk.structs.PeeledOnion ret_hu_conv = org.ldk.structs.PeeledOnion.constr_from_ptr(ret);
109                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
110                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
111                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(c); };
112                 return ret_hu_conv;
113         }
114
115 }
116 } } }