common

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConfigDir  = "~/.lncm/"
	DefaultConfigFile = DefaultConfigDir + "invoicer.conf"
	DefaultLogFile    = DefaultConfigDir + "invoicer.log"

	DefaultInvoiceExpiry = 180
	MaxInvoiceDescLen    = 639
)

Variables

This section is empty.

Functions

func CleanAndExpandPath

func CleanAndExpandPath(path string) string

CleanAndExpandPath converts passed file system paths into absolute ones.

func DeprecatedConfigLocationCheck added in v0.5.0

func DeprecatedConfigLocationCheck(path string, err error) (*toml.Tree, error)

deprecatedConfigLocationCheck checks for a config file in a previously default location. Checking there will be

removed in one of the next versions.

tl;dr: `mkdir ~/.lncm  &&  mv ~/.invoicer/* ~/.lncm/  &&  rmdir ~/.invoicer`

OR, if you run in Docker, just change where your volume is mounted, ex:

`-v $(pwd)/:/root/.invoicer/`    ->    `-v $(pwd)/:/root/.lncm/`

func FormatRoutes added in v0.5.0

func FormatRoutes(ginRoutes gin.RoutesInfo) (routes []string)

func Max added in v0.5.0

func Max(a, b int) int

Types

type AddrStatus

type AddrStatus struct {
	Address       string   `json:"address"`
	Amount        float64  `json:"amount"`
	Confirmations int64    `json:"confirmations"`
	Label         string   `json:"label,omitempty"`
	TxIds         []string `json:"txids"`
}

type AddrsStatus

type AddrsStatus []AddrStatus

type Bitcoind

type Bitcoind struct {
	Host string `toml:"host"`
	Port int64  `toml:"port"`
	User string `toml:"user"`
	Pass string `toml:"pass"`
}

Bitcoind config NOTE: Keep in mind that this is **not yet encrypted**, so best to keep it _local_

type Config

type Config struct {
	// Port invoicer will run on
	Port int64 `toml:"port"`

	// Path to directory where `index.html` will be served from
	StaticDir string `toml:"static-dir"`

	// Location of a log file
	LogFile string `toml:"log-file"`

	// Currently only `lnd` supported
	LnClient string `toml:"ln-client"`

	// Allows for disabling the possibility of on-chain payments.
	OffChainOnly bool `toml:"off-chain-only"`

	// [bitcoind] section in the `--config` file that defines Bitcoind's setup
	Bitcoind Bitcoind `toml:"bitcoind"`

	// [lnd] section in the `--config` file that defines Lnd's setup
	Lnd Lnd `toml:"lnd"`

	// An optional list of user:password pairs that will get granted access to the /history endpoint
	Users map[string]string `toml:"users"`
}

This struct defines the structure of the config .toml file

type Info

type Info struct {
	OnChain  bool     `json:"on-chain"`
	OffChain bool     `json:"off-chain"`
	Uris     []string `json:"uris"`
}

type Invoice

type Invoice struct {
	NewPayment

	Description string `json:"description"`

	// What was the requested amount for the payment
	Amount int64 `json:"amount"`

	// general status of the payment
	Expired bool  `json:"is_expired"`
	Paid    bool  `json:"is_paid"`
	PaidAt  int64 `json:"paid_at"`
}

type Invoices

type Invoices []Invoice

type Lnd

type Lnd struct {
	Host string `toml:"host"`
	Port int64  `toml:"port"`

	// TLS certificate is usually located in `~/.lnd/tls.cert`
	TLS string `toml:"tls"`

	// Macaroons are usually located in `~/.lnd/data/chain/bitcoin/mainnet/`
	Macaroons struct {
		// This is needed to generate new invoices
		Invoice string `toml:"invoice"`

		// This is needed to check status of invoices (and if enabled access `/history` endpoint)
		ReadOnly string `toml:"readonly"`
	} `toml:"macaroon"`

	// How many times try to talk to LND before committing suicide
	KillCount *int `toml:"kill-count"`
}

Lnd config

type NewPayment

type NewPayment struct {
	CreatedAt int64  `json:"created_at"`
	Expiry    int64  `json:"expiry"`
	Bolt11    string `json:"bolt11"`
	Hash      string `json:"hash"`
	Address   string `json:"address"`
}

type Payment

type Payment struct {
	NewPayment

	Description string `json:"description"`

	// The requested amount for the payment
	Amount int64 `json:"amount"`

	// General status of the payment
	Expired bool  `json:"is_expired"`
	Paid    bool  `json:"is_paid"`
	PaidAt  int64 `json:"paid_at,omitempty"`

	// LN specific
	LnPaid bool `json:"ln_paid"`

	// BTC specific
	BtcPaid       bool     `json:"btc_paid"` // only true if amount >= the requested one
	BtcAmount     int64    `json:"btc_amount"`
	Confirmations int64    `json:"confirmations"`
	TxIds         []string `json:"txids"`
}

func (*Payment) ApplyBtc

func (p *Payment) ApplyBtc(s AddrStatus)

func (*Payment) ApplyLn

func (p *Payment) ApplyLn(invoice Invoice)

type Status

type Status struct {
	Ts      int64 `json:"created_at"`
	Settled bool  `json:"is_paid"`
	Expiry  int64 `json:"expiry"`
	Value   int64 `json:"amount"`
}

func (Status) IsExpired

func (s Status) IsExpired() bool

type StatusReply

type StatusReply struct {
	Code    int         `json:"-"`
	Error   string      `json:"error,omitempty"`
	Ln      *Status     `json:"ln,omitempty"`
	Bitcoin *AddrStatus `json:"bitcoin,omitempty"`
}

Jump to

Keyboard shortcuts

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