Documentation
¶
Index ¶
- Variables
- func AESCipher(key, plaintext []byte) (ciphertext []byte, iv []byte, err error)
- func AESDecipher(key, ciphertext, iv []byte) (plaintext []byte, err error)
- func Encode(s string) (string, error)
- func FindLNURLInText(text string) (lnurl string, ok bool)
- func IsDomainName(s string) bool
- func LNURLDecode(code string) (string, error)
- func LNURLDecodeStrict(code string) (string, error)
- func LNURLEncode(actualurl string) (lnurl string, err error)
- func LNURLEncodeStrict(actualurl string) (string, error)
- func ParseInternetIdentifier(text string) (name, domain string, ok bool)
- func RandomK1() string
- func VerifySignature(k1, sig, key string) (ok bool, err error)
- func WithCustomClient(c *http.Client)
- type LNURLAuthParams
- type LNURLChannelResponse
- type LNURLErrorResponse
- type LNURLParams
- func HandleAuth(rawurl string, parsed *url.URL, query url.Values) (LNURLParams, error)
- func HandleChannel(raw []byte) (LNURLParams, error)
- func HandleFastWithdraw(query url.Values) (LNURLParams, bool)
- func HandleLNURL(rawlnurl string) (string, LNURLParams, error)
- func HandlePay(raw []byte) (LNURLParams, error)
- func HandleWithdraw(raw []byte) (LNURLParams, error)
- type LNURLPayParams
- func (params LNURLPayParams) Call(msats int64, comment string, payerdata *PayerDataValues) (*LNURLPayValues, error)
- func (params LNURLPayParams) CallbackURL() *url.URL
- func (_ LNURLPayParams) LNURLKind() string
- func (params LNURLPayParams) MetadataEncoded() string
- func (params *LNURLPayParams) Normalize() error
- type LNURLPayValues
- type LNURLResponse
- type LNURLWithdrawResponse
- type Metadata
- type PayerDataItemSpec
- type PayerDataKeyAuthSpec
- type PayerDataKeyAuthValues
- type PayerDataSpec
- type PayerDataValues
- type SuccessAction
Constants ¶
This section is empty.
Variables ¶
var ( FALSE *bool = &f TRUE *bool = &t )
var Client = &http.Client{ Timeout: 5 * time.Second, }
var TorClient *http.Client
Functions ¶
func AESDecipher ¶
func FindLNURLInText ¶
FindLNURLInText uses a Regular Expression to find a bech32-encoded lnurl string in a blob of text.
func IsDomainName ¶ added in v1.12.0
IsDomainName (from net package) checks if a string is a presentation-format domain name (currently restricted to hostname-compatible "preferred name" LDH labels and SRV-like "underscore labels"; see golang.org/issue/12421).
func LNURLDecode ¶
LNURLDecode takes a bech32-encoded lnurl string and returns a plain-text https URL.
func LNURLDecodeStrict ¶ added in v1.12.0
LNURLDecodeStrict takes a string and returns a valid lnurl, if possible. code can be
func LNURLEncode ¶
LNURLEncode takes a plain-text https URL and returns a bech32-encoded uppercased lnurl string.
func LNURLEncodeStrict ¶ added in v1.12.0
LNURLEncodeStrict will encode the actualurl to lnurl. based on the input url, it will determine whether bech32 encoding / url manipulation is necessary
func ParseInternetIdentifier ¶ added in v1.4.0
ParseInternetIdentifier extracts name and domain from an email-like string like username@example.com
func RandomK1 ¶
func RandomK1() string
RandomK1 returns a 32-byte random hex-encoded string for usage as k1 in lnurl-auth and anywhere else.
func VerifySignature ¶
VerifySignature takes the hex-encoded parameters passed to an lnurl-login endpoint and verifies the signature against the key and challenge.
func WithCustomClient ¶ added in v1.12.0
Types ¶
type LNURLAuthParams ¶
type LNURLAuthParams struct {
Tag string `json:"tag"`
K1 string `json:"k1"`
Callback string `json:"callback"`
CallbackURL *url.URL `json:"-"`
Host string `json:"host"`
}
func (LNURLAuthParams) LNURLKind ¶
func (_ LNURLAuthParams) LNURLKind() string
type LNURLChannelResponse ¶
type LNURLChannelResponse struct {
LNURLResponse
Tag string `json:"tag"`
K1 string `json:"k1"`
Callback string `json:"callback"`
CallbackURL *url.URL `json:"-"`
URI string `json:"uri"`
}
func (LNURLChannelResponse) LNURLKind ¶
func (_ LNURLChannelResponse) LNURLKind() string
type LNURLErrorResponse ¶
type LNURLErrorResponse struct {
Status string `json:"status,omitempty"`
Reason string `json:"reason,omitempty"`
URL *url.URL `json:"-"`
}
func ErrorResponse ¶
func ErrorResponse(reason string) LNURLErrorResponse
func (LNURLErrorResponse) Error ¶
func (r LNURLErrorResponse) Error() string
type LNURLParams ¶
type LNURLParams interface {
LNURLKind() string
}
func HandleAuth ¶
func HandleChannel ¶
func HandleChannel(raw []byte) (LNURLParams, error)
func HandleFastWithdraw ¶
func HandleFastWithdraw(query url.Values) (LNURLParams, bool)
func HandleLNURL ¶
func HandleLNURL(rawlnurl string) (string, LNURLParams, error)
HandleLNURL takes a bech32-encoded lnurl and either gets its parameters from the query- string or calls the URL to get the parameters. Returns a different struct for each of the lnurl subprotocols, the .LNURLKind() method of which should be checked next to see how the wallet is going to proceed.
func HandlePay ¶
func HandlePay(raw []byte) (LNURLParams, error)
func HandleWithdraw ¶
func HandleWithdraw(raw []byte) (LNURLParams, error)
type LNURLPayParams ¶ added in v1.6.0
type LNURLPayParams struct {
LNURLResponse
Callback string `json:"callback"`
Tag string `json:"tag"`
MaxSendable int64 `json:"maxSendable"`
MinSendable int64 `json:"minSendable"`
EncodedMetadata string `json:"metadata"`
CommentAllowed int64 `json:"commentAllowed"`
PayerData *PayerDataSpec `json:"payerData,omitempty"`
Metadata Metadata `json:"-"`
}
func (LNURLPayParams) Call ¶ added in v1.6.0
func (params LNURLPayParams) Call( msats int64, comment string, payerdata *PayerDataValues, ) (*LNURLPayValues, error)
func (LNURLPayParams) CallbackURL ¶ added in v1.6.0
func (params LNURLPayParams) CallbackURL() *url.URL
func (LNURLPayParams) LNURLKind ¶ added in v1.6.0
func (_ LNURLPayParams) LNURLKind() string
func (LNURLPayParams) MetadataEncoded ¶ added in v1.7.0
func (params LNURLPayParams) MetadataEncoded() string
func (*LNURLPayParams) Normalize ¶ added in v1.9.0
func (params *LNURLPayParams) Normalize() error
type LNURLPayValues ¶ added in v1.6.0
type LNURLPayValues struct {
LNURLResponse
SuccessAction *SuccessAction `json:"successAction"`
Routes interface{} `json:"routes"` // ignored
PR string `json:"pr"`
Disposable *bool `json:"disposable,omitempty"`
ParsedInvoice decodepay.Bolt11 `json:"-"`
PayerDataJSON string `json:"-"`
}
func CallPay ¶ added in v1.10.2
func CallPay( metadata string, callback *url.URL, msats int64, comment string, payerdata *PayerDataValues, ) (*LNURLPayValues, error)
type LNURLResponse ¶
type LNURLResponse struct {
Status string `json:"status,omitempty"`
Reason string `json:"reason,omitempty"`
}
The base response for all lnurl calls.
func OkResponse ¶
func OkResponse() LNURLResponse
type LNURLWithdrawResponse ¶
type LNURLWithdrawResponse struct {
LNURLResponse
Tag string `json:"tag"`
K1 string `json:"k1"`
Callback string `json:"callback"`
CallbackURL *url.URL `json:"-"`
MaxWithdrawable int64 `json:"maxWithdrawable"`
MinWithdrawable int64 `json:"minWithdrawable"`
DefaultDescription string `json:"defaultDescription"`
BalanceCheck string `json:"balanceCheck,omitempty"`
PayLink string `json:"payLink,omitempty"`
}
func (LNURLWithdrawResponse) LNURLKind ¶
func (_ LNURLWithdrawResponse) LNURLKind() string
type Metadata ¶
type PayerDataItemSpec ¶ added in v1.6.0
type PayerDataItemSpec struct {
Mandatory bool `json:"mandatory"`
}
type PayerDataKeyAuthSpec ¶ added in v1.6.0
type PayerDataKeyAuthValues ¶ added in v1.6.0
type PayerDataSpec ¶ added in v1.6.0
type PayerDataSpec struct {
FreeName *PayerDataItemSpec `json:"name"`
PubKey *PayerDataItemSpec `json:"pubkey"`
LightningAddress *PayerDataItemSpec `json:"identifier"`
Email *PayerDataItemSpec `json:"email"`
KeyAuth *PayerDataKeyAuthSpec `json:"auth"`
}
func (PayerDataSpec) Exists ¶ added in v1.6.0
func (s PayerDataSpec) Exists() bool
type PayerDataValues ¶ added in v1.6.0
type PayerDataValues struct {
FreeName string `json:"name,omitempty"`
PubKey string `json:"pubkey,omitempty"`
LightningAddress string `json:"identifier,omitempty"`
Email string `json:"email,omitempty"`
KeyAuth *PayerDataKeyAuthValues `json:"auth,omitempty"`
}
type SuccessAction ¶
type SuccessAction struct {
Tag string `json:"tag"`
Description string `json:"description,omitempty"`
URL string `json:"url,omitempty"`
Message string `json:"message,omitempty"`
Ciphertext string `json:"ciphertext,omitempty"`
IV string `json:"iv,omitempty"`
}
func AESAction ¶
func AESAction(description string, preimage []byte, content string) (*SuccessAction, error)
func Action ¶
func Action(text string, url string) *SuccessAction