Table of Contents

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

uri UriBuilder

The UriBuilder whose query string will be modified.

key string

The query parameter name.

value string

The 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

serviceUrl Uri

The HTTPS, .onion, or local-network service URL to encode.

Returns

string

A bech32-encoded LNURL string.

Exceptions

ArgumentException

Thrown when serviceUrl is 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

serviceUrl Uri

The HTTPS, .onion, or local-network service URL to encode.

tag string

The LNURL tag. If null, extracted from the URL query string.

bech32 bool

If true, returns a lightning:lnurl1... URI; otherwise a LUD-17 scheme URI.

Returns

Uri

A Uri in the chosen encoding format.

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

identifier string

A Lightning Address in the form user@domain or user@domain:port.

Returns

Uri

The well-known LNURL-pay Uri for the given identifier.

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

lnUrl Uri
httpClient HttpClient

Returns

Task<object>

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

lnUrl Uri
httpClient HttpClient
cancellationToken CancellationToken

Returns

Task<object>

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

lnUrl Uri
tag string
httpClient HttpClient

Returns

Task<object>

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

lnUrl Uri
tag string
httpClient HttpClient
cancellationToken CancellationToken

Returns

Task<object>

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

identifier string

A Lightning Address in the form user@domain.

httpClient HttpClient

The 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

identifier string

A Lightning Address in the form user@domain.

httpClient HttpClient

The HttpClient used to perform the HTTP request.

cancellationToken CancellationToken

A 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

lnurl string

The LNURL string to parse. Accepted formats include bech32 (lnurl1...), bech32 with prefix (lightning:lnurl1...), or LUD-17 scheme URIs (lnurlp://, lnurlw://, lnurlc://, keyauth://).

tag string

When this method returns, contains the LNURL tag (e.g. "payRequest", "withdrawRequest", "channelRequest", "login") if it could be determined; otherwise null.

Returns

Uri

The decoded service Uri.

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.