bitcoinjs-lib
Version:
Client-side Bitcoin JavaScript library
30 lines (29 loc) • 1.22 kB
TypeScript
/// <reference types="node" />
/**
* Calculates the encoding length of a number used for push data in Bitcoin transactions.
* @param i The number to calculate the encoding length for.
* @returns The encoding length of the number.
*/
export declare function encodingLength(i: number): number;
/**
* Encodes a number into a buffer using a variable-length encoding scheme.
* The encoded buffer is written starting at the specified offset.
* Returns the size of the encoded buffer.
*
* @param buffer - The buffer to write the encoded data into.
* @param num - The number to encode.
* @param offset - The offset at which to start writing the encoded buffer.
* @returns The size of the encoded buffer.
*/
export declare function encode(buffer: Buffer, num: number, offset: number): number;
/**
* Decodes a buffer and returns information about the opcode, number, and size.
* @param buffer - The buffer to decode.
* @param offset - The offset within the buffer to start decoding.
* @returns An object containing the opcode, number, and size, or null if decoding fails.
*/
export declare function decode(buffer: Buffer, offset: number): {
opcode: number;
number: number;
size: number;
} | null;