lnbits

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserStateConfirmPayment = iota + 1
	UserStateConfirmSend
	UserStateLNURLEnterAmount
	UserStateConfirmLNURLPay
	UserEnterAmount
	UserHasEnteredAmount
	UserEnterUser
	UserHasEnteredUser
	UserEnterShopTitle
	UserStateShopItemSendPhoto
	UserStateShopItemSendTitle
	UserStateShopItemSendDescription
	UserStateShopItemSendPrice
	UserStateShopItemSendItemFile
	UserEnterShopsDescription
	UserEnterDallePrompt
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	AdminKey   string
	InvoiceKey string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(key, url string) *Client

NewClient returns a new lnbits api client. Pass your API key and url here.

func (*Client) CreateUserWithInitialWallet

func (c *Client) CreateUserWithInitialWallet(userName, walletName, adminId string, email string) (wal User, err error)

CreateUserWithInitialWallet creates new user with initial wallet

func (*Client) CreateWallet

func (c *Client) CreateWallet(userId, walletName, adminId string) (wal Wallet, err error)

CreateWallet creates a new wallet.

func (*Client) GetUser

func (c *Client) GetUser(userId string) (user User, err error)

GetUser returns user information

func (Client) Info

func (c Client) Info(w Wallet) (wtx Wallet, err error)

Info returns wallet information

func (Client) Payment added in v0.5.1

func (c Client) Payment(w Wallet, payment_hash string) (payment LNbitsPayment, err error)

Payment state of a payment

func (Client) Payments added in v0.5.1

func (c Client) Payments(w Wallet) (wtx Payments, err error)

Payments returns wallet payments

func (Client) Wallets

func (c Client) Wallets(w User) (wtx []Wallet, err error)

Wallets returns all wallets belonging to an user

type Error

type Error struct {
	Detail string `json:"detail"`
}

func (Error) Error

func (err Error) Error() string

type Invoice added in v0.5.1

type Invoice struct {
	PaymentHash    string `json:"payment_hash"`
	PaymentRequest string `json:"payment_request"`
}

type InvoiceParams

type InvoiceParams struct {
	Out                 bool   `json:"out"`                            // must be True if invoice is payed, False if invoice is received
	Amount              int64  `json:"amount"`                         // amount in Satoshi
	Memo                string `json:"memo,omitempty"`                 // the invoice memo.
	Webhook             string `json:"webhook,omitempty"`              // the webhook to fire back to when payment is received.
	DescriptionHash     string `json:"description_hash,omitempty"`     // the invoice description hash.
	UnhashedDescription string `json:"unhashed_description,omitempty"` // the unhashed invoice description.
}

type LNbitsPayment added in v0.5.1

type LNbitsPayment struct {
	Paid     bool    `json:"paid"`
	Preimage string  `json:"preimage"`
	Details  Payment `json:"details,omitempty"`
}

type NodeSettings added in v0.5.1

type NodeSettings struct {
	NodeType     string                 `json:"nodetype"`
	LNDParams    *satdress.LNDParams    `gorm:"embedded;embeddedPrefix:lndparams_"`
	LNbitsParams *satdress.LNBitsParams `gorm:"embedded;embeddedPrefix:lnbitsparams_"`
}

type PayParams

type PayParams struct {
	// the BOLT11 payment request you want to pay.
	PaymentRequest string `json:"payment_request"`

	// custom data you may want to associate with this invoice. optional.
	PassThru map[string]interface{} `json:"passThru"`
}

type Payment added in v0.5.1

type Payment struct {
	CheckingID    string      `json:"checking_id"`
	Pending       bool        `json:"pending"`
	Amount        int64       `json:"amount"`
	Fee           int64       `json:"fee"`
	Memo          string      `json:"memo"`
	Time          int         `json:"time"`
	Bolt11        string      `json:"bolt11"`
	Preimage      string      `json:"preimage"`
	PaymentHash   string      `json:"payment_hash"`
	Extra         struct{}    `json:"extra"`
	WalletID      string      `json:"wallet_id"`
	Webhook       interface{} `json:"webhook"`
	WebhookStatus interface{} `json:"webhook_status"`
}

type PaymentParams

type PaymentParams struct {
	Out    bool   `json:"out"`
	Bolt11 string `json:"bolt11"`
}

type Payments added in v0.5.1

type Payments []Payment

type Settings added in v0.5.1

type Settings struct {
	ID   string       `json:"id" gorm:"primarykey"`
	Node NodeSettings `gorm:"embedded;embeddedPrefix:node_"`
}

type TransferParams

type TransferParams struct {
	Memo         string `json:"memo"`           // the transfer description.
	NumSatoshis  int64  `json:"num_satoshis"`   // the transfer amount.
	DestWalletId string `json:"dest_wallet_id"` // the key or id of the destination
}

type User

type User struct {
	ID           string       `json:"id"`
	Name         string       `json:"name" gorm:"primaryKey"`
	Initialized  bool         `json:"initialized"`
	Telegram     *tb.User     `gorm:"embedded;embeddedPrefix:telegram_"`
	Wallet       *Wallet      `gorm:"embedded;embeddedPrefix:wallet_"`
	StateKey     UserStateKey `json:"stateKey"`
	StateData    string       `json:"stateData"`
	CreatedAt    time.Time    `json:"created"`
	UpdatedAt    time.Time    `json:"updated"`
	AnonID       string       `json:"anon_id"`
	AnonIDSha256 string       `json:"anon_id_sha256"`
	UUID         string       `json:"uuid"`
	Banned       bool         `json:"banned"`
	Settings     *Settings    `json:"settings" gorm:"foreignKey:id"`
}

func (User) LinkingKey added in v0.5.1

func (u User) LinkingKey(domain string) (*btcec.PrivateKey, *btcec.PublicKey)

from fiatjaf/lnurl-go

func (*User) ResetState

func (u *User) ResetState()

func (User) SignKeyAuth added in v0.5.1

func (u User) SignKeyAuth(domain string, k1hex string) (key string, sig string, err error)

type UserStateKey

type UserStateKey int

type Wallet

type Wallet struct {
	ID       string `json:"id" gorm:"id"`
	Adminkey string `json:"adminkey"`
	Inkey    string `json:"inkey"`
	Balance  int64  `json:"balance"`
	Name     string `json:"name"`
	User     string `json:"user"`
}

func (Wallet) Invoice added in v0.4.1

func (w Wallet) Invoice(params InvoiceParams, c *Client) (lntx Invoice, err error)

Invoice creates an invoice associated with this wallet.

func (Wallet) Pay added in v0.4.1

func (w Wallet) Pay(params PaymentParams, c *Client) (wtx Invoice, err error)

Pay pays a given invoice with funds from the wallet.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL