]> git.bitcoin.ninja Git - ldk-java/blob - c_sharp/src/org/ldk/structs/PeeledOnion.cs
Update CI references to LDK 0.0.124 drop stale memchr pins
[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                 public Option_MessageContextZ _1;
47                 /**
48                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
49                  */
50                 public BlindedMessagePath _2;
51                 internal PeeledOnion_Receive(long ptr) : base(null, ptr) {
52                         long _0 = bindings.LDKPeeledOnion_Receive_get__0(ptr);
53                         org.ldk.structs.ParsedOnionMessageContents _0_hu_conv = org.ldk.structs.ParsedOnionMessageContents.constr_from_ptr(_0);
54                         if (_0_hu_conv != null) { _0_hu_conv.ptrs_to.AddLast(this); };
55                         this._0 = _0_hu_conv;
56                         long _1 = bindings.LDKPeeledOnion_Receive_get__1(ptr);
57                         org.ldk.structs.Option_MessageContextZ _1_hu_conv = org.ldk.structs.Option_MessageContextZ.constr_from_ptr(_1);
58                         if (_1_hu_conv != null) { _1_hu_conv.ptrs_to.AddLast(this); };
59                         this._1 = _1_hu_conv;
60                         long _2 = bindings.LDKPeeledOnion_Receive_get__2(ptr);
61                         org.ldk.structs.BlindedMessagePath _2_hu_conv = null; if (_2 < 0 || _2 > 4096) { _2_hu_conv = new org.ldk.structs.BlindedMessagePath(null, _2); }
62                         if (_2_hu_conv != null) { _2_hu_conv.ptrs_to.AddLast(this); };
63                         this._2 = _2_hu_conv;
64                 }
65         }
66         internal long clone_ptr() {
67                 long ret = bindings.PeeledOnion_clone_ptr(this.ptr);
68                 GC.KeepAlive(this);
69                 return ret;
70         }
71
72         /**
73          * Creates a copy of the PeeledOnion
74          */
75         public PeeledOnion clone() {
76                 long ret = bindings.PeeledOnion_clone(this.ptr);
77                 GC.KeepAlive(this);
78                 if (ret >= 0 && ret <= 4096) { return null; }
79                 org.ldk.structs.PeeledOnion ret_hu_conv = org.ldk.structs.PeeledOnion.constr_from_ptr(ret);
80                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
81                 return ret_hu_conv;
82         }
83
84         /**
85          * Utility method to constructs a new Forward-variant PeeledOnion
86          */
87         public static PeeledOnion forward(org.ldk.structs.NextMessageHop a, org.ldk.structs.OnionMessage b) {
88                 long ret = bindings.PeeledOnion_forward(a.ptr, b.ptr);
89                 GC.KeepAlive(a);
90                 GC.KeepAlive(b);
91                 if (ret >= 0 && ret <= 4096) { return null; }
92                 org.ldk.structs.PeeledOnion ret_hu_conv = org.ldk.structs.PeeledOnion.constr_from_ptr(ret);
93                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
94                 return ret_hu_conv;
95         }
96
97         /**
98          * Utility method to constructs a new Receive-variant PeeledOnion
99          */
100         public static PeeledOnion receive(org.ldk.structs.ParsedOnionMessageContents a, org.ldk.structs.Option_MessageContextZ b, org.ldk.structs.BlindedMessagePath c) {
101                 long ret = bindings.PeeledOnion_receive(a.ptr, b.ptr, c.ptr);
102                 GC.KeepAlive(a);
103                 GC.KeepAlive(b);
104                 GC.KeepAlive(c);
105                 if (ret >= 0 && ret <= 4096) { return null; }
106                 org.ldk.structs.PeeledOnion ret_hu_conv = org.ldk.structs.PeeledOnion.constr_from_ptr(ret);
107                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
108                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
109                 return ret_hu_conv;
110         }
111
112 }
113 } } }