Class LNURL
- Namespace
- LNURL
- Assembly
- LNURL.Core.dll
Static facade class providing core LNURL protocol operations including encoding, decoding, and fetching information from LNURL endpoints. Implements LUD-01 (bech32 encoding), LUD-17 (scheme-based encoding), and LUD-16 (Lightning Address / internet identifier).
public class LNURL
- Inheritance
-
LNURL
- Inherited Members
Methods
AppendPayloadToQuery(UriBuilder, string, string)
Appends a URL-encoded key-value pair to the query string of a UriBuilder.
public static void AppendPayloadToQuery(UriBuilder uri, string key, string value)
Parameters
uriUriBuilderThe UriBuilder whose query string will be modified.
keystringThe query parameter name.
valuestringThe query parameter value.
EncodeBech32(Uri)
Encodes a service URL into a bech32-formatted LNURL string as specified by LUD-01.
public static string EncodeBech32(Uri serviceUrl)
Parameters
serviceUrlUriThe HTTPS, .onion, or local-network service URL to encode.
Returns
- string
A bech32-encoded LNURL string.
Exceptions
- ArgumentException
Thrown when
serviceUrlis not HTTPS, an onion service, or on the local network.
EncodeUri(Uri, string, bool)
Encodes a service URL into either a bech32 LNURL (LUD-01) or a LUD-17 scheme-based URI.
public static Uri EncodeUri(Uri serviceUrl, string tag, bool bech32)
Parameters
serviceUrlUriThe HTTPS, .onion, or local-network service URL to encode.
tagstringThe LNURL tag. If
null, extracted from the URL query string.bech32boolIf
true, returns alightning:lnurl1...URI; otherwise a LUD-17 scheme URI.
Returns
ExtractUriFromInternetIdentifier(string)
Converts a Lightning Address (internet identifier per LUD-16) to its well-known LNURL-pay URL.
public static Uri ExtractUriFromInternetIdentifier(string identifier)
Parameters
identifierstringA Lightning Address in the form
user@domainoruser@domain:port.
Returns
FetchInformation(Uri, HttpClient)
Fetches LNURL endpoint information from the given URL, automatically determining the response type.
public static Task<object> FetchInformation(Uri lnUrl, HttpClient httpClient)
Parameters
lnUrlUrihttpClientHttpClient
Returns
FetchInformation(Uri, HttpClient, CancellationToken)
Fetches LNURL endpoint information from the given URL, automatically determining the response type.
public static Task<object> FetchInformation(Uri lnUrl, HttpClient httpClient, CancellationToken cancellationToken)
Parameters
lnUrlUrihttpClientHttpClientcancellationTokenCancellationToken
Returns
FetchInformation(Uri, string, HttpClient)
Fetches LNURL endpoint information from the given URL with an explicit tag hint.
public static Task<object> FetchInformation(Uri lnUrl, string tag, HttpClient httpClient)
Parameters
lnUrlUritagstringhttpClientHttpClient
Returns
FetchInformation(Uri, string, HttpClient, CancellationToken)
Fetches LNURL endpoint information from the given URL with an explicit tag hint. Supports fast withdraw (LUD-03 query-string parameters) and LNURL-auth (LUD-04) inline parsing.
public static Task<object> FetchInformation(Uri lnUrl, string tag, HttpClient httpClient, CancellationToken cancellationToken)
Parameters
lnUrlUritagstringhttpClientHttpClientcancellationTokenCancellationToken
Returns
FetchPayRequestViaInternetIdentifier(string, HttpClient)
Fetches a LNURLPayRequest for the given Lightning Address (internet identifier) as specified by LUD-16.
public static Task<LNURLPayRequest> FetchPayRequestViaInternetIdentifier(string identifier, HttpClient httpClient)
Parameters
identifierstringA Lightning Address in the form
user@domain.httpClientHttpClientThe HttpClient used to perform the HTTP request.
Returns
- Task<LNURLPayRequest>
The LNURLPayRequest fetched from the well-known LNURL-pay endpoint.
FetchPayRequestViaInternetIdentifier(string, HttpClient, CancellationToken)
Fetches a LNURLPayRequest for the given Lightning Address (internet identifier) as specified by LUD-16.
public static Task<LNURLPayRequest> FetchPayRequestViaInternetIdentifier(string identifier, HttpClient httpClient, CancellationToken cancellationToken)
Parameters
identifierstringA Lightning Address in the form
user@domain.httpClientHttpClientThe HttpClient used to perform the HTTP request.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<LNURLPayRequest>
The LNURLPayRequest fetched from the well-known LNURL-pay endpoint.
Parse(string, out string)
Parses an LNURL string (bech32-encoded per LUD-01, or a LUD-17 scheme URI) into an absolute Uri
and extracts the LNURL tag if present. The lightning: prefix is stripped automatically.
public static Uri Parse(string lnurl, out string tag)
Parameters
lnurlstringThe LNURL string to parse. Accepted formats include bech32 (
lnurl1...), bech32 with prefix (lightning:lnurl1...), or LUD-17 scheme URIs (lnurlp://,lnurlw://,lnurlc://,keyauth://).tagstringWhen this method returns, contains the LNURL tag (e.g.
"payRequest","withdrawRequest","channelRequest","login") if it could be determined; otherwisenull.
Returns
Exceptions
- FormatException
Thrown when the decoded URL is not secure (must be HTTPS, .onion, or local network), or the string is not a valid bech32 LNURL or LUD-17 URI.