[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[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 NextMessageHop _0;
31                 public OnionMessage _1;
32                 internal PeeledOnion_Forward(long ptr) : base(null, ptr) {
33                         long _0 = bindings.LDKPeeledOnion_Forward_get__0(ptr);
34                         org.ldk.structs.NextMessageHop _0_hu_conv = org.ldk.structs.NextMessageHop.constr_from_ptr(_0);
35                         if (_0_hu_conv != null) { _0_hu_conv.ptrs_to.AddLast(this); };
36                         this._0 = _0_hu_conv;
37                         long _1 = bindings.LDKPeeledOnion_Forward_get__1(ptr);
38                         org.ldk.structs.OnionMessage _1_hu_conv = null; if (_1 < 0 || _1 > 4096) { _1_hu_conv = new org.ldk.structs.OnionMessage(null, _1); }
39                         if (_1_hu_conv != null) { _1_hu_conv.ptrs_to.AddLast(this); };
40                         this._1 = _1_hu_conv;
41                 }
42         }
43         /** A PeeledOnion of type Receive */
44         public class PeeledOnion_Receive : PeeledOnion {
45                 public ParsedOnionMessageContents _0;
46                 /**
47                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
48                  */
49                 public byte[] _1;
50                 /**
51                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
52                  */
53                 public BlindedPath _2;
54                 internal PeeledOnion_Receive(long ptr) : base(null, ptr) {
55                         long _0 = bindings.LDKPeeledOnion_Receive_get__0(ptr);
56                         org.ldk.structs.ParsedOnionMessageContents _0_hu_conv = org.ldk.structs.ParsedOnionMessageContents.constr_from_ptr(_0);
57                         if (_0_hu_conv != null) { _0_hu_conv.ptrs_to.AddLast(this); };
58                         this._0 = _0_hu_conv;
59                         long _1 = bindings.LDKPeeledOnion_Receive_get__1(ptr);
60                         byte[] _1_conv = InternalUtils.decodeUint8Array(_1);
61                         this._1 = _1_conv;
62                         long _2 = bindings.LDKPeeledOnion_Receive_get__2(ptr);
63                         org.ldk.structs.BlindedPath _2_hu_conv = null; if (_2 < 0 || _2 > 4096) { _2_hu_conv = new org.ldk.structs.BlindedPath(null, _2); }
64                         if (_2_hu_conv != null) { _2_hu_conv.ptrs_to.AddLast(this); };
65                         this._2 = _2_hu_conv;
66                 }
67         }
68         internal long clone_ptr() {
69                 long ret = bindings.PeeledOnion_clone_ptr(this.ptr);
70                 GC.KeepAlive(this);
71                 return ret;
72         }
73
74         /**
75          * Creates a copy of the PeeledOnion
76          */
77         public PeeledOnion clone() {
78                 long ret = bindings.PeeledOnion_clone(this.ptr);
79                 GC.KeepAlive(this);
80                 if (ret >= 0 && ret <= 4096) { return null; }
81                 org.ldk.structs.PeeledOnion ret_hu_conv = org.ldk.structs.PeeledOnion.constr_from_ptr(ret);
82                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
83                 return ret_hu_conv;
84         }
85
86         /**
87          * Utility method to constructs a new Forward-variant PeeledOnion
88          */
89         public static PeeledOnion forward(org.ldk.structs.NextMessageHop a, org.ldk.structs.OnionMessage b) {
90                 long ret = bindings.PeeledOnion_forward(a.ptr, b.ptr);
91                 GC.KeepAlive(a);
92                 GC.KeepAlive(b);
93                 if (ret >= 0 && ret <= 4096) { return null; }
94                 org.ldk.structs.PeeledOnion ret_hu_conv = org.ldk.structs.PeeledOnion.constr_from_ptr(ret);
95                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
96                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
97                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(b); };
98                 return ret_hu_conv;
99         }
100
101         /**
102          * Utility method to constructs a new Receive-variant PeeledOnion
103          */
104         public static PeeledOnion receive(org.ldk.structs.ParsedOnionMessageContents a, byte[] b, org.ldk.structs.BlindedPath c) {
105                 long ret = bindings.PeeledOnion_receive(a.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(b, 32)), c.ptr);
106                 GC.KeepAlive(a);
107                 GC.KeepAlive(b);
108                 GC.KeepAlive(c);
109                 if (ret >= 0 && ret <= 4096) { return null; }
110                 org.ldk.structs.PeeledOnion ret_hu_conv = org.ldk.structs.PeeledOnion.constr_from_ptr(ret);
111                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
112                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
113                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(c); };
114                 return ret_hu_conv;
115         }
116
117 }
118 } } }