6 namespace org { namespace ldk { namespace structs {
9 * Fallback address in case no LN payment is possible
11 public class Fallback : CommonBase {
12 protected Fallback(object _dummy, long ptr) : base(ptr) { }
14 if (ptr != 0) { bindings.Fallback_free(ptr); }
17 internal static Fallback constr_from_ptr(long ptr) {
18 long raw_ty = bindings.LDKFallback_ty_from_ptr(ptr);
20 case 0: return new Fallback_SegWitProgram(ptr);
21 case 1: return new Fallback_PubKeyHash(ptr);
22 case 2: return new Fallback_ScriptHash(ptr);
24 throw new ArgumentException("Impossible enum variant");
28 /** A Fallback of type SegWitProgram */
29 public class Fallback_SegWitProgram : Fallback {
31 public byte[] program;
32 internal Fallback_SegWitProgram(long ptr) : base(null, ptr) {
33 byte version = bindings.LDKFallback_SegWitProgram_get_version(ptr);
34 UInt5 version_conv = new UInt5(version);
35 this.version = version_conv;
36 this.program = bindings.LDKFallback_SegWitProgram_get_program(ptr);
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);
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);
53 internal long clone_ptr() {
54 long ret = bindings.Fallback_clone_ptr(this.ptr);
60 * Creates a copy of the Fallback
62 public Fallback clone() {
63 long ret = bindings.Fallback_clone(this.ptr);
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); };
72 * Utility method to constructs a new SegWitProgram-variant Fallback
74 public static Fallback seg_wit_program(org.ldk.util.UInt5 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); };
85 * Utility method to constructs a new PubKeyHash-variant Fallback
87 public static Fallback pub_key_hash(byte[] a) {
88 long ret = bindings.Fallback_pub_key_hash(InternalUtils.check_arr_len(a, 20));
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); };
97 * Utility method to constructs a new ScriptHash-variant Fallback
99 public static Fallback script_hash(byte[] a) {
100 long ret = bindings.Fallback_script_hash(InternalUtils.check_arr_len(a, 20));
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); };
109 * Checks if two Fallbacks contain equal inner contents.
112 long ret = bindings.Fallback_hash(this.ptr);
117 public override int GetHashCode() {
118 return (int)this.hash();
121 * Checks if two Fallbacks contain equal inner contents.
122 * This ignores pointers and is_owned flags and looks at the values in fields.
124 public bool eq(org.ldk.structs.Fallback b) {
125 bool ret = bindings.Fallback_eq(this.ptr, b == null ? 0 : b.ptr);
131 public override bool Equals(object o) {
132 if (!(o is Fallback)) return false;
133 return this.eq((Fallback)o);