lnurl-0.1.0.0: Support for developing against the LNURL protocol
Safe HaskellNone
LanguageHaskell2010

LnUrl.Pay

Description

See https://github.com/fiatjaf/lnurl-rfc/blob/master/lnurl-pay.md.

Workflow

  1. LN WALLET decodes URL using getPayURL and makes a GET request.
  2. LN SERVICE responds with Response SuccessResponse.
  3. LN WALLET get parameters from the user.
  4. LN WALLET prepare a callback URL using getCallbackUrl.
  5. LN SERVICE responds with Response CallbackSuccessResponse.
  6. LN WALLET verifies: (a) h tag in paymentRequest is SHA256(metadata), (b) the amount in paymentRequest matches the requested amount, and (c) signatures on ChannelUpdate messages.
  7. LN WALLET pays invoice.
  8. LN WALLET after paying the invoice, execute the successAction if defined.
Synopsis

Client

getPayURL :: URI -> URI Source #

Apply the LNURL-pay uri transform logic. LN SERVICE should respond to the resulting URL with Response.

getCallbackUrl Source #

Arguments

:: SuccessResponse 
-> Word64

amount (millisatoshis)

-> Maybe ByteString

cache prevention

-> [NodeId]

starting points (node ids)

-> Maybe Text

comment

-> Maybe PubKey

proof of payer

-> Maybe URI 

Prepare a callback url to use to retrieve the payment request

decrypt Source #

Arguments

:: ByteString

Payment preimage

-> AesAction 
-> Either AesError ByteString 

Use the payment preimage to get the encrypted payload

Server

encrypt Source #

Arguments

:: ByteString

Payment preimage

-> Text

Description

-> ByteString

Message to encrypt

-> IO (Either AesError AesAction) 

Use the payment preimage to build an encrypted payload

Types

data Response a Source #

Constructors

Success a 
ErrorResponse Text 

Instances

Instances details
Eq a => Eq (Response a) Source # 
Instance details

Defined in LnUrl

Methods

(==) :: Response a -> Response a -> Bool #

(/=) :: Response a -> Response a -> Bool #

Show a => Show (Response a) Source # 
Instance details

Defined in LnUrl

Methods

showsPrec :: Int -> Response a -> ShowS #

show :: Response a -> String #

showList :: [Response a] -> ShowS #

ToJSON a => ToJSON (Response a) Source # 
Instance details

Defined in LnUrl

FromJSON a => FromJSON (Response a) Source # 
Instance details

Defined in LnUrl

data Metadata Source #

The metadata array

Instances

Instances details
Eq Metadata Source # 
Instance details

Defined in LnUrl.Pay

Show Metadata Source # 
Instance details

Defined in LnUrl.Pay

ToJSON Metadata Source # 
Instance details

Defined in LnUrl.Pay

FromJSON Metadata Source # 
Instance details

Defined in LnUrl.Pay

data Hop Source #

Constructors

Hop 

Instances

Instances details
Eq Hop Source # 
Instance details

Defined in LnUrl.Pay

Methods

(==) :: Hop -> Hop -> Bool #

(/=) :: Hop -> Hop -> Bool #

Show Hop Source # 
Instance details

Defined in LnUrl.Pay

Methods

showsPrec :: Int -> Hop -> ShowS #

show :: Hop -> String #

showList :: [Hop] -> ShowS #

ToJSON Hop Source # 
Instance details

Defined in LnUrl.Pay

FromJSON Hop Source # 
Instance details

Defined in LnUrl.Pay

data UrlAction Source #

Constructors

UrlAction 

Fields

Instances

Instances details
Eq UrlAction Source # 
Instance details

Defined in LnUrl.Pay

Show UrlAction Source # 
Instance details

Defined in LnUrl.Pay

data AesAction Source #

Instances

Instances details
Eq AesAction Source # 
Instance details

Defined in LnUrl.Pay

Show AesAction Source # 
Instance details

Defined in LnUrl.Pay

data AesError Source #

Constructors

KeyError 
IvError 
PaddingError 

Instances

Instances details
Eq AesError Source # 
Instance details

Defined in LnUrl.Pay

Show AesError Source # 
Instance details

Defined in LnUrl.Pay

Exception AesError Source # 
Instance details

Defined in LnUrl.Pay