Safe Haskell | None |
---|---|
Language | Haskell2010 |
See https://github.com/fiatjaf/lnurl-rfc/blob/master/lnurl-pay.md.
Workflow
LN WALLET
decodes URL usinggetPayURL
and makes aGET
request.LN SERVICE
responds withResponse
SuccessResponse
.LN WALLET
get parameters from the user.LN WALLET
prepare a callback URL usinggetCallbackUrl
.LN SERVICE
responds withResponse
CallbackSuccessResponse
.LN WALLET
verifies: (a)h
tag inpaymentRequest
isSHA256(metadata)
, (b) the amount inpaymentRequest
matches the requested amount, and (c) signatures onChannelUpdate
messages.LN WALLET
pays invoice.LN WALLET
after paying the invoice, execute thesuccessAction
if defined.
Synopsis
- getPayURL :: URI -> URI
- getCallbackUrl :: SuccessResponse -> Word64 -> Maybe ByteString -> [NodeId] -> Maybe Text -> Maybe PubKey -> Maybe URI
- decrypt :: ByteString -> AesAction -> Either AesError ByteString
- encrypt :: ByteString -> Text -> ByteString -> IO (Either AesError AesAction)
- data Response a
- = Success a
- | ErrorResponse Text
- data SuccessResponse = SuccessResponse {
- callback :: URI
- maxSendable :: Word64
- minSendable :: Word64
- metadata :: [Metadata]
- commentAllowed :: Maybe Int
- data Metadata
- data CallbackSuccessResponse = CallbackSuccessResponse {
- paymentRequest :: Text
- successAction :: Maybe SuccessAction
- disposable :: Bool
- routes :: [[Hop]]
- data Hop = Hop {}
- data SuccessAction
- data UrlAction = UrlAction {
- urlDescription :: Text
- url :: URI
- data AesAction = AesAction {}
- data AesError
Client
getPayURL :: URI -> URI Source #
Apply the LNURL-pay uri transform logic. LN SERVICE
should respond to the resulting URL with Response
.
:: 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
:: ByteString | Payment preimage |
-> AesAction | |
-> Either AesError ByteString |
Use the payment preimage to get the encrypted payload
Server
:: ByteString | Payment preimage |
-> Text | Description |
-> ByteString | Message to encrypt |
-> IO (Either AesError AesAction) |
Use the payment preimage to build an encrypted payload
Types
data SuccessResponse Source #
SuccessResponse | |
|
Instances
Eq SuccessResponse Source # | |
Defined in LnUrl.Pay (==) :: SuccessResponse -> SuccessResponse -> Bool # (/=) :: SuccessResponse -> SuccessResponse -> Bool # | |
Show SuccessResponse Source # | |
Defined in LnUrl.Pay showsPrec :: Int -> SuccessResponse -> ShowS # show :: SuccessResponse -> String # showList :: [SuccessResponse] -> ShowS # | |
ToJSON SuccessResponse Source # | |
Defined in LnUrl.Pay toJSON :: SuccessResponse -> Value # toEncoding :: SuccessResponse -> Encoding # toJSONList :: [SuccessResponse] -> Value # toEncodingList :: [SuccessResponse] -> Encoding # | |
FromJSON SuccessResponse Source # | |
Defined in LnUrl.Pay parseJSON :: Value -> Parser SuccessResponse # parseJSONList :: Value -> Parser [SuccessResponse] # |
The metadata array
data CallbackSuccessResponse Source #
CallbackSuccessResponse | |
|
Instances
Eq CallbackSuccessResponse Source # | |
Defined in LnUrl.Pay | |
Show CallbackSuccessResponse Source # | |
Defined in LnUrl.Pay showsPrec :: Int -> CallbackSuccessResponse -> ShowS # show :: CallbackSuccessResponse -> String # showList :: [CallbackSuccessResponse] -> ShowS # | |
ToJSON CallbackSuccessResponse Source # | |
Defined in LnUrl.Pay | |
FromJSON CallbackSuccessResponse Source # | |
Defined in LnUrl.Pay |
Hop | |
|
data SuccessAction Source #
Instances
Eq SuccessAction Source # | |
Defined in LnUrl.Pay (==) :: SuccessAction -> SuccessAction -> Bool # (/=) :: SuccessAction -> SuccessAction -> Bool # | |
Show SuccessAction Source # | |
Defined in LnUrl.Pay showsPrec :: Int -> SuccessAction -> ShowS # show :: SuccessAction -> String # showList :: [SuccessAction] -> ShowS # | |
ToJSON SuccessAction Source # | |
Defined in LnUrl.Pay toJSON :: SuccessAction -> Value # toEncoding :: SuccessAction -> Encoding # toJSONList :: [SuccessAction] -> Value # toEncodingList :: [SuccessAction] -> Encoding # | |
FromJSON SuccessAction Source # | |
Defined in LnUrl.Pay parseJSON :: Value -> Parser SuccessAction # parseJSONList :: Value -> Parser [SuccessAction] # |
UrlAction | |
|
AesAction | |
|