Documentation ¶
Overview ¶
Package util contains helpers for encoding/decoding tlvs to maintain parity with other moneysocket implementations
Index ¶
Constants ¶
const ( // TLVMinimum is the minimum tlv value // types cannot be less than 2^16 according to bolt-1 https://git.io/JLCRq TLVMinimum = 65536 // TLVTypeStart is the starting value is 2^16+443 and // will increment by 2 for new types https://git.io/JLCRc TLVTypeStart = TLVMinimum + 443 // BeaconTLVType is the tlv type for a beacon. BeaconTLVType tlv.Type = TLVTypeStart SharedSeedTLVType tlv.Type = TLVTypeStart + 2 // LocationCountTLVType is the tlv type for a location count. LocationCountTLVType tlv.Type = TLVTypeStart + 4 // LocationListTLVType is the tkv type that prefixes a list of tlv locations. LocationListTLVType tlv.Type = TLVTypeStart + 6 // WebsocketLocationTLVType is the tlv type used for websockets. WebsocketLocationTLVType tlv.Type = TLVTypeStart + 8 // WebRTCLocationTLVType is the tlv type of a web rtc location // TODO beacons/__init.py https://git.io/JLC0J WebRTCLocationTLVType = TLVTypeStart + 10 // BluetoothLocationTLVType is the bluetooth location tlv type // TODO beacons/__init__.py https://git.io/JLC0I BluetoothLocationTLVType tlv.Type = TLVTypeStart + 12 // NFCLocationTLVType is the tlv type of an nfc loation tlv // TODO beacons/__init__.py https://git.io/JLC0g NFCLocationTLVType tlv.Type = TLVTypeStart + 14 )
Variables ¶
var TLVTypes = []tlv.Type{BeaconTLVType, SharedSeedTLVType, LocationCountTLVType, LocationListTLVType, WebsocketLocationTLVType, WebRTCLocationTLVType, BluetoothLocationTLVType, NFCLocationTLVType}
TLVTypes is a list of all custom implemented tlv types in the package.
Functions ¶
func DVarInt ¶
DVarInt is a Decoder for variable byte slices. An error is returned if val is not *[]byte. This is not currently implemented since these kinds of decodings are done manually using the bigsize module.
func EVarInt ¶
EVarInt is an Encoder for variable byte slices. An error is returned if val is not *[]byte.
func NamespaceTLVsAreValid ¶ added in v0.40.0
NamespaceTLVsAreValid will determine if a bytestring contains valid tlvs.
Types ¶
type TLV ¶ added in v0.40.0
type TLV struct {
// contains filtered or unexported fields
}
TLV is used for encoding/decoding values to/from TLV (Type-Length-Value) byte strings as defined in: https://git.io/JmwOl note: I tried to use the golang implementation, but didn't quite get the streaming encodes/decodes to work. this can be fixed in a future version.
func NamespaceIterTLVs ¶ added in v0.40.0
NamespaceIterTLVs will iterate over the namespaces in a byteString returns error if all are not valid.
func NamespacePopTLVs ¶ added in v0.40.0
NamespacePopTLVs Represents a specific namespace of TLVs as referred to in BOLT 1 and provides generic pop helpers for the fundamental types defined here: https://git.io/JmwOJ and https://git.io/JmwOk