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 [`RawBolt11Invoice`] 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 [`RawBolt11Invoice`].
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 {
24 if (ptr != 0) { bindings.SignedRawBolt11Invoice_free(ptr); }
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.
32 public boolean eq(org.ldk.structs.SignedRawBolt11Invoice b) {
33 boolean ret = bindings.SignedRawBolt11Invoice_eq(this.ptr, 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 SignedRawBolt11Invoice)) return false;
42 return this.eq((SignedRawBolt11Invoice)o);
45 long ret = bindings.SignedRawBolt11Invoice_clone_ptr(this.ptr);
46 Reference.reachabilityFence(this);
51 * Creates a copy of the SignedRawBolt11Invoice
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); };
63 * Generates a non-cryptographic 64-bit hash of the SignedRawBolt11Invoice.
66 long ret = bindings.SignedRawBolt11Invoice_hash(this.ptr);
67 Reference.reachabilityFence(this);
71 @Override public int hashCode() {
72 return (int)this.hash();
75 * Disassembles the `SignedRawBolt11Invoice` into its three parts:
77 * 2. hash of the raw invoice
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); };
91 * The [`RawBolt11Invoice`] which was signed.
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); };
103 * The hash of the [`RawBolt11Invoice`] that was signed.
105 public byte[] signable_hash() {
106 byte[] ret = bindings.SignedRawBolt11Invoice_signable_hash(this.ptr);
107 Reference.reachabilityFence(this);
112 * Signature for the invoice.
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); };
124 * Recovers the public key used for signing the invoice from the recoverable signature.
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);
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.SignedRawBolt11Invoice_check_signature(this.ptr);
140 Reference.reachabilityFence(this);
145 * Read a SignedRawBolt11Invoice object from a string
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);
156 * Get the string representation of a SignedRawBolt11Invoice object
158 public String to_str() {
159 String ret = bindings.SignedRawBolt11Invoice_to_str(this.ptr);
160 Reference.reachabilityFence(this);