lncore

package
v0.0.0-...-8c3d3b4 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: MIT Imports: 2 Imported by: 5

README

lit/lncore

This package, lncore, makes up the base of a bunch of stuff used across Lit, including database interface.

Documentation

Index

Constants

View Source
const (
	// CstateInit means it hasn't been broadcast yet.
	CstateInit = 0

	// CstateUnconfirmed means it's been broadcast but not included yet.
	CstateUnconfirmed = 1

	// CstateOK means it's been included and the channel is active.
	CstateOK = 2

	// CstateClosing means the close tx has been broadcast but not included yet.
	CstateClosing = 3

	// CstateBreaking means it's the break tx has been broadcast but not included and spendable yet.
	CstateBreaking = 4

	// CstateClosed means nothing else should be done with the channel anymore.
	CstateClosed = 5

	// CstateError means something went horribly wrong and we may need extra intervention.
	CstateError = 255
)

Variables

This section is empty.

Functions

func AreCoinsCompatible

func AreCoinsCompatible(a, b CoinSpecific) bool

AreCoinsCompatible checks to see if two coin-specific objects are for the same coin.

Types

type ChannelHandle

type ChannelHandle [64]byte

ChannelHandle is "something" to concisely uniquely identify a channel. Usually just a txid.

type ChannelInfo

type ChannelInfo struct {
	PeerAddr   string       `json:"peeraddr"`
	CoinType   int32        `json:"cointype"`
	State      ChannelState `json:"state"`
	OpenTx     []byte       `json:"opentx"`     // should this be here?
	OpenHeight int32        `json:"openheight"` // -1 if unconfirmed

}

ChannelInfo .

type ChannelState

type ChannelState uint8

ChannelState .

type CoinAddress

type CoinAddress struct {
	// contains filtered or unexported fields
}

type CoinSpecific

type CoinSpecific interface {
	GetCoinTypeId() int32
	Bytes() []byte
}

CoinSpecific is a meta-interface for coin-specific types.

type LitChannelStorage

type LitChannelStorage interface {
	GetChannel(handle ChannelHandle) (*ChannelInfo, error)
	GetChannelHandles() ([]ChannelHandle, error)
	GetChannels() ([]ChannelInfo, error)

	AddChannel(handle ChannelHandle, info ChannelInfo) error
	UpdateChannel(handle ChannelHandle, info ChannelInfo) error
	ArchiveChannel(handle ChannelHandle) error

	GetArchivedChannelHandles() ([]ChannelHandle, error)
}

LitChannelStorage .

type LitPeerStorage

type LitPeerStorage interface {
	GetPeerAddrs() ([]LnAddr, error)
	GetPeerInfo(addr LnAddr) (*PeerInfo, error)
	GetPeerInfos() (map[LnAddr]PeerInfo, error)
	AddPeer(addr LnAddr, pi PeerInfo) error
	UpdatePeer(addr LnAddr, pi *PeerInfo) error
	DeletePeer(addr LnAddr) error

	// TEMP Until we figure this all out.
	GetUniquePeerIdx() (uint32, error)
}

LitPeerStorage is storage for peer data.

type LitStorage

type LitStorage interface {
	Open(dbpath string) error
	IsSingleFile() bool
	Close() error

	GetWalletDB(uint32) LitWalletStorage
	GetPeerDB() LitPeerStorage
	GetChannelDB() LitChannelStorage

	Check() error
}

LitStorage is an abstract wrapper layer around an arbitrary database.

type LitWalletStorage

type LitWalletStorage interface {
	CoinSpecific

	GetAddresses() ([]CoinAddress, error)

	GetUtxos() ([]Utxo, error)
	AddUtxo(Utxo) error
	RemoveUtxo(Utxo) error
}

LitWalletStorage is storage for wallet data.

type LnAddr

type LnAddr string

LnAddr is just a bech32-encoded pubkey. TODO Move this to another package so it's more obviously not *just* IO-related.

func ParseLnAddr

func ParseLnAddr(m string) (LnAddr, error)

ParseLnAddr will verify that the string passed is a valid LN address, as in ln1pmclh89haeswrw0unf8awuyqeu4t2uell58nea.

func (LnAddr) ToString

func (lnaddr LnAddr) ToString() string

ToString returns the LnAddr as a string. Right now it just unwraps it but it might do something more eventually.

type PeerInfo

type PeerInfo struct {
	LnAddr   *LnAddr `json:"lnaddr"`
	Nickname *string `json:"name"`
	NetAddr  *string `json:"netaddr"` // ip address, port, I guess

	// TEMP This is again, for adapting to the old system.
	PeerIdx uint32 `json:"hint_peeridx"`
}

PeerInfo .

type Txid

type Txid struct {
	// contains filtered or unexported fields
}

Txid represents a transaction on the blockchain.

type Utxo

type Utxo struct {
	Txid
}

Utxo is an unspent transaction output that we could be able to spend.

Jump to

Keyboard shortcuts

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