BCHserialized

class BCHserialized(_format: SerializationType, notCopiedData: ByteArray? = null, sizeHint: Int = 1024)

Constructors

Link copied to clipboard
constructor(contents: ByteArray, _format: SerializationType)
constructor(contents: MutableList<ByteArray>, _format: SerializationType)
constructor(contents: BCHserialized)
constructor(_format: SerializationType, notCopiedData: ByteArray? = null, sizeHint: Int = 1024)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var serPos: Int

Functions

Link copied to clipboard

Append a single character to this object

Append a serialized string to this object

Append a serialized object to this serialized object

Link copied to clipboard

Serialize a bitcoin-style "compact" integer

Link copied to clipboard

Serialize a double according to the IEEE 754 floating-point double format bit layout

Link copied to clipboard

Add these exact bytes to the serialization. (NO LENGTH FIELD : this does not add a serialized byte array)

Link copied to clipboard

Serialize a 32 bit integer into this object

Link copied to clipboard

Serialize a 32 bit integer into this object

Link copied to clipboard

Serialize a 64 bit integer into this object

Link copied to clipboard

serialize the length of the list as a compact int, then each list element. You may use either addlist or addList, the lowercase variant is included to be analogous to delist, which is lowercase because de is a prefix

fun <T> addList(b: List<out T>, Tser: (T, BCHserialized) -> Unit): BCHserialized

serialize the length of the list as a compact int, then each list element. You may use either addlist or addList, the lowercase variant is included to be analogous to delist, which is lowercase because de is a prefix This is more efficient than converting a list into BCHserializable objects first

Link copied to clipboard

serialize the length of the list as a compact int, then each list element. You may use either addlist or addList, the lowercase variant is included to be analogous to delist, which is lowercase because de is a prefix

fun <T> addlist(b: List<out T>, Tser: (T, BCHserialized) -> Unit): BCHserialized
Link copied to clipboard
fun <K, V> addMap(mp: Map<K, V>, Kserializer: (K) -> BCHserialized, Vserializer: (V) -> BCHserialized, format: SerializationType = SerializationType.UNKNOWN): BCHserialized

Serializes a map object with the provided key and value serialization functions

Link copied to clipboard

Append a serialized object to this serialized object Network formats do not support this, but occasionally we serialize into a network format to store as a binary blob on disk

Link copied to clipboard

This API is ambiguous WRT null verses a size 0 byte array

Link copied to clipboard
Link copied to clipboard
fun addUint256(num: BigInteger): BCHserialized
Link copied to clipboard
Link copied to clipboard

Serialize a 64 bit integer into this object

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Return how many bytes are left to be read

Link copied to clipboard

Deserialize a 16 bit BigEndian unsigned integer

Link copied to clipboard
Link copied to clipboard
fun debyte(): Byte

Deserialize an 8 bits (as a signed value)

Link copied to clipboard

Deserialize a variable length array (vector) of bytes Note that the opposite of this (serializing a array of bytes) is ambiguous Do you want to serialize the exact bytes passed, or serialize an array of bytes (that is, indicate the length in the serialization). To serialize an array of bytes (the opposite of this) use the "variableSized" object like this: satoshiSerializedObject + variableSized(yourByteArray)

Link copied to clipboard
fun debytes(into: ByteArray, len: Int, start: Int = 0)

Deserialize certain number of bytes as a ByteArray

Link copied to clipboard
fun dechar(): Char

Deserialize a character

Link copied to clipboard
Link copied to clipboard

Deerialize a double according to the IEEE 754 floating-point double format bit layout

Link copied to clipboard
fun deint32(): Int

Deserialize a 32 bit integer

Link copied to clipboard
fun deint64(): Long

Deserialize a 64 bit signed integer

Link copied to clipboard
fun <T> delist(Tfactory: (BCHserialized) -> T): MutableList<T>

Deserialize a list of some object. You must pass a factory function that takes a buffer and returns an instance of the object (consuming some of the buffer)

Link copied to clipboard
fun <K, V> demap(Kfactory: (BCHserialized) -> K, Vfactory: (BCHserialized) -> V): MutableMap<K, V>

Deserialize a map of key value pair objects. You must pass 2 factory functions that each take a buffer and returns an instance of the key or value object (consuming some of the buffer)

fun <K, V> demap(ret: AbstractMutableMap<K, V>, Kfactory: (BCHserialized) -> K, Vfactory: (BCHserialized) -> V): AbstractMutableMap<K, V>
fun <K, V> demap(ret: HashMap<K, V>, Kfactory: (BCHserialized) -> K, Vfactory: (BCHserialized) -> V): HashMap<K, V>
Link copied to clipboard

Deserialize any object that is nullable, but prepending a byte indicating whether this object is null or not. This API should only be used for DISK serialization because this nullable technique is not part of the network protocol. However, in one case we store to disk the network serialization of an object (if it exists).

Link copied to clipboard

Deserialize a variable length array (vector) of bytes, see deByteArray If the array size is 0, return null

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun deserializeReset(pos: Int = 0)
Link copied to clipboard
Link copied to clipboard
fun deuint16(): Int

Deserialize a 16 bit integer

Link copied to clipboard
fun deuint256(): BigInteger
Link copied to clipboard
fun deuint32(): Long

Deserialize a 32 bit unsigned integer -- must be returned as a long since kotlin integers are signed

Link copied to clipboard
fun deuint64(): Long
Link copied to clipboard
fun deuint8(): Int

Deserialize an 8 bit integer

Link copied to clipboard
fun devarint(): Long
Link copied to clipboard
fun expand(amt: Int = 0)
Link copied to clipboard

calculate the double SHA256 of the data in this object

Link copied to clipboard
fun lazyReset()

If we happen to be at the end of the received data, rewind to the beginning

Link copied to clipboard
operator fun plus(b: Array<out BCHserializable>): BCHserialized

Return a new serialization object that contains this and the serialization of an array of serializable objects

operator fun plus(b: ByteArray): BCHserialized

operator fun plus(s: String?): BCHserialized
operator fun plus(s: variableSized): BCHserialized

Return a new serialization object that contains this and the passed parameter serialized

operator fun plus(b: BCHserialized): BCHserialized

Return a new serialization object that contains this and the passed parameter

Link copied to clipboard
operator fun plusAssign(s: String)

Append a serialized string to this object

Append a serialized object to this serialized object

Link copied to clipboard
fun reserve(amt: Int)
Link copied to clipboard

calculate the SHA256 of the data in this object

Link copied to clipboard

Return an object that allows access to the unconsumed data

Link copied to clipboard
Link copied to clipboard
fun toHex(): String

Return a hex string of this serialized data

Link copied to clipboard