[C#] Update auto-generated files
[ldk-java] / c_sharp / src / org / ldk / structs / Fallback.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  * Fallback address in case no LN payment is possible
10  */
11 public class Fallback : CommonBase {
12         protected Fallback(object _dummy, long ptr) : base(ptr) { }
13         ~Fallback() {
14                 if (ptr != 0) { bindings.Fallback_free(ptr); }
15         }
16
17         internal static Fallback constr_from_ptr(long ptr) {
18                 long raw_ty = bindings.LDKFallback_ty_from_ptr(ptr);
19                 switch (raw_ty) {
20                         case 0: return new Fallback_SegWitProgram(ptr);
21                         case 1: return new Fallback_PubKeyHash(ptr);
22                         case 2: return new Fallback_ScriptHash(ptr);
23                         default:
24                                 throw new ArgumentException("Impossible enum variant");
25                 }
26         }
27
28         /** A Fallback of type SegWitProgram */
29         public class Fallback_SegWitProgram : Fallback {
30                 public WitnessVersion version;
31                 public byte[] program;
32                 internal Fallback_SegWitProgram(long ptr) : base(null, ptr) {
33                         byte version = bindings.LDKFallback_SegWitProgram_get_version(ptr);
34                         WitnessVersion version_conv = new WitnessVersion(version);
35                         this.version = version_conv;
36                         this.program = bindings.LDKFallback_SegWitProgram_get_program(ptr);
37                 }
38         }
39         /** A Fallback of type PubKeyHash */
40         public class Fallback_PubKeyHash : Fallback {
41                 public byte[] pub_key_hash;
42                 internal Fallback_PubKeyHash(long ptr) : base(null, ptr) {
43                         this.pub_key_hash = bindings.LDKFallback_PubKeyHash_get_pub_key_hash(ptr);
44                 }
45         }
46         /** A Fallback of type ScriptHash */
47         public class Fallback_ScriptHash : Fallback {
48                 public byte[] script_hash;
49                 internal Fallback_ScriptHash(long ptr) : base(null, ptr) {
50                         this.script_hash = bindings.LDKFallback_ScriptHash_get_script_hash(ptr);
51                 }
52         }
53         internal long clone_ptr() {
54                 long ret = bindings.Fallback_clone_ptr(this.ptr);
55                 GC.KeepAlive(this);
56                 return ret;
57         }
58
59         /**
60          * Creates a copy of the Fallback
61          */
62         public Fallback clone() {
63                 long ret = bindings.Fallback_clone(this.ptr);
64                 GC.KeepAlive(this);
65                 if (ret >= 0 && ret <= 4096) { return null; }
66                 org.ldk.structs.Fallback ret_hu_conv = org.ldk.structs.Fallback.constr_from_ptr(ret);
67                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
68                 return ret_hu_conv;
69         }
70
71         /**
72          * Utility method to constructs a new SegWitProgram-variant Fallback
73          */
74         public static Fallback seg_wit_program(org.ldk.util.WitnessVersion version, byte[] program) {
75                 long ret = bindings.Fallback_seg_wit_program(version.getVal(), program);
76                 GC.KeepAlive(version);
77                 GC.KeepAlive(program);
78                 if (ret >= 0 && ret <= 4096) { return null; }
79                 org.ldk.structs.Fallback ret_hu_conv = org.ldk.structs.Fallback.constr_from_ptr(ret);
80                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
81                 return ret_hu_conv;
82         }
83
84         /**
85          * Utility method to constructs a new PubKeyHash-variant Fallback
86          */
87         public static Fallback pub_key_hash(byte[] a) {
88                 long ret = bindings.Fallback_pub_key_hash(InternalUtils.check_arr_len(a, 20));
89                 GC.KeepAlive(a);
90                 if (ret >= 0 && ret <= 4096) { return null; }
91                 org.ldk.structs.Fallback ret_hu_conv = org.ldk.structs.Fallback.constr_from_ptr(ret);
92                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
93                 return ret_hu_conv;
94         }
95
96         /**
97          * Utility method to constructs a new ScriptHash-variant Fallback
98          */
99         public static Fallback script_hash(byte[] a) {
100                 long ret = bindings.Fallback_script_hash(InternalUtils.check_arr_len(a, 20));
101                 GC.KeepAlive(a);
102                 if (ret >= 0 && ret <= 4096) { return null; }
103                 org.ldk.structs.Fallback ret_hu_conv = org.ldk.structs.Fallback.constr_from_ptr(ret);
104                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
105                 return ret_hu_conv;
106         }
107
108         /**
109          * Generates a non-cryptographic 64-bit hash of the Fallback.
110          */
111         public long hash() {
112                 long ret = bindings.Fallback_hash(this.ptr);
113                 GC.KeepAlive(this);
114                 return ret;
115         }
116
117         public override int GetHashCode() {
118                 return (int)this.hash();
119         }
120         /**
121          * Checks if two Fallbacks contain equal inner contents.
122          * This ignores pointers and is_owned flags and looks at the values in fields.
123          */
124         public bool eq(org.ldk.structs.Fallback b) {
125                 bool ret = bindings.Fallback_eq(this.ptr, b == null ? 0 : b.ptr);
126                 GC.KeepAlive(this);
127                 GC.KeepAlive(b);
128                 return ret;
129         }
130
131         public override bool Equals(object o) {
132                 if (!(o is Fallback)) return false;
133                 return this.eq((Fallback)o);
134         }
135 }
136 } } }