| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
LnUrl.Pay
Description
See https://github.com/fiatjaf/lnurl-rfc/blob/master/lnurl-pay.md.
Workflow
LN WALLETdecodes URL usinggetPayURLand makes aGETrequest.LN SERVICEresponds withResponseSuccessResponse.LN WALLETget parameters from the user.LN WALLETprepare a callback URL usinggetCallbackUrl.LN SERVICEresponds withResponseCallbackSuccessResponse.LN WALLETverifies: (a)htag inpaymentRequestisSHA256(metadata), (b) the amount inpaymentRequestmatches the requested amount, and (c) signatures onChannelUpdatemessages.LN WALLETpays invoice.LN WALLETafter paying the invoice, execute thesuccessActionif 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.
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
Arguments
| :: ByteString | Payment preimage |
| -> AesAction | |
| -> Either AesError ByteString |
Use the payment preimage to get the encrypted payload
Server
Arguments
| :: ByteString | Payment preimage |
| -> Text | Description |
| -> ByteString | Message to encrypt |
| -> IO (Either AesError AesAction) |
Use the payment preimage to build an encrypted payload
Types
Constructors
| Success a | |
| ErrorResponse Text |
data SuccessResponse Source #
Constructors
| SuccessResponse | |
Fields
| |
Instances
| Eq SuccessResponse Source # | |
Defined in LnUrl.Pay Methods (==) :: SuccessResponse -> SuccessResponse -> Bool # (/=) :: SuccessResponse -> SuccessResponse -> Bool # | |
| Show SuccessResponse Source # | |
Defined in LnUrl.Pay Methods showsPrec :: Int -> SuccessResponse -> ShowS # show :: SuccessResponse -> String # showList :: [SuccessResponse] -> ShowS # | |
| ToJSON SuccessResponse Source # | |
Defined in LnUrl.Pay Methods toJSON :: SuccessResponse -> Value # toEncoding :: SuccessResponse -> Encoding # toJSONList :: [SuccessResponse] -> Value # toEncodingList :: [SuccessResponse] -> Encoding # | |
| FromJSON SuccessResponse Source # | |
Defined in LnUrl.Pay Methods parseJSON :: Value -> Parser SuccessResponse # parseJSONList :: Value -> Parser [SuccessResponse] # | |
The metadata array
Constructors
| PlainText Text | |
| ImagePNG ByteString | |
| ImageJPEG ByteString | |
| Email Text | |
| Ident Text |
data CallbackSuccessResponse Source #
Constructors
| CallbackSuccessResponse | |
Fields
| |
Instances
| Eq CallbackSuccessResponse Source # | |
Defined in LnUrl.Pay Methods (==) :: CallbackSuccessResponse -> CallbackSuccessResponse -> Bool # (/=) :: CallbackSuccessResponse -> CallbackSuccessResponse -> Bool # | |
| Show CallbackSuccessResponse Source # | |
Defined in LnUrl.Pay Methods showsPrec :: Int -> CallbackSuccessResponse -> ShowS # show :: CallbackSuccessResponse -> String # showList :: [CallbackSuccessResponse] -> ShowS # | |
| ToJSON CallbackSuccessResponse Source # | |
Defined in LnUrl.Pay Methods toJSON :: CallbackSuccessResponse -> Value # toEncoding :: CallbackSuccessResponse -> Encoding # toJSONList :: [CallbackSuccessResponse] -> Value # | |
| FromJSON CallbackSuccessResponse Source # | |
Defined in LnUrl.Pay Methods parseJSON :: Value -> Parser CallbackSuccessResponse # parseJSONList :: Value -> Parser [CallbackSuccessResponse] # | |
Constructors
| Hop | |
Fields
| |
data SuccessAction Source #
Instances
| Eq SuccessAction Source # | |
Defined in LnUrl.Pay Methods (==) :: SuccessAction -> SuccessAction -> Bool # (/=) :: SuccessAction -> SuccessAction -> Bool # | |
| Show SuccessAction Source # | |
Defined in LnUrl.Pay Methods showsPrec :: Int -> SuccessAction -> ShowS # show :: SuccessAction -> String # showList :: [SuccessAction] -> ShowS # | |
| ToJSON SuccessAction Source # | |
Defined in LnUrl.Pay Methods toJSON :: SuccessAction -> Value # toEncoding :: SuccessAction -> Encoding # toJSONList :: [SuccessAction] -> Value # toEncodingList :: [SuccessAction] -> Encoding # | |
| FromJSON SuccessAction Source # | |
Defined in LnUrl.Pay Methods parseJSON :: Value -> Parser SuccessAction # parseJSONList :: Value -> Parser [SuccessAction] # | |
Constructors
| UrlAction | |
Fields
| |
Constructors
| AesAction | |
Fields
| |
Constructors
| KeyError | |
| IvError | |
| PaddingError |