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 {
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;
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;
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;
59 internal long clone_ptr() {
60 long ret = bindings.Fallback_clone_ptr(this.ptr);
66 * Creates a copy of the Fallback
68 public Fallback clone() {
69 long ret = bindings.Fallback_clone(this.ptr);
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); };
78 * Utility method to constructs a new SegWitProgram-variant Fallback
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); };
91 * Utility method to constructs a new PubKeyHash-variant Fallback
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)));
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); };
103 * Utility method to constructs a new ScriptHash-variant Fallback
105 public static Fallback script_hash(byte[] a) {
106 long ret = bindings.Fallback_script_hash(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(a, 20)));
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); };
115 * Generates a non-cryptographic 64-bit hash of the Fallback.
118 long ret = bindings.Fallback_hash(this.ptr);
123 public override int GetHashCode() {
124 return (int)this.hash();
127 * Checks if two Fallbacks contain equal inner contents.
128 * This ignores pointers and is_owned flags and looks at the values in fields.
130 public bool eq(org.ldk.structs.Fallback b) {
131 bool ret = bindings.Fallback_eq(this.ptr, b == null ? 0 : b.ptr);
137 public override bool Equals(object o) {
138 if (!(o is Fallback)) return false;
139 return this.eq((Fallback)o);