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`] 3. using `str::parse::(&str)` (see [`Invoice::from_str`]) [`Invoice::from_str`]: crate::Invoice#impl-FromStr
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Option_u64Z
amount_milli_satoshis()
Returns the amount if specified in the invoice as millisatoshis.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 issuedlong
duration_since_epoch()
Returns the `Invoice`'s timestamp as a duration since the Unix epochlong
duration_until_expiry()
Returns the Duration remaining until the invoice expires.boolean
eq(Invoice b)
Checks if two Invoices contain equal inner contents.boolean
equals(Object o)
long
expiration_remaining_from_epoch(long time)
Returns the Duration remaining until the invoice expires given the current time.Option_DurationZ
expires_at()
Returns the Duration since the Unix epoch at which the invoice expires.long
expiry_time()
Returns the invoice's expiry time, if present, otherwise [`DEFAULT_EXPIRY_TIME`].String[]
fallback_addresses()
Returns a list of all fallback addresses as [`Address`]esInvoiceFeatures
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_InvoiceParseOrSemanticErrorZ
from_str(String s)
Read a Invoice object from a stringlong
hash()
Generates a non-cryptographic 64-bit hash of the Invoice.int
hashCode()
SignedRawInvoice
into_signed_raw()
Transform the `Invoice` into it's unchecked versionboolean
is_expired()
Returns whether the invoice has expired.long
min_final_cltv_expiry_delta()
Returns the invoice's `min_final_cltv_expiry_delta` time, if present, otherwise [`DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA`].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 paymentOption_CVec_u8ZZ
payment_metadata()
Get the payment metadata blob if one was included in the invoicebyte[]
payment_secret()
Get the payment secret if one was included in the invoicePrivateRoute[]
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 hintsbyte[]
signable_hash()
The hash of the [`RawInvoice`] that was signed.long
timestamp()
Returns the `Invoice`'s timestamp (should equal its creation time)String
to_str()
Get the string representation of a Invoice objectboolean
would_expire(long at_time)
Returns whether the expiry time would pass at the given point in time.
-
-
-
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.
-
hash
public long hash()
Generates a non-cryptographic 64-bit hash of the Invoice.
-
signable_hash
public byte[] signable_hash()
The hash of the [`RawInvoice`] that was signed.
-
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 = \"lnbc100p1psj9jhxdqud3jxktt5w46x7unfv9kz6mn0v3jsnp4q0d3p2sfluzdx45tqcs\\ h2pu5qc7lgq0xs578ngs6s0s68ua4h7cvspp5q6rmq35js88zp5dvwrv9m459tnk2zunwj5jalqtyxqulh0l\\ 5gflssp5nf55ny5gcrfl30xuhzj3nphgj27rstekmr9fw3ny5989s300gyus9qyysgqcqpcrzjqw2sxwe993\\ h5pcm4dxzpvttgza8zhkqxpgffcrf5v25nwpr3cmfg7z54kuqq8rgqqqqqqqq2qqqqq9qq9qrzjqd0ylaqcl\\ j9424x9m8h2vcukcgnm6s56xfgu3j78zyqzhgs4hlpzvznlugqq9vsqqqqqqqlgqqqqqeqq9qrzjqwldmj9d\\ ha74df76zhx6l9we0vjdquygcdt3kssupehe64g6yyp5yz5rhuqqwccqqyqqqqlgqqqqjcqq9qrzjqf9e58a\\ guqr0rcun0ajlvmzq3ek63cw2w282gv3z5uupmuwvgjtq2z55qsqqg6qqqyqqqrtnqqqzq3cqygrzjqvphms\\ ywntrrhqjcraumvc4y6r8v4z5v593trte429v4hredj7ms5z52usqq9ngqqqqqqqlgqqqqqqgq9qrzjq2v0v\\ p62g49p7569ev48cmulecsxe59lvaw3wlxm7r982zxa9zzj7z5l0cqqxusqqyqqqqlgqqqqqzsqygarl9fh3\\ 8s0gyuxjjgux34w75dnc6xp2l35j7es3jd4ugt3lu0xzre26yg5m7ke54n2d5sym4xcmxtl8238xxvw5h5h5\\ j5r6drg6k6zcqj0fcwg\"; let signed = invoice.parse::().unwrap(); assert!(Invoice::from_signed(signed).is_ok()); ```
-
timestamp
public long timestamp()
Returns the `Invoice`'s timestamp (should equal its creation time)
-
duration_since_epoch
public long duration_since_epoch()
Returns the `Invoice`'s timestamp as a duration since the Unix epoch
-
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
public byte[] payment_secret()
Get the payment secret if one was included in the invoice
-
payment_metadata
public Option_CVec_u8ZZ payment_metadata()
Get the payment metadata blob if one was included in the invoice
-
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)
-
expires_at
public Option_DurationZ expires_at()
Returns the Duration since the Unix epoch at which the invoice expires. Returning None if overflow occurred.
-
expiry_time
public long expiry_time()
Returns the invoice's expiry time, if present, otherwise [`DEFAULT_EXPIRY_TIME`].
-
is_expired
public boolean is_expired()
Returns whether the invoice has expired.
-
duration_until_expiry
public long duration_until_expiry()
Returns the Duration remaining until the invoice expires.
-
expiration_remaining_from_epoch
public long expiration_remaining_from_epoch(long time)
Returns the Duration remaining until the invoice expires given the current time. `time` is the timestamp as a duration since the Unix epoch.
-
would_expire
public boolean would_expire(long at_time)
Returns whether the expiry time would pass at the given point in time. `at_time` is the timestamp as a duration since the Unix epoch.
-
min_final_cltv_expiry_delta
public long min_final_cltv_expiry_delta()
Returns the invoice's `min_final_cltv_expiry_delta` time, if present, otherwise [`DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA`].
-
fallback_addresses
public String[] fallback_addresses()
Returns a list of all fallback addresses as [`Address`]es
-
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_milli_satoshis
public Option_u64Z amount_milli_satoshis()
Returns the amount if specified in the invoice as millisatoshis.
-
from_str
public static Result_InvoiceParseOrSemanticErrorZ 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
-
-