Package org.ldk.structs
Class Invoice
- java.lang.Object
-
- org.ldk.structs.Invoice
-
public class Invoice extends Object
Represents a syntactically and semantically correct lightning BOLT11 invoice. There are three ways to construct an `Invoice`: 1. using `InvoiceBuilder` 2. using `Invoice::from_signed(SignedRawInvoice)` 3. using `str::parse::(&str)`
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Option_u64Z
amount_pico_btc()
Returns the amount if specified in the invoice as pico. Result_NoneSemanticErrorZ
check_signature()
Check that the invoice is signed correctly and that key recovery worksInvoice
clone()
Creates a copy of the InvoiceCurrency
currency()
Returns the currency for which the invoice was issuedboolean
eq(Invoice b)
Checks if two Invoices contain equal inner contents.long
expiry_time()
Returns the invoice's expiry time, if present, otherwise [`DEFAULT_EXPIRY_TIME`].InvoiceFeatures
features()
Get the invoice features if they were included in the invoice Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent Noneprotected void
finalize()
static Result_InvoiceSemanticErrorZ
from_signed(SignedRawInvoice signed_invoice)
Constructs an `Invoice` from a `SignedRawInvoice` by checking all its invariants.static Result_InvoiceNoneZ
from_str(String s)
Read a Invoice object from a stringSignedRawInvoice
into_signed_raw()
Transform the `Invoice` into it's unchecked versionlong
min_final_cltv_expiry()
Returns the invoice's `min_final_cltv_expiry` time, if present, otherwise [`DEFAULT_MIN_FINAL_CLTV_EXPIRY`].byte[]
payee_pub_key()
Get the payee's public key if one was included in the invoice Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent Nonebyte[]
payment_hash()
Returns the hash to which we will receive the preimage on completion of the paymentbyte[]
payment_secret()
Get the payment secret if one was included in the invoice Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent NonePrivateRoute[]
private_routes()
Returns a list of all routes included in the invoicebyte[]
recover_payee_pub_key()
Recover the payee's public key (only to be used if none was included in the invoice)RouteHint[]
route_hints()
Returns a list of all routes included in the invoice as the underlying hintslong
timestamp()
Returns the `Invoice`'s timestamp (should equal it's creation time)String
to_str()
Get the string representation of a Invoice object
-
-
-
Method Detail
-
finalize
protected void finalize() throws Throwable
-
eq
public boolean eq(Invoice b)
Checks if two Invoices contain equal inner contents. This ignores pointers and is_owned flags and looks at the values in fields. Two objects with NULL inner values will be considered "equal" here.
-
into_signed_raw
public SignedRawInvoice into_signed_raw()
Transform the `Invoice` into it's unchecked version
-
check_signature
public Result_NoneSemanticErrorZ check_signature()
Check that the invoice is signed correctly and that key recovery works
-
from_signed
public static Result_InvoiceSemanticErrorZ from_signed(SignedRawInvoice signed_invoice)
Constructs an `Invoice` from a `SignedRawInvoice` by checking all its invariants. ``` use lightning_invoice::*; let invoice = \"lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdp\\ \tl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq8rkx3yf5tcsyz3d7\\ \t3gafnh3cax9rn449d9p5uxz9ezhhypd0elx87sjle52x86fux2ypatgddc6k63n7erqz25le42c4u4ec\\ \tky03ylcqca784w\"; let signed = invoice.parse::().unwrap(); assert!(Invoice::from_signed(signed).is_ok()); ```
-
timestamp
public long timestamp()
Returns the `Invoice`'s timestamp (should equal it's creation time)
-
payment_hash
public byte[] payment_hash()
Returns the hash to which we will receive the preimage on completion of the payment
-
payee_pub_key
@Nullable public byte[] payee_pub_key()
Get the payee's public key if one was included in the invoice Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
-
payment_secret
@Nullable public byte[] payment_secret()
Get the payment secret if one was included in the invoice Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
-
features
@Nullable public InvoiceFeatures features()
Get the invoice features if they were included in the invoice Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
-
recover_payee_pub_key
public byte[] recover_payee_pub_key()
Recover the payee's public key (only to be used if none was included in the invoice)
-
expiry_time
public long expiry_time()
Returns the invoice's expiry time, if present, otherwise [`DEFAULT_EXPIRY_TIME`].
-
min_final_cltv_expiry
public long min_final_cltv_expiry()
Returns the invoice's `min_final_cltv_expiry` time, if present, otherwise [`DEFAULT_MIN_FINAL_CLTV_EXPIRY`].
-
private_routes
public PrivateRoute[] private_routes()
Returns a list of all routes included in the invoice
-
route_hints
public RouteHint[] route_hints()
Returns a list of all routes included in the invoice as the underlying hints
-
currency
public Currency currency()
Returns the currency for which the invoice was issued
-
amount_pico_btc
public Option_u64Z amount_pico_btc()
Returns the amount if specified in the invoice as pico.
-
from_str
public static Result_InvoiceNoneZ from_str(String s)
Read a Invoice object from a string
-
to_str
public String to_str()
Get the string representation of a Invoice object
-
-