cec5fb5357
Move various write methods to a class `BufferWriter`. This allows increased code reuse for libraries that want to implement different serialization formats. Also de-duplicates some code paths and increases test coverage. Original concept by idea by https://github.com/argjv: https://github.com/BitGo/bitgo-utxo-lib/blob/master/src/bufferWriter.js
16 lines
507 B
TypeScript
16 lines
507 B
TypeScript
/**
|
|
* Helper class for serialization of bitcoin data types into a pre-allocated buffer.
|
|
*/
|
|
export declare class BufferWriter {
|
|
buffer: Buffer;
|
|
offset: number;
|
|
constructor(buffer: Buffer, offset?: number);
|
|
writeUInt8(i: number): void;
|
|
writeInt32(i: number): void;
|
|
writeUInt32(i: number): void;
|
|
writeUInt64(i: number): void;
|
|
writeVarInt(i: number): void;
|
|
writeSlice(slice: Buffer): void;
|
|
writeVarSlice(slice: Buffer): void;
|
|
writeVector(vector: Buffer[]): void;
|
|
}
|