1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
10 * Represents a signed `RawInvoice` with cached hash. The signature is not checked and may be
14 * The hash has to be either from the deserialized invoice or from the serialized `raw_invoice`.
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class SignedRawInvoice extends CommonBase {
18 SignedRawInvoice(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.SignedRawInvoice_free(ptr); }
26 * Checks if two SignedRawInvoices contain equal inner contents.
27 * This ignores pointers and is_owned flags and looks at the values in fields.
28 * Two objects with NULL inner values will be considered "equal" here.
30 public boolean eq(SignedRawInvoice b) {
31 boolean ret = bindings.SignedRawInvoice_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
37 * Creates a copy of the SignedRawInvoice
39 public SignedRawInvoice clone() {
40 long ret = bindings.SignedRawInvoice_clone(this.ptr);
41 SignedRawInvoice ret_hu_conv = new SignedRawInvoice(null, ret);
42 ret_hu_conv.ptrs_to.add(this);
47 * Disassembles the `SignedRawInvoice` into its three parts:
49 * 2. hash of the raw invoice
52 public ThreeTuple<RawInvoice, byte[], InvoiceSignature> into_parts() {
53 long ret = bindings.SignedRawInvoice_into_parts(this.ptr);
54 long ret_a = bindings.LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(ret);
55 RawInvoice ret_a_hu_conv = new RawInvoice(null, ret_a);
56 ret_a_hu_conv.ptrs_to.add(this);;
57 byte[] ret_b = bindings.LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(ret);
58 long ret_c = bindings.LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(ret);
59 InvoiceSignature ret_c_hu_conv = new InvoiceSignature(null, ret_c);
60 ret_c_hu_conv.ptrs_to.add(this);;
61 ThreeTuple<RawInvoice, byte[], InvoiceSignature> ret_conv = new ThreeTuple<RawInvoice, byte[], InvoiceSignature>(ret_a_hu_conv, ret_b, ret_c_hu_conv, () -> {
62 bindings.C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(ret);
64 ret_a_hu_conv.ptrs_to.add(ret_conv);
65 ret_c_hu_conv.ptrs_to.add(ret_conv);
66 this.ptrs_to.add(this);
71 * The `RawInvoice` which was signed.
73 public RawInvoice raw_invoice() {
74 long ret = bindings.SignedRawInvoice_raw_invoice(this.ptr);
75 RawInvoice ret_hu_conv = new RawInvoice(null, ret);
76 ret_hu_conv.ptrs_to.add(this);
81 * The hash of the `RawInvoice` that was signed.
83 public byte[] hash() {
84 byte[] ret = bindings.SignedRawInvoice_hash(this.ptr);
89 * InvoiceSignature for the invoice.
91 public InvoiceSignature signature() {
92 long ret = bindings.SignedRawInvoice_signature(this.ptr);
93 InvoiceSignature ret_hu_conv = new InvoiceSignature(null, ret);
94 ret_hu_conv.ptrs_to.add(this);
99 * Recovers the public key used for signing the invoice from the recoverable signature.
101 public Result_PayeePubKeyErrorZ recover_payee_pub_key() {
102 long ret = bindings.SignedRawInvoice_recover_payee_pub_key(this.ptr);
103 Result_PayeePubKeyErrorZ ret_hu_conv = Result_PayeePubKeyErrorZ.constr_from_ptr(ret);
108 * Checks if the signature is valid for the included payee public key or if none exists if it's
109 * valid for the recovered signature (which should always be true?).
111 public boolean check_signature() {
112 boolean ret = bindings.SignedRawInvoice_check_signature(this.ptr);
117 * Read a SignedRawInvoice object from a string
119 public static Result_SignedRawInvoiceNoneZ from_str(String s) {
120 long ret = bindings.SignedRawInvoice_from_str(s);
121 Result_SignedRawInvoiceNoneZ ret_hu_conv = Result_SignedRawInvoiceNoneZ.constr_from_ptr(ret);
126 * Get the string representation of a SignedRawInvoice object
128 public String to_str() {
129 String ret = bindings.SignedRawInvoice_to_str(this.ptr);