[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / SignedRawBolt11Invoice.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 [`RawBolt11Invoice`] 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 [`RawBolt11Invoice`].
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class SignedRawBolt11Invoice extends CommonBase {
20         SignedRawBolt11Invoice(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.SignedRawBolt11Invoice_free(ptr); }
25         }
26
27         /**
28          * Checks if two SignedRawBolt11Invoices 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(org.ldk.structs.SignedRawBolt11Invoice b) {
33                 boolean ret = bindings.SignedRawBolt11Invoice_eq(this.ptr, b == null ? 0 : b.ptr);
34                 Reference.reachabilityFence(this);
35                 Reference.reachabilityFence(b);
36                 if (this != null) { this.ptrs_to.add(b); };
37                 return ret;
38         }
39
40         @Override public boolean equals(Object o) {
41                 if (!(o instanceof SignedRawBolt11Invoice)) return false;
42                 return this.eq((SignedRawBolt11Invoice)o);
43         }
44         long clone_ptr() {
45                 long ret = bindings.SignedRawBolt11Invoice_clone_ptr(this.ptr);
46                 Reference.reachabilityFence(this);
47                 return ret;
48         }
49
50         /**
51          * Creates a copy of the SignedRawBolt11Invoice
52          */
53         public SignedRawBolt11Invoice clone() {
54                 long ret = bindings.SignedRawBolt11Invoice_clone(this.ptr);
55                 Reference.reachabilityFence(this);
56                 if (ret >= 0 && ret <= 4096) { return null; }
57                 org.ldk.structs.SignedRawBolt11Invoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.SignedRawBolt11Invoice(null, ret); }
58                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
59                 return ret_hu_conv;
60         }
61
62         /**
63          * Generates a non-cryptographic 64-bit hash of the SignedRawBolt11Invoice.
64          */
65         public long hash() {
66                 long ret = bindings.SignedRawBolt11Invoice_hash(this.ptr);
67                 Reference.reachabilityFence(this);
68                 return ret;
69         }
70
71         @Override public int hashCode() {
72                 return (int)this.hash();
73         }
74         /**
75          * Disassembles the `SignedRawBolt11Invoice` into its three parts:
76          * 1. raw invoice
77          * 2. hash of the raw invoice
78          * 3. signature
79          */
80         public ThreeTuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ into_parts() {
81                 long ret = bindings.SignedRawBolt11Invoice_into_parts(this.ptr);
82                 Reference.reachabilityFence(this);
83                 if (ret >= 0 && ret <= 4096) { return null; }
84                 ThreeTuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ ret_hu_conv = new ThreeTuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ(null, ret);
85                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
86                 if (this != null) { this.ptrs_to.add(this); };
87                 return ret_hu_conv;
88         }
89
90         /**
91          * The [`RawBolt11Invoice`] which was signed.
92          */
93         public RawBolt11Invoice raw_invoice() {
94                 long ret = bindings.SignedRawBolt11Invoice_raw_invoice(this.ptr);
95                 Reference.reachabilityFence(this);
96                 if (ret >= 0 && ret <= 4096) { return null; }
97                 org.ldk.structs.RawBolt11Invoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RawBolt11Invoice(null, ret); }
98                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
99                 return ret_hu_conv;
100         }
101
102         /**
103          * The hash of the [`RawBolt11Invoice`] that was signed.
104          */
105         public byte[] signable_hash() {
106                 byte[] ret = bindings.SignedRawBolt11Invoice_signable_hash(this.ptr);
107                 Reference.reachabilityFence(this);
108                 return ret;
109         }
110
111         /**
112          * Signature for the invoice.
113          */
114         public Bolt11InvoiceSignature signature() {
115                 long ret = bindings.SignedRawBolt11Invoice_signature(this.ptr);
116                 Reference.reachabilityFence(this);
117                 if (ret >= 0 && ret <= 4096) { return null; }
118                 org.ldk.structs.Bolt11InvoiceSignature ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt11InvoiceSignature(null, ret); }
119                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
120                 return ret_hu_conv;
121         }
122
123         /**
124          * Recovers the public key used for signing the invoice from the recoverable signature.
125          */
126         public Result_PayeePubKeySecp256k1ErrorZ recover_payee_pub_key() {
127                 long ret = bindings.SignedRawBolt11Invoice_recover_payee_pub_key(this.ptr);
128                 Reference.reachabilityFence(this);
129                 if (ret >= 0 && ret <= 4096) { return null; }
130                 Result_PayeePubKeySecp256k1ErrorZ ret_hu_conv = Result_PayeePubKeySecp256k1ErrorZ.constr_from_ptr(ret);
131                 return ret_hu_conv;
132         }
133
134         /**
135          * Checks if the signature is valid for the included payee public key or if none exists if it's
136          * valid for the recovered signature (which should always be true?).
137          */
138         public boolean check_signature() {
139                 boolean ret = bindings.SignedRawBolt11Invoice_check_signature(this.ptr);
140                 Reference.reachabilityFence(this);
141                 return ret;
142         }
143
144         /**
145          * Read a SignedRawBolt11Invoice object from a string
146          */
147         public static Result_SignedRawBolt11InvoiceBolt11ParseErrorZ from_str(java.lang.String s) {
148                 long ret = bindings.SignedRawBolt11Invoice_from_str(s);
149                 Reference.reachabilityFence(s);
150                 if (ret >= 0 && ret <= 4096) { return null; }
151                 Result_SignedRawBolt11InvoiceBolt11ParseErrorZ ret_hu_conv = Result_SignedRawBolt11InvoiceBolt11ParseErrorZ.constr_from_ptr(ret);
152                 return ret_hu_conv;
153         }
154
155         /**
156          * Get the string representation of a SignedRawBolt11Invoice object
157          */
158         public String to_str() {
159                 String ret = bindings.SignedRawBolt11Invoice_to_str(this.ptr);
160                 Reference.reachabilityFence(this);
161                 return ret;
162         }
163
164 }