1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * Represents a signed `RawInvoice` with cached hash. The signature is not checked and may be
15 * The hash has to be either from the deserialized invoice or from the serialized `raw_invoice`.
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 {
23 if (ptr != 0) { bindings.SignedRawInvoice_free(ptr); }
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.
31 public boolean eq(SignedRawInvoice b) {
32 boolean ret = bindings.SignedRawInvoice_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
38 * Creates a copy of the SignedRawInvoice
40 public SignedRawInvoice clone() {
41 long ret = bindings.SignedRawInvoice_clone(this.ptr);
42 if (ret < 1024) { return null; }
43 SignedRawInvoice ret_hu_conv = new SignedRawInvoice(null, ret);
44 ret_hu_conv.ptrs_to.add(this);
49 * Disassembles the `SignedRawInvoice` into its three parts:
51 * 2. hash of the raw invoice
54 public ThreeTuple_RawInvoice_u832InvoiceSignatureZ into_parts() {
55 long ret = bindings.SignedRawInvoice_into_parts(this.ptr);
56 if (ret < 1024) { return null; }
57 ThreeTuple_RawInvoice_u832InvoiceSignatureZ ret_hu_conv = new ThreeTuple_RawInvoice_u832InvoiceSignatureZ(null, ret);
58 ret_hu_conv.ptrs_to.add(this);
64 * The `RawInvoice` which was signed.
66 public RawInvoice raw_invoice() {
67 long ret = bindings.SignedRawInvoice_raw_invoice(this.ptr);
68 if (ret < 1024) { return null; }
69 RawInvoice ret_hu_conv = new RawInvoice(null, ret);
70 ret_hu_conv.ptrs_to.add(this);
75 * The hash of the `RawInvoice` that was signed.
77 public byte[] hash() {
78 byte[] ret = bindings.SignedRawInvoice_hash(this.ptr);
83 * InvoiceSignature for the invoice.
85 public InvoiceSignature signature() {
86 long ret = bindings.SignedRawInvoice_signature(this.ptr);
87 if (ret < 1024) { return null; }
88 InvoiceSignature ret_hu_conv = new InvoiceSignature(null, ret);
89 ret_hu_conv.ptrs_to.add(this);
94 * Recovers the public key used for signing the invoice from the recoverable signature.
96 public Result_PayeePubKeyErrorZ recover_payee_pub_key() {
97 long ret = bindings.SignedRawInvoice_recover_payee_pub_key(this.ptr);
98 if (ret < 1024) { return null; }
99 Result_PayeePubKeyErrorZ ret_hu_conv = Result_PayeePubKeyErrorZ.constr_from_ptr(ret);
104 * Checks if the signature is valid for the included payee public key or if none exists if it's
105 * valid for the recovered signature (which should always be true?).
107 public boolean check_signature() {
108 boolean ret = bindings.SignedRawInvoice_check_signature(this.ptr);
113 * Read a SignedRawInvoice object from a string
115 public static Result_SignedRawInvoiceNoneZ from_str(java.lang.String s) {
116 long ret = bindings.SignedRawInvoice_from_str(s);
117 if (ret < 1024) { return null; }
118 Result_SignedRawInvoiceNoneZ ret_hu_conv = Result_SignedRawInvoiceNoneZ.constr_from_ptr(ret);
123 * Get the string representation of a SignedRawInvoice object
125 public String to_str() {
126 String ret = bindings.SignedRawInvoice_to_str(this.ptr);