terminus

package
v0.73.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GetInfoMethod is the rpc method for getting info.
	GetInfoMethod = "getinfo"
	// CreateAccountMethod is the create account rpc method.
	CreateAccountMethod = "create"
	// ConnectMethod is the connect rpc method.
	ConnectMethod = "connect"
	// ListenMethod is the listen rpc method.
	ListenMethod = "listen"
)
View Source
const NexusName = "TerminusNexus"

NexusName is the name of the terminus nexus.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v0.54.0

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

Client is the terminus client.

func NewClient

func NewClient(config *config.Config) Client

NewClient creates a new Client for querying the rpc clint.

func (Client) Connect added in v0.54.0

func (t Client) Connect(accountName, beacon string) (res string, err error)

Connect connects an account to a beacon.

func (Client) CreateAccount added in v0.54.0

func (t Client) CreateAccount(msats int) (res string, err error)

CreateAccount creates account with a given number of sats.

func (Client) ExecCmd added in v0.54.0

func (t Client) ExecCmd(method string, argv []string) (res []byte, err error)

ExecCmd executes a command from the Client.

func (Client) GetInfo added in v0.54.0

func (t Client) GetInfo() (res string, err error)

GetInfo gets a list of beacons, accounts, etc.

func (Client) Listen added in v0.54.0

func (t Client) Listen(accountName string) (res string, err error)

Listen listens on a given account.

type Directory added in v0.54.0

type Directory struct {

	// AccountBySharedSeed is a list of accounts by shared seed
	AccountBySharedSeed map[string]account.DB
	// SharedSeedsByAccount is a list of accounts by shared seed
	SharedSeedsByAccount map[string][]beacon.SharedSeed
	// Accounts is a list of accounts
	Accounts map[string]account.DB
	// AccountsByPaymentHash is a list of accounts organized by payment hash
	AccountsByPaymentHash map[string]account.DB
	// contains filtered or unexported fields
}

Directory is a terminus directory that manages account lists/maps.

func NewTerminusDirectory

func NewTerminusDirectory(config *config.Config) *Directory

NewTerminusDirectory gets anew terminus directory.

func (*Directory) AddAccount added in v0.54.0

func (t *Directory) AddAccount(acct account.DB)

AddAccount creates an account.

func (*Directory) GenerateAccountName added in v0.54.0

func (t *Directory) GenerateAccountName() string

GenerateAccountName generates an account name from an autoincrementing int.

func (*Directory) GetAccountList added in v0.54.0

func (t *Directory) GetAccountList() []account.DB

GetAccountList gets a list of accounts.

func (*Directory) GetAccountNameSet added in v0.54.0

func (t *Directory) GetAccountNameSet() (accounts []string)

GetAccountNameSet gets a list of acount names.

func (*Directory) GetAccounts added in v0.54.0

func (t *Directory) GetAccounts() (accounts []account.DB)

GetAccounts python version is an iterator.

func (*Directory) LookupByName added in v0.54.0

func (t *Directory) LookupByName(name string) *account.DB

LookupByName looks up an account by name.

func (*Directory) LookupByPaymentHash added in v0.54.0

func (t *Directory) LookupByPaymentHash(hash string)

LookupByPaymentHash looks up a payment by hash.

func (*Directory) LookupBySeed added in v0.54.0

func (t *Directory) LookupBySeed(seed beacon.SharedSeed) account.DB

LookupBySeed looks up an item by seed.

func (*Directory) ReindexAccount added in v0.54.0

func (t *Directory) ReindexAccount(acct account.DB)

ReindexAccount reindexes an account.

type Layer added in v0.54.0

type Layer struct {
	layer.BaseLayer
	NexusesBySharedSeed map[string][]string
	// contains filtered or unexported fields
}

Layer is the terminus layer TODO this needs to be fully implemented.

func NewTerminusLayer

func NewTerminusLayer() *Layer

NewTerminusLayer creates a new terminus layer.

func (*Layer) AnnounceNexus added in v0.54.0

func (o *Layer) AnnounceNexus(belowNexus nexus.Nexus)

AnnounceNexus creates a new TerminusNexus and registers it.

func (*Layer) HandleInvoiceRequest added in v0.54.0

func (o *Layer) HandleInvoiceRequest(ss beacon.SharedSeed, msats int)

HandleInvoiceRequest handles an invoice request.

func (*Layer) HandlePayRequest added in v0.54.0

func (o *Layer) HandlePayRequest(ss beacon.SharedSeed, bolt11 string)

HandlePayRequest handles a payment request.

func (*Layer) HandleProviderInfoRequest added in v0.54.0

func (o *Layer) HandleProviderInfoRequest(ss beacon.SharedSeed)

HandleProviderInfoRequest processes a provider info request.

func (*Layer) NotifyPreImage added in v0.54.0

func (o *Layer) NotifyPreImage(sharedSeeds []beacon.SharedSeed, preimage string)

NotifyPreImage notifies a preimage.

func (*Layer) RegisterAboveLayer added in v0.54.0

func (o *Layer) RegisterAboveLayer(belowLayer layer.Base)

RegisterAboveLayer registers the current nexuses announce/revoke nexuses to the below layer.

func (*Layer) RevokeNexus added in v0.54.0

func (o *Layer) RevokeNexus(belowNexus nexus.Nexus)

RevokeNexus removes a nexus.

func (*Layer) SetupTerminusNexus added in v0.54.0

func (o *Layer) SetupTerminusNexus(belowNexus nexus.Nexus) *Nexus

SetupTerminusNexus sets up the terminus nexus.

type Nexus added in v0.54.0

type Nexus struct {
	*base.NexusBase
	// contains filtered or unexported fields
}

Nexus is the name of the nexus.

func NewTerminusNexus

func NewTerminusNexus(below nexus.Nexus, layer layer.Base) Nexus

NewTerminusNexus creates a new terminus nexus.

func (Nexus) IsLayerMessage added in v0.54.0

func (o Nexus) IsLayerMessage(message message_base.MoneysocketMessage) bool

IsLayerMessage determines wether or not the message can be handled by the current layer.

func (*Nexus) NotifyPreimage added in v0.54.0

func (o *Nexus) NotifyPreimage(preimage, requestReferenceUUID string)

NotifyPreimage notifies a preimage is ready.

func (*Nexus) NotifyProviderInfo added in v0.54.0

func (o *Nexus) NotifyProviderInfo(ss beacon.SharedSeed)

NotifyProviderInfo sends a provider info notification.

func (*Nexus) OnBinMessage added in v0.54.0

func (o *Nexus) OnBinMessage(belowNexus nexus.Nexus, msgBytes []byte)

OnBinMessage processes a binary message.

func (*Nexus) OnMessage added in v0.54.0

func (o *Nexus) OnMessage(belowNexus nexus.Nexus, message message_base.MoneysocketMessage)

OnMessage processes a message.

type OnStackEvent

type OnStackEvent func(layerName string, nexus nexus.Nexus, status string)

OnStackEvent processes stack events.

type RPCMessage added in v0.54.0

type RPCMessage struct {
	// Method is the rpc method (e.g. connect, listen, etc)
	Method string `json:"method"`
	// Params are any parameters passed in RPCMessage
	Params [][]string `json:"params"`
}

RPCMessage is used for getting messages from the terminus client.

type Stack added in v0.54.0

type Stack struct {
	Config *config.Config
	// contains filtered or unexported fields
}

Stack is the terminus stack.

func NewTerminusStack

func NewTerminusStack(config *config.Config) *Stack

NewTerminusStack creates a terminus stack.

func (*Stack) AnnounceNexus added in v0.54.0

func (s *Stack) AnnounceNexus(terminusNexus Nexus)

AnnounceNexus announces the terminus nexus.

func (*Stack) Connect added in v0.54.0

func (s *Stack) Connect(location location.WebsocketLocation, sharedSeed *beacon.SharedSeed) (*websocket2.OutgoingSocket, error)

Connect connects to a websocket location.

func (*Stack) GetListenLocation added in v0.54.0

func (s *Stack) GetListenLocation() []location.Location

GetListenLocation gets ws listen locations from the config.

func (*Stack) Listen added in v0.54.0

func (s *Stack) Listen() error

Listen listens on the incoming stack.

func (*Stack) LocalConnect added in v0.54.0

func (s *Stack) LocalConnect(sharedSeed beacon.SharedSeed)

LocalConnect connects to a layer by shared seed.

func (*Stack) SendStackEvent added in v0.54.0

func (s *Stack) SendStackEvent(layerName string, nexus nexus.Nexus, status string)

SendStackEvent sends a given event up the stack.

func (*Stack) SetupIncomingStack added in v0.54.0

func (s *Stack) SetupIncomingStack(config *config.Config, localLayer *local.OutgoingLocalLayer) *stack.IncomingStack

SetupIncomingStack sets up an incoming stack3.

func (*Stack) SetupLocalLayer added in v0.54.0

func (s *Stack) SetupLocalLayer() *local.OutgoingLocalLayer

SetupLocalLayer sets up the local layer.

func (*Stack) SetupProviderLayer added in v0.54.0

func (s *Stack) SetupProviderLayer(belowLayer layer.Base) *provider.Layer

SetupProviderLayer sets up a provider layer.

func (*Stack) SetupRendezvousLayer added in v0.54.0

func (s *Stack) SetupRendezvousLayer(belowLayer1 layer.Base, belowLayer2 layer.Base) *rendezvous.OutgoingRendezvousLayer

SetupRendezvousLayer sets up the rendezvous layer.

func (*Stack) SetupTerminusLayer added in v0.54.0

func (s *Stack) SetupTerminusLayer(belowLayer layer.Base) *Layer

SetupTerminusLayer sets up the terminus layer.

func (*Stack) SetupWebsocketLayer added in v0.54.0

func (s *Stack) SetupWebsocketLayer() *websocket.OutgoingWebsocketLayer

SetupWebsocketLayer sets up a websocket layer.

type Terminus

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

Terminus is the app.

func NewTerminus

func NewTerminus(config *config.Config) (terminus Terminus, err error)

NewTerminus creates a Terminus node from a config.

func (*Terminus) Create

func (t *Terminus) Create(msats int) account.DB

Create creates an account with a given number of msats and add it to the directory.

func (*Terminus) GetInfo

func (t *Terminus) GetInfo() (res string)

GetInfo gets formatted info (for python parity).

func (*Terminus) Listen

func (t *Terminus) Listen(rawAcct string, rawSharedSeed string) (encodedBeacon string, err error)

Listen listens on a port. Raw shared seed is optional.

func (*Terminus) LoadPersisted

func (t *Terminus) LoadPersisted()

LoadPersisted loads persisted accounts from the disk.

func (*Terminus) OnAnnounce added in v0.54.0

func (t *Terminus) OnAnnounce(nexus nexus.Nexus)

OnAnnounce handles nexus announcements.

func (*Terminus) OnRevoke added in v0.54.0

func (t *Terminus) OnRevoke(nexus nexus.Nexus)

OnRevoke handles a nexus revoke attempt. Does nothing in terminus.

func (*Terminus) RetryConnectionLoop added in v0.17.0

func (t *Terminus) RetryConnectionLoop()

RetryConnectionLoop retries a connection on a loop.

func (*Terminus) ServeHTTP

func (t *Terminus) ServeHTTP(w http.ResponseWriter, request *http.Request)

ServeHTTP handles requests through the rpc server todo break this out into separate methods.

func (*Terminus) Start

func (t *Terminus) Start(ctx context.Context) error

Start starts the server.

func (*Terminus) StartServer

func (t *Terminus) StartServer() error

StartServer starts the terminus server.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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