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