util

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

in a seperate package because this is used by beacon/locations and beacon/root this should probably be moved to internal if moneysocket (socket) is ever moved to its own package

Index

Constants

View Source
const (
	// types cannot be less than 2^16 according to bolt-1 https://git.io/JLCRq
	TlvMinimum = 65536
	// starting value is 2^16+443 and will increment by 2 for new types https://git.io/JLCRc
	TlvTypeStart = TlvMinimum + 443
	// tlv type for a beacon
	BeaconTlvType tlv.Type = TlvTypeStart
	// tlv type for a shared type
	SharedSeedTlvType tlv.Type = TlvTypeStart + 2
	// tlv type for a location count
	LocationCountTlvType tlv.Type = TlvTypeStart + 4
	// tlv type for a list
	LocationListTlvType tlv.Type = TlvTypeStart + 6
	// location websockets
	WebsocketLocationTlvType tlv.Type = TlvTypeStart + 8
	// TODO beacons/__init.py https://git.io/JLC0J
	WebrtcLocationTlvType = TlvTypeStart + 10
	// TODO beacons/__init__.py https://git.io/JLC0I
	BluetoothLocationTlvType tlv.Type = TlvTypeStart + 12
	// TODO beacons/__init__.py https://git.io/JLC0g
	NfcLocationTlvType tlv.Type = TlvTypeStart + 14
)

Variables

list of all custom implemented tlv types in the package

Functions

func DVarInt

func DVarInt(r io.Reader, val interface{}, _ *[8]byte, l uint64) error

DVarBytes is a Decoder for variable byte slices. An error is returned if val is not *[]byte.

func EVarInt

func EVarInt(w io.Writer, val interface{}, b *[8]byte) error

EVarInt is an Encoder for variable byte slices. An error is returned if val is not *[]byte.

func NamespaceTlvsAreValid

func NamespaceTlvsAreValid(byteString []byte) bool

assert tlvs are valid

Types

type Tlv

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

For encoding/decoding values to/from Tlv (Type-Length-Value) byte strings as defined in: https://github.com/lightningnetwork/lightning-rfc/blob/master/01-messaging.md#type-length-value-format note: I tried to use the golang implementation, but didn't quite get the sreaming encodes/decodes to work. this can be fixed in a future version

func NamespaceIterTlvs

func NamespaceIterTlvs(byteString []byte) (tlvs []Tlv, err error)

func NamespacePopTlvs

func NamespacePopTlvs(byteString []byte) (t Tlv, remainder []byte, err error)

Represents a specific namespace of TLVs as referred to in BOLT 1 and provides generic pop helpers for the fundamental types defined here: https://github.com/lightningnetwork/lightning-rfc/blob/master/01-messaging.md#fundamental-types see: https://github.com/moneysocket/py-moneysocket/blob/main/moneysocket/utl/third_party/bolt/namespace.py#L9

func NewTlv

func NewTlv(t tlvHelper.Type, v []byte) (res Tlv)

func TlvPop

func TlvPop(byteString []byte) (tlv Tlv, remainder []byte, err error)

func (Tlv) Length

func (tlv Tlv) Length() int

get l of tlv.t

func (Tlv) Type

func (tlv Tlv) Type() tlvHelper.Type

get tlv.type

func (Tlv) Value

func (tlv Tlv) Value() []byte

get value of tlv

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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