[Java] Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / SignedRawInvoice.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 java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Represents a signed `RawInvoice` with cached hash. The signature is not checked and may be
13  * invalid.
14  * 
15  * # Invariants
16  * The hash has to be either from the deserialized invoice or from the serialized `raw_invoice`.
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class SignedRawInvoice extends CommonBase {
20         SignedRawInvoice(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.SignedRawInvoice_free(ptr); }
25         }
26
27         /**
28          * Checks if two SignedRawInvoices contain equal inner contents.
29          * This ignores pointers and is_owned flags and looks at the values in fields.
30          * Two objects with NULL inner values will be considered "equal" here.
31          */
32         public boolean eq(SignedRawInvoice b) {
33                 boolean ret = bindings.SignedRawInvoice_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
34                 Reference.reachabilityFence(this);
35                 Reference.reachabilityFence(b);
36                 this.ptrs_to.add(b);
37                 return ret;
38         }
39
40         @Override public boolean equals(Object o) {
41                 if (!(o instanceof SignedRawInvoice)) return false;
42                 return this.eq((SignedRawInvoice)o);
43         }
44         long clone_ptr() {
45                 long ret = bindings.SignedRawInvoice_clone_ptr(this.ptr);
46                 Reference.reachabilityFence(this);
47                 return ret;
48         }
49
50         /**
51          * Creates a copy of the SignedRawInvoice
52          */
53         public SignedRawInvoice clone() {
54                 long ret = bindings.SignedRawInvoice_clone(this.ptr);
55                 Reference.reachabilityFence(this);
56                 if (ret >= 0 && ret <= 4096) { return null; }
57                 SignedRawInvoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new SignedRawInvoice(null, ret); }
58                 ret_hu_conv.ptrs_to.add(this);
59                 return ret_hu_conv;
60         }
61
62         /**
63          * Disassembles the `SignedRawInvoice` into its three parts:
64          * 1. raw invoice
65          * 2. hash of the raw invoice
66          * 3. signature
67          */
68         public ThreeTuple_RawInvoice_u832InvoiceSignatureZ into_parts() {
69                 long ret = bindings.SignedRawInvoice_into_parts(this.ptr);
70                 Reference.reachabilityFence(this);
71                 if (ret >= 0 && ret <= 4096) { return null; }
72                 ThreeTuple_RawInvoice_u832InvoiceSignatureZ ret_hu_conv = new ThreeTuple_RawInvoice_u832InvoiceSignatureZ(null, ret);
73                 ret_hu_conv.ptrs_to.add(this);
74                 ;
75                 return ret_hu_conv;
76         }
77
78         /**
79          * The `RawInvoice` which was signed.
80          */
81         public RawInvoice raw_invoice() {
82                 long ret = bindings.SignedRawInvoice_raw_invoice(this.ptr);
83                 Reference.reachabilityFence(this);
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 RawInvoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RawInvoice(null, ret); }
86                 ret_hu_conv.ptrs_to.add(this);
87                 return ret_hu_conv;
88         }
89
90         /**
91          * The hash of the `RawInvoice` that was signed.
92          */
93         public byte[] hash() {
94                 byte[] ret = bindings.SignedRawInvoice_hash(this.ptr);
95                 Reference.reachabilityFence(this);
96                 return ret;
97         }
98
99         /**
100          * InvoiceSignature for the invoice.
101          */
102         public InvoiceSignature signature() {
103                 long ret = bindings.SignedRawInvoice_signature(this.ptr);
104                 Reference.reachabilityFence(this);
105                 if (ret >= 0 && ret <= 4096) { return null; }
106                 InvoiceSignature ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InvoiceSignature(null, ret); }
107                 ret_hu_conv.ptrs_to.add(this);
108                 return ret_hu_conv;
109         }
110
111         /**
112          * Recovers the public key used for signing the invoice from the recoverable signature.
113          */
114         public Result_PayeePubKeyErrorZ recover_payee_pub_key() {
115                 long ret = bindings.SignedRawInvoice_recover_payee_pub_key(this.ptr);
116                 Reference.reachabilityFence(this);
117                 if (ret >= 0 && ret <= 4096) { return null; }
118                 Result_PayeePubKeyErrorZ ret_hu_conv = Result_PayeePubKeyErrorZ.constr_from_ptr(ret);
119                 return ret_hu_conv;
120         }
121
122         /**
123          * Checks if the signature is valid for the included payee public key or if none exists if it's
124          * valid for the recovered signature (which should always be true?).
125          */
126         public boolean check_signature() {
127                 boolean ret = bindings.SignedRawInvoice_check_signature(this.ptr);
128                 Reference.reachabilityFence(this);
129                 return ret;
130         }
131
132         /**
133          * Read a SignedRawInvoice object from a string
134          */
135         public static Result_SignedRawInvoiceParseErrorZ from_str(java.lang.String s) {
136                 long ret = bindings.SignedRawInvoice_from_str(s);
137                 Reference.reachabilityFence(s);
138                 if (ret >= 0 && ret <= 4096) { return null; }
139                 Result_SignedRawInvoiceParseErrorZ ret_hu_conv = Result_SignedRawInvoiceParseErrorZ.constr_from_ptr(ret);
140                 return ret_hu_conv;
141         }
142
143         /**
144          * Get the string representation of a SignedRawInvoice object
145          */
146         public String to_str() {
147                 String ret = bindings.SignedRawInvoice_to_str(this.ptr);
148                 Reference.reachabilityFence(this);
149                 return ret;
150         }
151
152 }