lightning

package
v0.0.0-...-4a639d8 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NONE = 0

	FailPaymentPending = iota + 1
	FailPaymentFailed  = iota + 2
	FailPaymentUnknown = iota + 3

	FailQueryPending = iota + 4
	FailQueryFailed  = iota + 5
	FailQueryUnknown = iota + 6
)
View Source
const (
	MAINNET = "mainnet"
	REGTEST = "regtest"
	TESTNET = "testnet"
	SIGNET  = "signet"
)

Variables

View Source
var (
	ErrAlreadyPaid = errors.New("Invoice already paid")
)
View Source
var ErrLnbitsFailedPayment = errors.New("failed payment")

Functions

func CreateMockInvoice

func CreateMockInvoice(amountSats int64, description string, network chaincfg.Params, expiry int64) (string, error)

func GetAverageRouteFee

func GetAverageRouteFee(routes []*lnrpc.Route) uint64

Types

type Backend

type Backend uint
const CLNGRPC Backend = iota + 3
const FAKEWALLET Backend = iota + 4
const LNBITS Backend = iota + 2
const LNDGRPC Backend = iota + 1

type CLNGRPCWallet

type CLNGRPCWallet struct {
	Network chaincfg.Params
	// contains filtered or unexported fields
}

func (CLNGRPCWallet) ActiveMPP

func (f CLNGRPCWallet) ActiveMPP() bool

func (CLNGRPCWallet) CheckPayed

func (l CLNGRPCWallet) CheckPayed(quote string) (PaymentStatus, string, error)

func (CLNGRPCWallet) GetNetwork

func (f CLNGRPCWallet) GetNetwork() *chaincfg.Params

func (CLNGRPCWallet) LightningType

func (f CLNGRPCWallet) LightningType() Backend

func (CLNGRPCWallet) PayInvoice

func (l CLNGRPCWallet) PayInvoice(invoice string, zpayInvoice *zpay32.Invoice, feeReserve uint64, mpp bool, amount_sat uint64) (PaymentResponse, error)

func (CLNGRPCWallet) QueryFees

func (l CLNGRPCWallet) QueryFees(invoice string, zpayInvoice *zpay32.Invoice, mpp bool, amount_sat uint64) (uint64, error)

func (CLNGRPCWallet) RequestInvoice

func (l CLNGRPCWallet) RequestInvoice(amount int64) (InvoiceResponse, error)

func (*CLNGRPCWallet) SetupGrpc

func (l *CLNGRPCWallet) SetupGrpc(host string, caCert string, clientCert string, clientKey string, macaroon string) error

func (CLNGRPCWallet) WalletBalance

func (l CLNGRPCWallet) WalletBalance() (uint64, error)

type FakeWallet

type FakeWallet struct {
	Network         chaincfg.Params
	UnpurposeErrors []FakeWalletError
}

func (FakeWallet) ActiveMPP

func (f FakeWallet) ActiveMPP() bool

func (FakeWallet) CheckPayed

func (f FakeWallet) CheckPayed(quote string) (PaymentStatus, string, error)

func (FakeWallet) GetNetwork

func (f FakeWallet) GetNetwork() *chaincfg.Params

func (FakeWallet) LightningType

func (f FakeWallet) LightningType() Backend

func (FakeWallet) PayInvoice

func (f FakeWallet) PayInvoice(invoice string, zpayInvoice *zpay32.Invoice, feeReserve uint64, mpp bool, amount_sat uint64) (PaymentResponse, error)

func (FakeWallet) QueryFees

func (f FakeWallet) QueryFees(invoice string, zpayInvoice *zpay32.Invoice, mpp bool, amount_sat uint64) (uint64, error)

func (FakeWallet) RequestInvoice

func (f FakeWallet) RequestInvoice(amount int64) (InvoiceResponse, error)

func (FakeWallet) WalletBalance

func (f FakeWallet) WalletBalance() (uint64, error)

type FakeWalletError

type FakeWalletError int

type InvoiceResponse

type InvoiceResponse struct {
	PaymentRequest string
	Rhash          string
}

type LNBitsDetailErrorData

type LNBitsDetailErrorData struct {
	Detail string
	Status string
}

type LNBitsPaymentStatus

type LNBitsPaymentStatus struct {
	Paid     bool   `json:"paid"`
	Pending  bool   `json:"pending"`
	Preimage string `json:"preimage"`
	Details  LNBitsPaymentStatusDetail
}

type LNBitsPaymentStatusDetail

type LNBitsPaymentStatusDetail struct {
	Memo    string
	Fee     int64
	Pending bool
}

type LightningBackend

type LightningBackend interface {
	PayInvoice(invoice string, zpayInvoice *zpay32.Invoice, feeReserve uint64, mpp bool, amount_sat uint64) (PaymentResponse, error)
	CheckPayed(quote string) (PaymentStatus, string, error)
	QueryFees(invoice string, zpayInvoice *zpay32.Invoice, mpp bool, amount_sat uint64) (uint64, error)
	RequestInvoice(amount int64) (InvoiceResponse, error)
	WalletBalance() (uint64, error)
	LightningType() Backend
	GetNetwork() *chaincfg.Params
	ActiveMPP() bool
}

type LnbitsWallet

type LnbitsWallet struct {
	Network  chaincfg.Params
	Endpoint string
	Key      string
}

func (LnbitsWallet) ActiveMPP

func (f LnbitsWallet) ActiveMPP() bool

func (LnbitsWallet) CheckPayed

func (l LnbitsWallet) CheckPayed(quote string) (PaymentStatus, string, error)

func (LnbitsWallet) GetNetwork

func (f LnbitsWallet) GetNetwork() *chaincfg.Params

func (LnbitsWallet) LightningType

func (f LnbitsWallet) LightningType() Backend

func (*LnbitsWallet) LnbitsRequest

func (l *LnbitsWallet) LnbitsRequest(method string, endpoint string, reqBody any, responseType any) error

func (LnbitsWallet) PayInvoice

func (l LnbitsWallet) PayInvoice(invoice string, zpayInvoice *zpay32.Invoice, feeReserve uint64, mpp bool, amount_sat uint64) (PaymentResponse, error)

func (LnbitsWallet) QueryFees

func (l LnbitsWallet) QueryFees(invoice string, zpayInvoice *zpay32.Invoice, mpp bool, amount_sat uint64) (uint64, error)

func (LnbitsWallet) RequestInvoice

func (l LnbitsWallet) RequestInvoice(amount int64) (InvoiceResponse, error)

func (LnbitsWallet) WalletBalance

func (l LnbitsWallet) WalletBalance() (uint64, error)

type LndGrpcWallet

type LndGrpcWallet struct {
	Network chaincfg.Params
	// contains filtered or unexported fields
}

func (LndGrpcWallet) ActiveMPP

func (f LndGrpcWallet) ActiveMPP() bool

func (LndGrpcWallet) CheckPayed

func (l LndGrpcWallet) CheckPayed(quote string) (PaymentStatus, string, error)

func (LndGrpcWallet) GetNetwork

func (f LndGrpcWallet) GetNetwork() *chaincfg.Params

func (LndGrpcWallet) LightningType

func (f LndGrpcWallet) LightningType() Backend

func (LndGrpcWallet) PayInvoice

func (l LndGrpcWallet) PayInvoice(invoice string, zpayInvoice *zpay32.Invoice, feeReserve uint64, mpp bool, amount_sat uint64) (PaymentResponse, error)

func (LndGrpcWallet) QueryFees

func (l LndGrpcWallet) QueryFees(invoice string, zpayInvoice *zpay32.Invoice, mpp bool, amount_sat uint64) (uint64, error)

func (LndGrpcWallet) RequestInvoice

func (l LndGrpcWallet) RequestInvoice(amount int64) (InvoiceResponse, error)

func (*LndGrpcWallet) SetupGrpc

func (l *LndGrpcWallet) SetupGrpc(host string, macaroon string, tlsCrt string) error

func (LndGrpcWallet) WalletBalance

func (l LndGrpcWallet) WalletBalance() (uint64, error)

type PaymentResponse

type PaymentResponse struct {
	Preimage       string
	PaymentRequest string
	PaymentState   PaymentStatus
	Rhash          string
	PaidFeeSat     int64
}

type PaymentStatus

type PaymentStatus uint
const FAILED PaymentStatus = iota + 2
const PENDING PaymentStatus = iota + 3
const SETTLED PaymentStatus = iota + 1
const UNKNOWN PaymentStatus = iota + 999

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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