Update auto-generated bindings to 0.0.103
[ldk-java] / src / main / java / org / ldk / structs / Fallback.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
8
9
10 /**
11  * Fallback address in case no LN payment is possible
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class Fallback extends CommonBase {
15         private Fallback(Object _dummy, long ptr) { super(ptr); }
16         @Override @SuppressWarnings("deprecation")
17         protected void finalize() throws Throwable {
18                 super.finalize();
19                 if (ptr != 0) { bindings.Fallback_free(ptr); }
20         }
21         static Fallback constr_from_ptr(long ptr) {
22                 bindings.LDKFallback raw_val = bindings.LDKFallback_ref_from_ptr(ptr);
23                 if (raw_val.getClass() == bindings.LDKFallback.SegWitProgram.class) {
24                         return new SegWitProgram(ptr, (bindings.LDKFallback.SegWitProgram)raw_val);
25                 }
26                 if (raw_val.getClass() == bindings.LDKFallback.PubKeyHash.class) {
27                         return new PubKeyHash(ptr, (bindings.LDKFallback.PubKeyHash)raw_val);
28                 }
29                 if (raw_val.getClass() == bindings.LDKFallback.ScriptHash.class) {
30                         return new ScriptHash(ptr, (bindings.LDKFallback.ScriptHash)raw_val);
31                 }
32                 assert false; return null; // Unreachable without extending the (internal) bindings interface
33         }
34
35         public final static class SegWitProgram extends Fallback {
36                 public final UInt5 version;
37                 public final byte[] program;
38                 private SegWitProgram(long ptr, bindings.LDKFallback.SegWitProgram obj) {
39                         super(null, ptr);
40                         byte version = obj.version;
41                         UInt5 version_conv = new UInt5(version);
42                         this.version = version_conv;
43                         this.program = obj.program;
44                 }
45         }
46         public final static class PubKeyHash extends Fallback {
47                 public final byte[] pub_key_hash;
48                 private PubKeyHash(long ptr, bindings.LDKFallback.PubKeyHash obj) {
49                         super(null, ptr);
50                         this.pub_key_hash = obj.pub_key_hash;
51                 }
52         }
53         public final static class ScriptHash extends Fallback {
54                 public final byte[] script_hash;
55                 private ScriptHash(long ptr, bindings.LDKFallback.ScriptHash obj) {
56                         super(null, ptr);
57                         this.script_hash = obj.script_hash;
58                 }
59         }
60         /**
61          * Creates a copy of the Fallback
62          */
63         public Fallback clone() {
64                 long ret = bindings.Fallback_clone(this.ptr);
65                 if (ret >= 0 && ret <= 4096) { return null; }
66                 Fallback ret_hu_conv = Fallback.constr_from_ptr(ret);
67                 ret_hu_conv.ptrs_to.add(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(UInt5 version, byte[] program) {
75                 long ret = bindings.Fallback_seg_wit_program(version.getVal(), program);
76                 if (ret >= 0 && ret <= 4096) { return null; }
77                 Fallback ret_hu_conv = Fallback.constr_from_ptr(ret);
78                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
79                 return ret_hu_conv;
80         }
81
82         /**
83          * Utility method to constructs a new PubKeyHash-variant Fallback
84          */
85         public static Fallback pub_key_hash(byte[] a) {
86                 long ret = bindings.Fallback_pub_key_hash(a);
87                 if (ret >= 0 && ret <= 4096) { return null; }
88                 Fallback ret_hu_conv = Fallback.constr_from_ptr(ret);
89                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
90                 return ret_hu_conv;
91         }
92
93         /**
94          * Utility method to constructs a new ScriptHash-variant Fallback
95          */
96         public static Fallback script_hash(byte[] a) {
97                 long ret = bindings.Fallback_script_hash(a);
98                 if (ret >= 0 && ret <= 4096) { return null; }
99                 Fallback ret_hu_conv = Fallback.constr_from_ptr(ret);
100                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
101                 return ret_hu_conv;
102         }
103
104         /**
105          * Checks if two Fallbacks contain equal inner contents.
106          */
107         public long hash() {
108                 long ret = bindings.Fallback_hash(this.ptr);
109                 return ret;
110         }
111
112         /**
113          * Checks if two Fallbacks contain equal inner contents.
114          * This ignores pointers and is_owned flags and looks at the values in fields.
115          */
116         public boolean eq(Fallback b) {
117                 boolean ret = bindings.Fallback_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
118                 return ret;
119         }
120
121 }