bitcoinjs-lib/types/buffer_writer.d.ts
Otto Allmendinger cec5fb5357
Extract BufferWriter class
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
2020-01-14 15:03:14 +01:00

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;
}