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
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
LNUrl
Gets or sets the full LNURL-auth URL.
[JsonIgnore]
[JsonIgnore]
public Uri LNUrl { get; set; }
Property Value
Tag
Gets the LNURL tag. For auth requests this is always "login".
[JsonProperty("tag")]
[JsonPropertyName("tag")]
public string Tag { get; }
Property Value
Methods
EnsureValidUrl(Uri)
Validates that a service URL conforms to the LNURL-auth requirements (LUD-04).
public static void EnsureValidUrl(Uri serviceUrl)
Parameters
serviceUrlUri
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
sigECDSASignaturekeyPubKeyhttpClientHttpClientcancellationTokenCancellationToken
Returns
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
keyKeyhttpClientHttpClientcancellationTokenCancellationToken
Returns
SignChallenge(Key)
Signs this request's K1 challenge with the given private key.
public ECDSASignature SignChallenge(Key key)
Parameters
keyKey
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
keyKeyk1string
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
sigECDSASignatureexpectedPubKeyPubKeyexpectedMessagebyte[]