Merge pull request #56 from TheBlueMatt/main
[ldk-java] / src / main / java / org / ldk / structs / SignOrCreationError.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  * When signing using a fallible method either an user-supplied `SignError` or a `CreationError`
12  * may occur.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class SignOrCreationError extends CommonBase {
16         private SignOrCreationError(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.SignOrCreationError_free(ptr); }
21         }
22         static SignOrCreationError constr_from_ptr(long ptr) {
23                 bindings.LDKSignOrCreationError raw_val = bindings.LDKSignOrCreationError_ref_from_ptr(ptr);
24                 if (raw_val.getClass() == bindings.LDKSignOrCreationError.SignError.class) {
25                         return new SignError(ptr, (bindings.LDKSignOrCreationError.SignError)raw_val);
26                 }
27                 if (raw_val.getClass() == bindings.LDKSignOrCreationError.CreationError.class) {
28                         return new CreationError(ptr, (bindings.LDKSignOrCreationError.CreationError)raw_val);
29                 }
30                 assert false; return null; // Unreachable without extending the (internal) bindings interface
31         }
32
33         /**
34          * An error occurred during signing
35          */
36         public final static class SignError extends SignOrCreationError {
37                 private SignError(long ptr, bindings.LDKSignOrCreationError.SignError obj) {
38                         super(null, ptr);
39                 }
40         }
41         /**
42          * An error occurred while building the transaction
43          */
44         public final static class CreationError extends SignOrCreationError {
45                 public final org.ldk.enums.CreationError creation_error;
46                 private CreationError(long ptr, bindings.LDKSignOrCreationError.CreationError obj) {
47                         super(null, ptr);
48                         this.creation_error = obj.creation_error;
49                 }
50         }
51         long clone_ptr() {
52                 long ret = bindings.SignOrCreationError_clone_ptr(this.ptr);
53                 return ret;
54         }
55
56         /**
57          * Creates a copy of the SignOrCreationError
58          */
59         public SignOrCreationError clone() {
60                 long ret = bindings.SignOrCreationError_clone(this.ptr);
61                 if (ret >= 0 && ret <= 4096) { return null; }
62                 SignOrCreationError ret_hu_conv = SignOrCreationError.constr_from_ptr(ret);
63                 ret_hu_conv.ptrs_to.add(this);
64                 return ret_hu_conv;
65         }
66
67         /**
68          * Utility method to constructs a new SignError-variant SignOrCreationError
69          */
70         public static SignOrCreationError sign_error() {
71                 long ret = bindings.SignOrCreationError_sign_error();
72                 if (ret >= 0 && ret <= 4096) { return null; }
73                 SignOrCreationError ret_hu_conv = SignOrCreationError.constr_from_ptr(ret);
74                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
75                 return ret_hu_conv;
76         }
77
78         /**
79          * Utility method to constructs a new CreationError-variant SignOrCreationError
80          */
81         public static SignOrCreationError creation_error(org.ldk.enums.CreationError a) {
82                 long ret = bindings.SignOrCreationError_creation_error(a);
83                 if (ret >= 0 && ret <= 4096) { return null; }
84                 SignOrCreationError ret_hu_conv = SignOrCreationError.constr_from_ptr(ret);
85                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
86                 return ret_hu_conv;
87         }
88
89         /**
90          * Checks if two SignOrCreationErrors contain equal inner contents.
91          * This ignores pointers and is_owned flags and looks at the values in fields.
92          */
93         public boolean eq(SignOrCreationError b) {
94                 boolean ret = bindings.SignOrCreationError_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
95                 return ret;
96         }
97
98         /**
99          * Get the string representation of a SignOrCreationError object
100          */
101         public String to_str() {
102                 String ret = bindings.SignOrCreationError_to_str(this.ptr);
103                 return ret;
104         }
105
106 }