[C#] Update auto-generated C# bindings
[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                         long program = bindings.LDKFallback_SegWitProgram_get_program(ptr);
37                         byte[] program_conv = InternalUtils.decodeUint8Array(program);
38                         this.program = program_conv;
39                 }
40         }
41         /** A Fallback of type PubKeyHash */
42         public class Fallback_PubKeyHash : Fallback {
43                 public byte[] pub_key_hash;
44                 internal Fallback_PubKeyHash(long ptr) : base(null, ptr) {
45                         long pub_key_hash = bindings.LDKFallback_PubKeyHash_get_pub_key_hash(ptr);
46                         byte[] pub_key_hash_conv = InternalUtils.decodeUint8Array(pub_key_hash);
47                         this.pub_key_hash = pub_key_hash_conv;
48                 }
49         }
50         /** A Fallback of type ScriptHash */
51         public class Fallback_ScriptHash : Fallback {
52                 public byte[] script_hash;
53                 internal Fallback_ScriptHash(long ptr) : base(null, ptr) {
54                         long script_hash = bindings.LDKFallback_ScriptHash_get_script_hash(ptr);
55                         byte[] script_hash_conv = InternalUtils.decodeUint8Array(script_hash);
56                         this.script_hash = script_hash_conv;
57                 }
58         }
59         internal long clone_ptr() {
60                 long ret = bindings.Fallback_clone_ptr(this.ptr);
61                 GC.KeepAlive(this);
62                 return ret;
63         }
64
65         /**
66          * Creates a copy of the Fallback
67          */
68         public Fallback clone() {
69                 long ret = bindings.Fallback_clone(this.ptr);
70                 GC.KeepAlive(this);
71                 if (ret >= 0 && ret <= 4096) { return null; }
72                 org.ldk.structs.Fallback ret_hu_conv = org.ldk.structs.Fallback.constr_from_ptr(ret);
73                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
74                 return ret_hu_conv;
75         }
76
77         /**
78          * Utility method to constructs a new SegWitProgram-variant Fallback
79          */
80         public static Fallback seg_wit_program(org.ldk.util.WitnessVersion version, byte[] program) {
81                 long ret = bindings.Fallback_seg_wit_program(version.getVal(), InternalUtils.encodeUint8Array(program));
82                 GC.KeepAlive(version);
83                 GC.KeepAlive(program);
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 org.ldk.structs.Fallback ret_hu_conv = org.ldk.structs.Fallback.constr_from_ptr(ret);
86                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
87                 return ret_hu_conv;
88         }
89
90         /**
91          * Utility method to constructs a new PubKeyHash-variant Fallback
92          */
93         public static Fallback pub_key_hash(byte[] a) {
94                 long ret = bindings.Fallback_pub_key_hash(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(a, 20)));
95                 GC.KeepAlive(a);
96                 if (ret >= 0 && ret <= 4096) { return null; }
97                 org.ldk.structs.Fallback ret_hu_conv = org.ldk.structs.Fallback.constr_from_ptr(ret);
98                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
99                 return ret_hu_conv;
100         }
101
102         /**
103          * Utility method to constructs a new ScriptHash-variant Fallback
104          */
105         public static Fallback script_hash(byte[] a) {
106                 long ret = bindings.Fallback_script_hash(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(a, 20)));
107                 GC.KeepAlive(a);
108                 if (ret >= 0 && ret <= 4096) { return null; }
109                 org.ldk.structs.Fallback ret_hu_conv = org.ldk.structs.Fallback.constr_from_ptr(ret);
110                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
111                 return ret_hu_conv;
112         }
113
114         /**
115          * Generates a non-cryptographic 64-bit hash of the Fallback.
116          */
117         public long hash() {
118                 long ret = bindings.Fallback_hash(this.ptr);
119                 GC.KeepAlive(this);
120                 return ret;
121         }
122
123         public override int GetHashCode() {
124                 return (int)this.hash();
125         }
126         /**
127          * Checks if two Fallbacks contain equal inner contents.
128          * This ignores pointers and is_owned flags and looks at the values in fields.
129          */
130         public bool eq(org.ldk.structs.Fallback b) {
131                 bool ret = bindings.Fallback_eq(this.ptr, b == null ? 0 : b.ptr);
132                 GC.KeepAlive(this);
133                 GC.KeepAlive(b);
134                 return ret;
135         }
136
137         public override bool Equals(object o) {
138                 if (!(o is Fallback)) return false;
139                 return this.eq((Fallback)o);
140         }
141 }
142 } } }