function decode(buffer, offset) {
  const opcode = tools.readUInt8(buffer, offset);
  let num;
  let size;
  // ~6 bit
  if (opcode < OPS.OP_PUSHDATA1) {
    num = opcode;
    size = 1;
    // 8 bit
  } else if (opcode === OPS.OP_PUSHDATA1) {
    if (offset + 2 > buffer.length) return null;
    num = tools.readUInt8(buffer, offset + 1);
    size = 2;
    // 16 bit
  } else if (opcode === OPS.OP_PUSHDATA2) {
    if (offset + 3 > buffer.length) return null;
    num = tools.readUInt16(buffer, offset + 1, 'LE');
    size = 3;
    // 32 bit
  } else {
    if (offset + 5 > buffer.length) return null;
    if (opcode !== OPS.OP_PUSHDATA4) throw new Error('Unexpected opcode');
    num = tools.readUInt32(buffer, offset + 1, 'LE');
    size = 5;
  }
  return {
    opcode,
    number: num,
    size,
  };
}
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.