Documentation ¶
Index ¶
- Constants
- Variables
- func AddFirstPartyCaveats(m *macaroon.Macaroon, caveats ...Caveat) error
- func EncodeCaveat(c Caveat) string
- func EncodeIdentifier(w io.Writer, id *Identifier) error
- func GenerateRandomBytes(n int) ([]byte, error)
- func GetCurrentFuncName(numCallStack int) string
- func GetIpFromUri(uri string) string
- func HasCaveat(m *macaroon.Macaroon, cond string) (string, bool)
- func IsLnUri(uri string) bool
- type Caveat
- type Identifier
- type LSAT
- type LnClient
- func (ln *LnClient) AddPeer(peer string) error
- func (ln *LnClient) AnchorData(hash []byte) (string, string, error)
- func (ln *LnClient) ChannelExists(peer string, satVal int64) (bool, error)
- func (ln *LnClient) CreateChannel(peer string, satVal int64) (lnrpc.Lightning_OpenChannelClient, error)
- func (ln *LnClient) CreateConn() (*grpc.ClientConn, error)
- func (ln *LnClient) GenerateHodlLSAT(ip string) (LSAT, error)
- func (ln *LnClient) GetBlockByHash(hash string) (lnrpc.BlockDetails, error)
- func (ln *LnClient) GetBlockByHeight(height int64) (lnrpc.BlockDetails, error)
- func (ln *LnClient) GetChannels() (*lnrpc.ListChannelsResponse, error)
- func (ln *LnClient) GetClient() (lnrpc.LightningClient, func(), error)
- func (ln *LnClient) GetInfo() (*lnrpc.GetInfoResponse, error)
- func (ln *LnClient) GetInvoiceClient() (invoicesrpc.InvoicesClient, func(), error)
- func (ln *LnClient) GetLndFeeEstimate() (int64, error)
- func (ln *LnClient) GetPendingChannels() (*lnrpc.PendingChannelsResponse, error)
- func (ln *LnClient) GetTransaction(id []byte) (lnrpc.TransactionDetails, error)
- func (ln *LnClient) GetWalletBalance() (*lnrpc.WalletBalanceResponse, error)
- func (ln *LnClient) GetWalletClient() (walletrpc.WalletKitClient, func(), error)
- func (ln *LnClient) GetWalletUnlockerClient() (lnrpc.WalletUnlockerClient, func(), error)
- func (ln *LnClient) LoggerError(err error) error
- func (ln *LnClient) LookupInvoice(payhash []byte) (lnrpc.Invoice, error)
- func (ln *LnClient) OurChannelOpenAndFunded(peer string, satVal int64) (bool, error)
- func (ln *LnClient) PeerExists(peer string) (bool, error)
- func (ln *LnClient) RemoteChannelOpenAndFunded(peer string, satVal int64) (bool, error)
- func (ln *LnClient) ReplaceByFee(txid string, OPRETURNIndex bool, newfee int) (walletrpc.BumpFeeResponse, error)
- func (ln *LnClient) SendCoins(addr string, amt int64, confs int32) (lnrpc.SendCoinsResponse, error)
- func (ln *LnClient) Unlocker() error
- type TokenID
Constants ¶
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 )
const (
// PreimageKey is the key used for a payment preimage caveat.
PreimageKey = "preimage"
)
Variables ¶
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\"") )
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 ¶
AddFirstPartyCaveats adds a set of caveats as first-party caveats to a macaroon.
func EncodeCaveat ¶
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 ¶
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 ¶
GetCurrentFuncName : get name of function being called
func GetIpFromUri ¶
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 ¶
DecodeCaveat decodes a caveat from its string representation.
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 (*LSAT) ToChallenge ¶
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 (*LnClient) ChannelExists ¶
func (*LnClient) CreateChannel ¶
func (*LnClient) CreateConn ¶
func (ln *LnClient) CreateConn() (*grpc.ClientConn, 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) GetInvoiceClient ¶
func (ln *LnClient) GetInvoiceClient() (invoicesrpc.InvoicesClient, func(), error)
func (*LnClient) GetLndFeeEstimate ¶
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 ¶
LoggerError : Log error if it exists using a logger
func (*LnClient) LookupInvoice ¶
func (*LnClient) OurChannelOpenAndFunded ¶
func (*LnClient) RemoteChannelOpenAndFunded ¶
func (*LnClient) ReplaceByFee ¶
type TokenID ¶
type TokenID [TokenIDSize]byte
TokenID is the type that stores the token identifier of an LSAT token.
func MakeIDFromString ¶
MakeIDFromString parses the hex encoded string and parses it into a token ID.