lightning

package
v0.0.0-...-1bcd00c Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2021 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LatestVersion is the latest version used for minting new LSATs.
	LatestVersion = 0

	// SecretSize is the size in bytes of a LSAT's secret, also known as
	// the root key of the macaroon.
	SecretSize = 32

	// TokenIDSize is the size in bytes of an LSAT's ID encoded in its
	// macaroon identifier.
	TokenIDSize = 32
)
View Source
const (
	// PreimageKey is the key used for a payment preimage caveat.
	PreimageKey = "preimage"
)

Variables

View Source
var (
	// ErrInvalidCaveat is an error returned when we attempt to decode a
	// caveat with an invalid format.
	ErrInvalidCaveat = errors.New("caveat must be of the form " +
		"\"condition=value\"")
)
View Source
var (

	// ErrUnknownVersion is an error returned when attempting to decode an
	// LSAT identifier with an unknown version.
	ErrUnknownVersion = errors.New("unknown LSAT version")
)

Functions

func AddFirstPartyCaveats

func AddFirstPartyCaveats(m *macaroon.Macaroon, caveats ...Caveat) error

AddFirstPartyCaveats adds a set of caveats as first-party caveats to a macaroon.

func EncodeCaveat

func EncodeCaveat(c Caveat) string

EncodeCaveat encodes a caveat into its string representation.

func EncodeIdentifier

func EncodeIdentifier(w io.Writer, id *Identifier) error

EncodeIdentifier encodes an LSAT's identifier according to its version.

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GetCurrentFuncName

func GetCurrentFuncName(numCallStack int) string

GetCurrentFuncName : get name of function being called

func GetIpFromUri

func GetIpFromUri(uri string) string

func HasCaveat

func HasCaveat(m *macaroon.Macaroon, cond string) (string, bool)

HasCaveat checks whether the given macaroon has a caveat with the given condition, and if so, returns its value. If multiple caveats with the same condition exist, then the value of the last one is returned.

func IsLnUri

func IsLnUri(uri string) bool

Types

type Caveat

type Caveat struct {
	// Condition serves as a way to identify a caveat and how to satisfy it.
	Condition string

	// Value is what will be used to satisfy a caveat. This can be as
	// flexible as needed, as long as it can be encoded into a string.
	Value string
}

Caveat is a predicate that can be applied to an LSAT in order to restrict its use in some form. Caveats are evaluated during LSAT verification after the LSAT's signature is verified. The predicate of each caveat must hold true in order to successfully validate an LSAT.

func DecodeCaveat

func DecodeCaveat(s string) (Caveat, error)

DecodeCaveat decodes a caveat from its string representation.

func NewCaveat

func NewCaveat(condition string, value string) Caveat

NewCaveat construct a new caveat with the given condition and value.

func (Caveat) String

func (c Caveat) String() string

String returns a user-friendly view of a caveat.

type Identifier

type Identifier struct {
	// Version is the version of an LSAT. Having a version allows us to
	// introduce new fields to the identifier in a backwards-compatible
	// manner.
	Version uint16

	// PaymentHash is the payment hash linked to an LSAT. Verification of
	// an LSAT depends on a valid payment, which is enforced by ensuring a
	// preimage is provided that hashes to our payment hash.
	PaymentHash lntypes.Hash

	// TokenID is the unique identifier of an LSAT.
	TokenID TokenID
}

Identifier contains the static identifying details of an LSAT. This is intended to be used as the identifier of the macaroon within an LSAT.

func DecodeIdentifier

func DecodeIdentifier(r io.Reader) (*Identifier, error)

DecodeIdentifier decodes an LSAT's identifier according to its version.

type LSAT

type LSAT struct {
	ID       TokenID
	Preimage []byte
	PayHash  []byte
	Invoice  string
	Value    int64
	Macaroon macaroon.Macaroon
}

func FromHeader

func FromHeader(header *http.Header) (LSAT, error)

func (*LSAT) ToChallenge

func (lsat *LSAT) ToChallenge() string

func (*LSAT) ToToken

func (lsat *LSAT) ToToken() string

type LnClient

type LnClient struct {
	ServerHostPort string
	TlsPath        string
	MacPath        string
	MinConfs       int64
	TargetConfs    int64
	Logger         log.Logger
	Testnet        bool
	WalletAddress  string
	WalletPass     string
	LastFee        int64
	HashPrice      int64
	SessionSecret  string
}

func CreateClient

func CreateClient(serverHostPort string, tlsPath string, macPath string) LnClient

func (*LnClient) AddPeer

func (ln *LnClient) AddPeer(peer string) error

func (*LnClient) AnchorData

func (ln *LnClient) AnchorData(hash []byte) (string, string, error)

func (*LnClient) ChannelExists

func (ln *LnClient) ChannelExists(peer string, satVal int64) (bool, error)

func (*LnClient) CreateChannel

func (ln *LnClient) CreateChannel(peer string, satVal int64) (lnrpc.Lightning_OpenChannelClient, error)

func (*LnClient) CreateConn

func (ln *LnClient) CreateConn() (*grpc.ClientConn, error)

func (*LnClient) GenerateHodlLSAT

func (ln *LnClient) GenerateHodlLSAT(ip string) (LSAT, error)

func (*LnClient) GetBlockByHash

func (ln *LnClient) GetBlockByHash(hash string) (lnrpc.BlockDetails, error)

func (*LnClient) GetBlockByHeight

func (ln *LnClient) GetBlockByHeight(height int64) (lnrpc.BlockDetails, error)

func (*LnClient) GetChannels

func (ln *LnClient) GetChannels() (*lnrpc.ListChannelsResponse, error)

func (*LnClient) GetClient

func (ln *LnClient) GetClient() (lnrpc.LightningClient, func(), error)

func (*LnClient) GetInfo

func (ln *LnClient) GetInfo() (*lnrpc.GetInfoResponse, error)

func (*LnClient) GetInvoiceClient

func (ln *LnClient) GetInvoiceClient() (invoicesrpc.InvoicesClient, func(), error)

func (*LnClient) GetLndFeeEstimate

func (ln *LnClient) GetLndFeeEstimate() (int64, error)

func (*LnClient) GetPendingChannels

func (ln *LnClient) GetPendingChannels() (*lnrpc.PendingChannelsResponse, error)

func (*LnClient) GetTransaction

func (ln *LnClient) GetTransaction(id []byte) (lnrpc.TransactionDetails, error)

func (*LnClient) GetWalletBalance

func (ln *LnClient) GetWalletBalance() (*lnrpc.WalletBalanceResponse, error)

func (*LnClient) GetWalletClient

func (ln *LnClient) GetWalletClient() (walletrpc.WalletKitClient, func(), error)

func (*LnClient) GetWalletUnlockerClient

func (ln *LnClient) GetWalletUnlockerClient() (lnrpc.WalletUnlockerClient, func(), error)

func (*LnClient) LoggerError

func (ln *LnClient) LoggerError(err error) error

LoggerError : Log error if it exists using a logger

func (*LnClient) LookupInvoice

func (ln *LnClient) LookupInvoice(payhash []byte) (lnrpc.Invoice, error)

func (*LnClient) OurChannelOpenAndFunded

func (ln *LnClient) OurChannelOpenAndFunded(peer string, satVal int64) (bool, error)

func (*LnClient) PeerExists

func (ln *LnClient) PeerExists(peer string) (bool, error)

func (*LnClient) RemoteChannelOpenAndFunded

func (ln *LnClient) RemoteChannelOpenAndFunded(peer string, satVal int64) (bool, error)

func (*LnClient) ReplaceByFee

func (ln *LnClient) ReplaceByFee(txid string, OPRETURNIndex bool, newfee int) (walletrpc.BumpFeeResponse, error)

func (*LnClient) SendCoins

func (ln *LnClient) SendCoins(addr string, amt int64, confs int32) (lnrpc.SendCoinsResponse, error)

func (*LnClient) Unlocker

func (ln *LnClient) Unlocker() error

type TokenID

type TokenID [TokenIDSize]byte

TokenID is the type that stores the token identifier of an LSAT token.

func MakeIDFromString

func MakeIDFromString(newID string) (TokenID, error)

MakeIDFromString parses the hex encoded string and parses it into a token ID.

func (*TokenID) String

func (t *TokenID) String() string

String returns the hex encoded representation of the token ID as a string.

Jump to

Keyboard shortcuts

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