Class Invoice
- Namespace
- NLightning.Bolt11.Models
- Assembly
- NLightning.Bolt11.dll
Represents a BOLT11 Invoice
public class Invoice
- Inheritance
-
Invoice
- Inherited Members
Remarks
The invoice is a payment request that can be sent to a payer to request a payment.
Constructors
Invoice(LightningMoney, uint256, uint256, uint256, Network, ISecureKeyManager?)
The base constructor for the invoice
public Invoice(LightningMoney amount, uint256 descriptionHash, uint256 paymentHash, uint256 paymentSecret, Network network, ISecureKeyManager? secureKeyManager = null)
Parameters
amount
LightningMoneyThe amount of the invoice
descriptionHash
uint256The description hash of the invoice
paymentHash
uint256The payment hash of the invoice
paymentSecret
uint256The payment secret of the invoice
network
NetworkThe network the invoice is created for
secureKeyManager
ISecureKeyManagerSecure key manager
Remarks
The invoice is created with the given amount of millisatoshis, a description hash, the payment hash and the payment secret.
- See Also
Invoice(LightningMoney, string, uint256, uint256, Network, ISecureKeyManager?)
The base constructor for the invoice
public Invoice(LightningMoney amount, string description, uint256 paymentHash, uint256 paymentSecret, Network network, ISecureKeyManager? secureKeyManager = null)
Parameters
amount
LightningMoneyThe amount of the invoice
description
stringThe description of the invoice
paymentHash
uint256The payment hash of the invoice
paymentSecret
uint256The payment secret of the invoice
network
NetworkThe network the invoice is created for
secureKeyManager
ISecureKeyManagerSecure key manager
Remarks
The invoice is created with the given amount of millisatoshis, a description, the payment hash and the payment secret.
- See Also
Properties
Amount
The amount for the invoice
public LightningMoney Amount { get; }
Property Value
Description
The description of the invoice
public string? Description { get; }
Property Value
Remarks
The description is a UTF-8 encoded string that describes, in short, the purpose of payment
DescriptionHash
The description hash of the invoice
public uint256? DescriptionHash { get; }
Property Value
- uint256
Remarks
The description hash is a 32 byte hash of the description
- See Also
-
uint256
ExpiryDate
The expiry date of the invoice
public DateTimeOffset ExpiryDate { get; set; }
Property Value
Remarks
The expiry date is the date the invoice expires
- See Also
FallbackAddresses
The fallback addresses of the invoice
public List<BitcoinAddress>? FallbackAddresses { get; set; }
Property Value
- List<BitcoinAddress>
Remarks
The fallback addresses are used to specify the fallback addresses the payer can use
- See Also
-
BitcoinAddress
Features
The features of the invoice
public FeatureSet? Features { get; set; }
Property Value
Remarks
The features are used to specify the features the payer should support
- See Also
HumanReadablePart
The human-readable part of the invoice
public string HumanReadablePart { get; }
Property Value
Metadata
The metadata of the invoice
public byte[]? Metadata { get; set; }
Property Value
- byte[]
Remarks
The metadata is used to add additional information to the invoice
MinFinalCltvExpiry
The min final cltv expiry of the invoice
public ushort? MinFinalCltvExpiry { get; set; }
Property Value
Remarks
The min final cltv expiry is the minimum final cltv expiry the payer should use
Network
The network the invoice is created for
public Network Network { get; }
Property Value
PayeePubKey
The payee pubkey of the invoice
public PubKey? PayeePubKey { get; set; }
Property Value
- PubKey
Remarks
The payee pubkey is the pubkey of the payee
- See Also
-
PubKey
PaymentHash
The payment hash of the invoice
public uint256 PaymentHash { get; }
Property Value
- uint256
Remarks
The payment hash is a 32 byte hash that is used to identify a payment
- See Also
-
uint256
PaymentSecret
The payment secret of the invoice
public uint256 PaymentSecret { get; }
Property Value
- uint256
Remarks
The payment secret is a 32 byte secret that is used to identify a payment
- See Also
-
uint256
RoutingInfos
The Routing Information of the invoice
public RoutingInfoCollection? RoutingInfos { get; set; }
Property Value
Remarks
The routing information is used to hint about the route the payment could take
- See Also
Signature
The signature of the invoice
public CompactSignature Signature { get; }
Property Value
- CompactSignature
Timestamp
The timestamp of the invoice
public long Timestamp { get; }
Property Value
Remarks
The timestamp is the time the invoice was created in seconds since the Unix epoch.
Methods
Decode(string?, Network?)
Decodes an invoice from a string
public static Invoice Decode(string? invoiceString, Network? expectedNetwork = null)
Parameters
invoiceString
stringThe invoice string
expectedNetwork
Network?The expected network of the invoice
Returns
- Invoice
The invoice
Exceptions
- InvoiceSerializationException
If something goes wrong in the decoding process
Encode()
Encodes the invoice into its string representation using the secure key manager.
public string Encode()
Returns
- string
The encoded invoice string.
Exceptions
- NullReferenceException
Thrown when the secure key manager is not set.
Encode(Key)
Encodes the current invoice into a lightning-compatible invoice format as a string.
public string Encode(Key nodeKey)
Parameters
nodeKey
KeyThe private key of the node used to sign the invoice.
Returns
- string
The encoded lightning invoice as a string.
Exceptions
- InvoiceSerializationException
Thrown when an error occurs during the encoding process.
InSatoshis(ulong, uint256, uint256, uint256, Network)
Creates a new invoice with the given amount of satoshis
public static Invoice InSatoshis(ulong amountSats, uint256 descriptionHash, uint256 paymentHash, uint256 paymentSecret, Network network)
Parameters
amountSats
ulongThe amount of satoshis the invoice is for
descriptionHash
uint256The description hash of the invoice
paymentHash
uint256The payment hash of the invoice
paymentSecret
uint256The payment secret of the invoice
network
NetworkThe network the invoice is created for
Returns
- Invoice
The invoice
Remarks
The invoice is created with the given amount of satoshis, a description hash, the payment hash and the payment secret.
InSatoshis(ulong, string, uint256, uint256, Network)
Creates a new invoice with the given amount of satoshis
public static Invoice InSatoshis(ulong amountSats, string description, uint256 paymentHash, uint256 paymentSecret, Network network)
Parameters
amountSats
ulongThe amount of satoshis the invoice is for
description
stringThe description of the invoice
paymentHash
uint256The payment hash of the invoice
paymentSecret
uint256The payment secret of the invoice
network
NetworkThe network the invoice is created for
Returns
- Invoice
The invoice
Remarks
The invoice is created with the given amount of satoshis, a description, the payment hash and the payment secret.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
ToString(Key)
Converts the invoice object to its string representation.
public string ToString(Key nodeKey)
Parameters
nodeKey
KeyThe node key used for signing the invoice.
Returns
- string
A string representation of the invoice.
Remarks
If the invoice string exists, it is returned directly. Otherwise, the invoice is encoded using the provided node key.
Exceptions
- InvoiceSerializationException
Thrown when an error occurs during the encoding process.