lnsocket

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommandoCmd            = 0x4c4f
	CommandoReplyContinues = 0x594b
	CommandoReplyTerm      = 0x594d
)

Commando message types

Variables

This section is empty.

Functions

func GenRandomBytes

func GenRandomBytes(size int) (blk []byte, err error)

GenRandomBytes gets random bytes

func GetMandatoryFeatures

func GetMandatoryFeatures(init *lnwire.Init) map[lnwire.FeatureBit]struct{}

GetMandatoryFeatures gets mandatory features

func ParseMsgType

func ParseMsgType(bytes []byte) uint16

ParseMsgType parses the type of message

func ToRawFeatureVector

func ToRawFeatureVector(features map[lnwire.FeatureBit]struct{}) *lnwire.RawFeatureVector

ToRawFeatureVector gets a raw feature vector

Types

type CommandoMsg

type CommandoMsg struct {
	Rune      string
	Method    string
	Params    string
	RequestID uint64
}

CommandoMsg struct

func NewCommandoMsg

func NewCommandoMsg(token string, method string, params string) CommandoMsg

NewCommandoMsg creates a new commando message

func (*CommandoMsg) Decode

func (msg *CommandoMsg) Decode(reader io.Reader, size uint32) error

Decode API

func (*CommandoMsg) Encode

func (msg *CommandoMsg) Encode(buf *bytes.Buffer, pver uint32) error

Encode API

func (*CommandoMsg) MsgType

func (msg *CommandoMsg) MsgType() lnwire.MessageType

MsgType API

type LN

type LN struct {
	Conn        net.Conn
	PrivKeyECDH *keychain.PrivKeyECDH
	Proxy       *tor.ProxyNet
	Timeout     time.Duration
}

LN struct - heavily borrowed from https://github.com/jb55/lnsocket/blob/master/go/lnsocket.go

func NewLN

func NewLN(timeout time.Duration) *LN

NewLN creates a new LN instance

func (*LN) Clone

func (ln *LN) Clone() *LN

Clone copies the given LN instance to new onne

func (*LN) CommandoReadAll

func (ln *LN) CommandoReadAll(ctx context.Context, rune, serviceMethod, params string, timeout time.Duration) (string, error)

CommandoReadAll reads complete commando response as string - used with internal lib

func (*LN) Connect

func (ln *LN) Connect(endpoint string) error

Connect connects to pubkey@host

func (*LN) DeserializeKey

func (ln *LN) DeserializeKey(key string) error

DeserializeKey deserializes the private key from base64

func (*LN) Disconnect

func (ln *LN) Disconnect()

Disconnect disconnect

func (*LN) GenKey

func (ln *LN) GenKey()

GenKey generates a keypair

func (*LN) Handshake

func (ln *LN) Handshake() error

Handshake performs a handshake

func (*LN) NewCommandoReader

func (ln *LN) NewCommandoReader(ctx context.Context, rune, serviceMethod, params string, timeout time.Duration) (io.Reader, error)

NewCommandoReader invokes a command and retruns a reader to read reply

func (*LN) Ping

func (ln *LN) Ping() error

Ping sends a ping message

func (*LN) Read

func (ln *LN) Read() (uint16, []byte, error)

Read reads from connection

func (*LN) SerializeKey

func (ln *LN) SerializeKey() string

SerializeKey serializes the private key to base64

func (*LN) Write

func (ln *LN) Write(b []byte) (int, error)

Write writes to connection

Jump to

Keyboard shortcuts

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