1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Represents a signed `RawInvoice` with cached hash. The signature is not checked and may be
16 * The hash has to be either from the deserialized invoice or from the serialized `raw_invoice`.
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 {
24 if (ptr != 0) { bindings.SignedRawInvoice_free(ptr); }
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.
32 public boolean eq(org.ldk.structs.SignedRawInvoice b) {
33 boolean ret = bindings.SignedRawInvoice_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); };
40 @Override public boolean equals(Object o) {
41 if (!(o instanceof SignedRawInvoice)) return false;
42 return this.eq((SignedRawInvoice)o);
45 long ret = bindings.SignedRawInvoice_clone_ptr(this.ptr);
46 Reference.reachabilityFence(this);
51 * Creates a copy of the SignedRawInvoice
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 org.ldk.structs.SignedRawInvoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.SignedRawInvoice(null, ret); }
58 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
63 * Checks if two SignedRawInvoices contain equal inner contents.
66 long ret = bindings.SignedRawInvoice_hash(this.ptr);
67 Reference.reachabilityFence(this);
71 @Override public int hashCode() {
72 return (int)this.hash();
75 * Disassembles the `SignedRawInvoice` into its three parts:
77 * 2. hash of the raw invoice
80 public ThreeTuple_RawInvoice_u832InvoiceSignatureZ into_parts() {
81 long ret = bindings.SignedRawInvoice_into_parts(this.ptr);
82 Reference.reachabilityFence(this);
83 if (ret >= 0 && ret <= 4096) { return null; }
84 ThreeTuple_RawInvoice_u832InvoiceSignatureZ ret_hu_conv = new ThreeTuple_RawInvoice_u832InvoiceSignatureZ(null, ret);
85 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
86 if (this != null) { this.ptrs_to.add(this); };
91 * The `RawInvoice` which was signed.
93 public RawInvoice raw_invoice() {
94 long ret = bindings.SignedRawInvoice_raw_invoice(this.ptr);
95 Reference.reachabilityFence(this);
96 if (ret >= 0 && ret <= 4096) { return null; }
97 org.ldk.structs.RawInvoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RawInvoice(null, ret); }
98 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
103 * The hash of the `RawInvoice` that was signed.
105 public byte[] signable_hash() {
106 byte[] ret = bindings.SignedRawInvoice_signable_hash(this.ptr);
107 Reference.reachabilityFence(this);
112 * InvoiceSignature for the invoice.
114 public InvoiceSignature signature() {
115 long ret = bindings.SignedRawInvoice_signature(this.ptr);
116 Reference.reachabilityFence(this);
117 if (ret >= 0 && ret <= 4096) { return null; }
118 org.ldk.structs.InvoiceSignature ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceSignature(null, ret); }
119 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
124 * Recovers the public key used for signing the invoice from the recoverable signature.
126 public Result_PayeePubKeyErrorZ recover_payee_pub_key() {
127 long ret = bindings.SignedRawInvoice_recover_payee_pub_key(this.ptr);
128 Reference.reachabilityFence(this);
129 if (ret >= 0 && ret <= 4096) { return null; }
130 Result_PayeePubKeyErrorZ ret_hu_conv = Result_PayeePubKeyErrorZ.constr_from_ptr(ret);
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?).
138 public boolean check_signature() {
139 boolean ret = bindings.SignedRawInvoice_check_signature(this.ptr);
140 Reference.reachabilityFence(this);
145 * Read a SignedRawInvoice object from a string
147 public static Result_SignedRawInvoiceParseErrorZ from_str(java.lang.String s) {
148 long ret = bindings.SignedRawInvoice_from_str(s);
149 Reference.reachabilityFence(s);
150 if (ret >= 0 && ret <= 4096) { return null; }
151 Result_SignedRawInvoiceParseErrorZ ret_hu_conv = Result_SignedRawInvoiceParseErrorZ.constr_from_ptr(ret);
156 * Get the string representation of a SignedRawInvoice object
158 public String to_str() {
159 String ret = bindings.SignedRawInvoice_to_str(this.ptr);
160 Reference.reachabilityFence(this);