Table of Contents

Class LNAuthRequest

Namespace
LNURL
Assembly
LNURL.Core.dll

Represents an LNURL-auth request as defined in LUD-04. Provides passwordless authentication by signing a challenge (k1) with a Lightning node key.

public class LNAuthRequest
Inheritance
LNAuthRequest
Inherited Members

Properties

Action

Gets or sets the optional action hint indicating the purpose of this authentication request.

[JsonProperty("action")]
[JsonConverter(typeof(StringEnumConverter))]
[JsonPropertyName("action")]
public LNAuthRequest.LNAuthRequestAction? Action { get; set; }

Property Value

LNAuthRequest.LNAuthRequestAction?

K1

Gets or sets the hex-encoded 32-byte challenge that the wallet must sign.

[JsonProperty("k1")]
[JsonPropertyName("k1")]
public string K1 { get; set; }

Property Value

string

LNUrl

Gets or sets the full LNURL-auth URL.

[JsonIgnore]
[JsonIgnore]
public Uri LNUrl { get; set; }

Property Value

Uri

Tag

Gets the LNURL tag. For auth requests this is always "login".

[JsonProperty("tag")]
[JsonPropertyName("tag")]
public string Tag { get; }

Property Value

string

Methods

EnsureValidUrl(Uri)

Validates that a service URL conforms to the LNURL-auth requirements (LUD-04).

public static void EnsureValidUrl(Uri serviceUrl)

Parameters

serviceUrl Uri

SendChallenge(ECDSASignature, PubKey, HttpClient, CancellationToken)

Sends the signed challenge and public key to the LNURL-auth service to complete authentication.

public Task<LNUrlStatusResponse> SendChallenge(ECDSASignature sig, PubKey key, HttpClient httpClient, CancellationToken cancellationToken = default)

Parameters

sig ECDSASignature
key PubKey
httpClient HttpClient
cancellationToken CancellationToken

Returns

Task<LNUrlStatusResponse>

SendChallenge(Key, HttpClient, CancellationToken)

Signs the K1 challenge with the given key and sends the result.

public Task<LNUrlStatusResponse> SendChallenge(Key key, HttpClient httpClient, CancellationToken cancellationToken = default)

Parameters

key Key
httpClient HttpClient
cancellationToken CancellationToken

Returns

Task<LNUrlStatusResponse>

SignChallenge(Key)

Signs this request's K1 challenge with the given private key.

public ECDSASignature SignChallenge(Key key)

Parameters

key Key

Returns

ECDSASignature

SignChallenge(Key, string)

Signs an arbitrary hex-encoded challenge with the given private key.

public static ECDSASignature SignChallenge(Key key, string k1)

Parameters

key Key
k1 string

Returns

ECDSASignature

VerifyChallenge(ECDSASignature, PubKey, byte[])

Verifies that a given ECDSA signature is valid for the expected public key and message.

public static bool VerifyChallenge(ECDSASignature sig, PubKey expectedPubKey, byte[] expectedMessage)

Parameters

sig ECDSASignature
expectedPubKey PubKey
expectedMessage byte[]

Returns

bool